Manage your Contacts on apps you develop with this companion backend.
TOC:
Varname | Definition | required |
---|---|---|
PORT | Port on which the backend will be hosted | YES |
MONGODB_URI | URI string to the MongoDB | YES |
COOKIE_SECRET | Sercret used to sign Cookies with | YES |
TOKEN_SECRET | Secret to Sign JWT Token with | YES |
Method: GET
Action: Base route\
Response:
{
"state": "OK",
"url": "/"
}
Method: GET
Action: Get some details about the servers health
Response:
{
"status": "",
"uptime": ,
"upSince": "",
"localTime": "",
"service": {
"name": "",
"version": ""
},
"connections": {
"database": ""
},
"env": {
"nodeVersion": "",
"processName": "",
"pid": ,
"cwd": ""
},
"git": {
"commitHash": "",
"branchName": "",
"tag":
}
}
Method: POST
Action: Signs in a user. After a successfull login, token is set into a cookie and sent to client, while also being sent in the Response object
Request:
{
"email": "",
"password": ""
}
email
: Email for signing in.
password
: Password for signing in.
Response:
{
"success": ,
"User": {
"uName": "",
"fName": "",
"lName": "",
"contact": {
"email": "",
"phone": ""
}
},
"token": ""
}
Method:POST
Action: Signs in a user. After a successfull login, token is set into a cookie and sent to client, while also being sent in the Response object
Request:
{
"fName": "",
"lName": "",
"uName": "",
"email": "",
"phone": "",
"password": ""
}
fName
: First Name of the User
lName
: Last Name of the User
uName
: User Name of the User
email
: Email for the User
phone
: Phone number of the User
password
: password for the User Account
Response:
{
"state": ""
}
Method:POST
Action: This Routes will remove the Cookies set by express which contains the JWT token
Needs Auth
Method:POST
Action: Get the profile of the currently logged in user
Response:
{
"meta": {
"createdAt": ""
},
"contact": {
"email": "",
"phone": ""
},
"fName": "",
"lName": "",
"uName": ""
}
Needs Auth
Mehtod: GET
Action: Get a list of contacts, added under a specific user
Response:
[
.,
{
"meta": {
"createdAt": ""
},
"contact": {
"email": "",
"phone": ""
},
"_id": "",
"cName": "",
"cType": ""
},
.
.
.
]
Needs Auth
Method: GET
Action: If thecid
url parameter is provided, returns with the cotact details with_id
responing to thatcid
. If not supplied, returns a list of contacts under that user.
Response:
{
"meta": {
"createdAt": ""
},
"contact": {
"email": "",
"phone": ""
},
"_id": "",
"cName": "",
"cType": ""
}
Needs Auth
Method: POST
Action: Create a new Contact under the currently signed in user
{
"cName": "",
"email": "",
"phone": "",
"cType": ""
}
cName
: Name of the contact (required)
email
: Email address of the contact (required)
phone
: Phone number of the contact (required)
cType
: Type of contact detail (optional) [defaults: NULL
]
Response:
{
"state": ""
}
Needs Auth
Method: PUT
Action: Updates only one field that has been supplied on the Request body on the database object with_id
ofcid
Payload:
{
"key": "",
"value": ""
}
key
: can be one of these (cName, cType, email, phone)
value
: new value to replace to old value with
Response:
{
"state": ""
}
Needs Auth
Method: DELETE
Action: Deletes the Contact related to the givencid
url parameter if the contact is created by the currently logged user
Response:
{
"state": ""
}