Back-end build week project for Sleep Tracker
- https://be-bw-sleep-tracker.herokuapp.com/ (Testing)
- https://bw-sleep-tracker-app.herokuapp.com/ (Production)
- Express:
Fast, unopinionated, minimalist web framework for Node.js
- Bcryptjs:
Allows you to store passwords securely in your database
- Jsonwebtoken:
Generate and verify json web tokens to maintain a stateless api
- Knex:
Knex.js is a "batteries included" SQL query builder for Postgres, MSSQL, MySQL, MariaDB, SQLite3, Oracle, and Amazon Redshift designed to be flexible, portable, and fun to use
- Knex-cleaner:
Helper library to clean a PostgreSQL, MySQL or SQLite3 database tables using Knex
- Pg:
Non-blocking PostgreSQL client for Node.js.
- Sqlite3:
Asynchronous, non-blocking SQLite3 bindings for Node.js.
- Cors:
CORS is a Node.js package for providing a Connect/Express middleware that can be used to enable CORS
- Helmet:
Helmet helps you secure your Express apps by setting various HTTP headers
- Dotenv:
Dotenv is a zero-dependency module that loads environment variables from a .env file
- Nodemon:
nodemon is a tool that helps develop Node.js based applications by automatically restarting the node application when file changes in the directory are detected
(# <--- signifies comment)
In your terminal run:
# Install dependencies
npm install
# Starts express server using nodemon
npm run server
Table | Method | Endpoint | Description |
---|---|---|---|
users | POST | /register | Creates a new user profile using the information sent inside the body of the request and returns a message along with the new user in the body of the response. |
users | POST | /login | Uses the credentials sent inside the body to authenticate the user. On successful login, returns a message with the user profile and a JSON Web Token token in the body of the response. |
users | PUT | /user/:id | The user will be able to update his settings after successful login. JSON web token should be available in the headers (Authorization) |
tracker | GET | /tracker/:id | Gets all the tracker information for the user id passed in the request parameters. The response will contain all the tracking information for the user sorted descending. The latest information will be first. |
tracker | POST | /tracker | Uses the tracker object sent inside the body to add the tracker information. |
tracker | GET | /tracker/:id/month/:month | Uses the user id and month provided in the request parameters to retrieve all the tracking information for the user for a particular month |
tracker | GET | /tracker/:id/year/:year | Uses the user id and year provided in the request parameters to retrieve all the tracking information for the user for a particular year |
tracker | GET | /tracker/:id/limit/:limit/order/:order | Uses the user id, limit and order details provided in the request to retrieve all the tracking information for a user. It would get only the number of items set in the limit. The order can be asc or desc |
tracker | PUT | /tracker | Uses the tracker object sent inside the body to update the tracking information |
tracker | DELETE | /tracker/:id/date/:date/year:year | Uses the id, date and year passed in the request parameter to delete the particular tracking information |
tracker | GET | /tracker/:id/date/:date | Uses the user id and date in the request to retrieve the particular tracking information |
tracker | GET | /user | Gets all the users in the system |
recommendation | POST | /recommendation | Uses the recommondation object in the body of the request to create a new recommendation |
recommendation | GET | /recommendation/:id | Gets all the recommendation available for a user based on the user id passed in the parameter |
recommendation | GET | /recommendation/:id/month/:month/year/:year | Gets all the recommendation for a user for a particular month and year |
recommendation | PUT | /recommendation | Updates the recommendation based on the recommendation object passed in the body |
recommendation | DELETE | /recommendation/:id/month/:month/year/:year | Deletes the recommendation for a user for that particular month and year |
tracker | GET | /tracker/:id/yearall/:year | Gets all the tracker information for year including the partially submitted records (having an emotion status of 5) |
Method Url: /register
HTTP method: [POST]
name | type | required | description |
---|---|---|---|
Content-Type |
String | Yes | Must be application/json |
name | type | required | description |
---|---|---|---|
username |
String | Yes | Must be unique |
password |
String | Yes | |
email |
String | Yes | |
first_name |
String | Yes | |
last_name |
String | Yes |
example:
{
"username":"g3ram",
"password":"password",
"email":"[email protected]",
"first_name":"Gayathri",
"last_name":"Ramakrishnan"
}
If you successfully register a user the endpoint will return an HTTP response with a status code
201
and a body as below.
example:
{
"user": {
"id": 3,
"username": "g3ram",
"password": "$2a$10$HXnXHP6WY8HEArAKXvNuh.KLFs5hBkqIOeWFycRCu3.Dhb4wt5ae.",
"email":"[email protected]",
"first_name":"Gayathri",
"last_name":"Ramakrishnan"
}
}
If you are missing any of the fields for registration, the endpoint will return an HTTP response with a status code
400
and a body as below.
example:
{
"message": "Please enter all the necessary credentials to register."
}
If there is a server or database error, the endpoint will return an HTTP response with a status code
500
and a body as below.
example:
{
"message": "Sorry, but something went wrong while registering"
}
Method Url: /login
HTTP method: [POST]
name | type | required | description |
---|---|---|---|
Content-Type |
String | Yes | Must be application/json |
name | type | required | description |
---|---|---|---|
username |
String | Yes | Must match a username in the database |
password |
String | Yes | Must match a password in the database corresponding to username above |
example:
{
"username":"g3ram",
"password":"password"
}
If you successfully login, the endpoint will return an HTTP response with a status code
200
and a body as below.
example:
{
"message": "g3ram is successfully logged in",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWJqZWN0IjoxLCJ1c2VybmFtZSI6InRlc3R1c2VyMSIsImlhdCI6MTU2MTMwNzAxOCwiZXhwIjoxNTYxMzkzNDE4fQ.uLuolcq01gufwrjUTbm0ecR8fjYJgWuou--ja3DKwOE"
}
If you are missing a email or password for login, the endpoint will return an HTTP response with a status code
400
and a body as below.
example:
{
"message": "Submit both an username and password when registering"
}
If you failt to login, the endpoint will return an HTTP response with a status code
401
which indicates the username and or password entered is not valid.
example:
{
message: "Sorry, incorrect email or password."
}
If there is a server or database error, the endpoint will return an HTTP response with a status code
500
and a body as below.
example:
{
"message": "Sorry, but something went wrong while logging in."
}
Method Url: /user/:id
HTTP method: [PUT]
name | type | required | description |
---|---|---|---|
Content-Type |
String | Yes | Must be application/json |
Authorization |
String | Yes | JSON Web Token |
name | type | required | description |
---|---|---|---|
id | Integer | Yes | ID of a specific user |
name | type | required | description |
---|---|---|---|
username |
String | Yes | Must be unique |
password |
String | Yes | |
email |
String | Yes | |
first_name |
String | Yes | |
last_name |
String | Yes |
example:
{
"username":"g3ram",
"password":"password",
"email":"[email protected]",
"first_name":"Tester_firstName",
"last_name":"Tester_lastName"
}
If a user with the specified ID in the URL parameters is updated successfully in the database, the endpoint will return an HTTP response with a status code
200
and a body as below.
example:
{
"id": 4,
"username": "g3ram",
"password": "password",
"email": "[email protected]",
"first_name": "Tester_firstName",
"last_name": "Tester_lastName"
}
If the user profile for the specified id can't be found in the database, the endpoint will return an HTTP response with a status code
404
and a body as below.
example:
{
"message": "Sorry, but that profile doesn't exist"
}
If you are missing any of the required field(s) - userId or user object(user object should have atleast email or first name or last name), the endpoint will return an HTTP response with a status code
400
and a body as below relating to the missing field(s).
example:
{
"message": "UserId or User object missing."
}
If there is a server or database error, the endpoint will return an HTTP response with a status code
500
and a body as below.
example:
{
"message": "Sorry, but something went wrong while updating the user information."
}
Method Url: /tracker/:id
HTTP method: [GET]
name | type | required | description |
---|---|---|---|
Content-Type |
String | Yes | Must be application/json |
Authorization |
String | Yes | JSON Web Token |
name | type | required | description |
---|---|---|---|
id | Integer | Yes | ID of a specific user |
No information is passed in the body
If a user with the specified ID in the URL parameters is available in the database, the endpoint will return an HTTP response with a status code
200
and a body as below.
example:
[
{
"user_id": 4,
"date": "06/21/2019",
"start_sleep_time": "22:00",
"end_sleep_time": "06:00",
"day_emotion": 4,
"sleep_emotion": 3,
"month": 6,
"year": 2019,
"day": 21
},
{
"user_id": 4,
"date": "06/22/2019",
"start_sleep_time": "22:00",
"end_sleep_time": "06:00",
"day_emotion": 4,
"sleep_emotion": 3,
"month": 6,
"year": 2019,
"day": 23
},
{
"user_id": 4,
"date": "06/23/2019",
"start_sleep_time": "22:00",
"end_sleep_time": "06:00",
"day_emotion": 4,
"sleep_emotion": 3,
"month": 6,
"year": 2019,
"day": 23
},
{
"user_id": 4,
"date": "06/24/2019",
"start_sleep_time": "22:00",
"end_sleep_time": "06:00",
"day_emotion": 4,
"sleep_emotion": 3,
"month": 6,
"year": 2019,
"day": 23
}
]
If the user profile for the specified id can't be found in the database, the endpoint will return an HTTP response with a status code
404
and a body as below.
example:
{
"message": "Sorry, unable to retrieve information for this user id."
}
If you are missing any of the required field(s) - userId , the endpoint will return an HTTP response with a status code
400
and a body as below relating to the missing field(s).
example:
{
"message": "The required user id is not available in the request parameters."
}
If there is a server or database error, the endpoint will return an HTTP response with a status code
500
and a body as below.
example:
{
"message": "Sorry, but something went wrong while trying to retrieve the tracker details for the user."
}
Method Url: /tracker/:id/month/:month
HTTP method: [GET]
name | type | required | description |
---|---|---|---|
Content-Type |
String | Yes | Must be application/json |
Authorization |
String | Yes | JSON Web Token |
name | type | required | description |
---|---|---|---|
id | Integer | Yes | ID of a specific user |
No information is passed in the body
If a user with the specified ID in the URL parameters is available in the database, all the tracking information for that user for that month will be retrieved. The endpoint will return an HTTP response with a status code
200
and a body as below.
example:
[
{
"user_id": 4,
"date": "06/21/2019",
"start_sleep_time": "22:00",
"end_sleep_time": "06:00",
"day_emotion": 4,
"sleep_emotion": 3,
"month": 6,
"year": 2019,
"day": 21
},
{
"user_id": 4,
"date": "06/22/2019",
"start_sleep_time": "22:00",
"end_sleep_time": "06:00",
"day_emotion": 4,
"sleep_emotion": 3,
"month": 6,
"year": 2019,
"day": 23
},
{
"user_id": 4,
"date": "06/23/2019",
"start_sleep_time": "22:00",
"end_sleep_time": "06:00",
"day_emotion": 4,
"sleep_emotion": 3,
"month": 6,
"year": 2019,
"day": 23
},
{
"user_id": 4,
"date": "06/24/2019",
"start_sleep_time": "22:00",
"end_sleep_time": "06:00",
"day_emotion": 4,
"sleep_emotion": 3,
"month": 6,
"year": 2019,
"day": 23
}
]
If the user profile for the specified id can't be found in the database, the endpoint will return an HTTP response with a status code
404
and a body as below.
example:
{
"message": "Sorry, unable to retrieve information for this user id."
}
If you are missing any of the required field(s) - userId , the endpoint will return an HTTP response with a status code
400
and a body as below relating to the missing field(s).
example:
{
"message": "The required user id or month is not available in the request parameters."
}
If there is a server or database error, the endpoint will return an HTTP response with a status code
500
and a body as below.
example:
{
"message": "Sorry, but something went wrong while trying to retrieve the tracker details for the user."
}
Method Url: /tracker/:id/year/:year
HTTP method: [GET]
name | type | required | description |
---|---|---|---|
Content-Type |
String | Yes | Must be application/json |
Authorization |
String | Yes | JSON Web Token |
name | type | required | description |
---|---|---|---|
id | Integer | Yes | ID of a specific user |
No information is passed in the body
If a user with the specified ID in the URL parameters is available in the database, all the tracking information for that user for that year will be retrieved. The endpoint will return an HTTP response with a status code
200
and a body as below.
example:
[
{
"user_id": 4,
"date": "06/21/2019",
"start_sleep_time": "22:00",
"end_sleep_time": "06:00",
"day_emotion": 4,
"sleep_emotion": 3,
"month": 6,
"year": 2019,
"day": 21
},
{
"user_id": 4,
"date": "06/22/2019",
"start_sleep_time": "22:00",
"end_sleep_time": "06:00",
"day_emotion": 4,
"sleep_emotion": 3,
"month": 6,
"year": 2019,
"day": 23
},
{
"user_id": 4,
"date": "06/23/2019",
"start_sleep_time": "22:00",
"end_sleep_time": "06:00",
"day_emotion": 4,
"sleep_emotion": 3,
"month": 6,
"year": 2019,
"day": 23
},
{
"user_id": 4,
"date": "06/24/2019",
"start_sleep_time": "22:00",
"end_sleep_time": "06:00",
"day_emotion": 4,
"sleep_emotion": 3,
"month": 6,
"year": 2019,
"day": 23
}
]
If the user profile for the specified id can't be found in the database, the endpoint will return an HTTP response with a status code
404
and a body as below.
example:
{
"message": "Sorry, unable to retrieve information for this user id."
}
If you are missing any of the required field(s) - userId , the endpoint will return an HTTP response with a status code
400
and a body as below relating to the missing field(s).
example:
{
"message": "The required user id or year is not available in the request parameters."
}
If there is a server or database error, the endpoint will return an HTTP response with a status code
500
and a body as below.
example:
{
"message": "Sorry, but something went wrong while trying to retrieve the tracker details for the user."
}
Method Url: /tracker/:id/limit/:limit/order/:order
HTTP method: [GET]
name | type | required | description |
---|---|---|---|
Content-Type |
String | Yes | Must be application/json |
Authorization |
String | Yes | JSON Web Token |
name | type | required | description |
---|---|---|---|
id | Integer | Yes | ID of a specific user |
No information is passed in the body
If a user with the specified ID in the URL parameters is available in the database, all the tracking information for that user will be retrieved. limit (Should be set to the number of records) and order (should be set to 'asc' or 'desc'). The endpoint will return an HTTP response with a status code
200
and a body as below. In the example below - limit is set to 2 and order is 'asc'
example:
[
{
"user_id": 4,
"date": "06/21/2019",
"start_sleep_time": "22:00",
"end_sleep_time": "06:00",
"day_emotion": 4,
"sleep_emotion": 3,
"month": 6,
"year": 2019,
"day": 21
},
{
"user_id": 4,
"date": "06/22/2019",
"start_sleep_time": "22:00",
"end_sleep_time": "06:00",
"day_emotion": 4,
"sleep_emotion": 3,
"month": 6,
"year": 2019,
"day": 23
}
]
If the user profile for the specified id can't be found in the database, the endpoint will return an HTTP response with a status code
404
and a body as below.
example:
{
"message": "Sorry, unable to retrieve information for this user id."
}
If you are missing any of the required field(s) - userId , the endpoint will return an HTTP response with a status code
400
and a body as below relating to the missing field(s).
example:
{
"message": "The required user id or limit or order is not available in the request parameters."
}
The following message will be displayed if invalid value is passed for limit or order.
{
"message":The limit value or the order value in the request parameter is not valid.
}
If there is a server or database error, the endpoint will return an HTTP response with a status code
500
and a body as below.
example:
{
"message": "Sorry, but something went wrong while trying to retrieve the tracker details for the user."
}
Method Url: /tracker/
HTTP method: [POST]
name | type | required | description |
---|---|---|---|
Content-Type |
String | Yes | Must be application/json |
Authorization |
String | Yes | JSON Web Token |
name | type | required | description |
---|---|---|---|
user_id |
String | Yes | Must be unique |
date |
String | Yes | |
start_sleep_time |
String | Yes | |
end_sleep_time |
String | Yes | |
day_emotion |
String | Yes | |
sleep_emotion |
Integer | Yes | |
month |
Integer | Yes | |
year |
Integer | Yes | |
day |
Integer | Yes |
example:
{
"user_id":4,
"date":"06/25/2019",
"start_sleep_time":"22:00",
"end_sleep_time":"06:00",
"day_emotion":4,
"sleep_emotion":3,
"month":6,
"day":20,
"year":2019
}
If a tracking info for the user is added successfully in the database, the endpoint will return an HTTP response with a status code
200
and a body as below.
example:
{
"user_id": 4,
"date": "06/25/2019",
"start_sleep_time": "22:00",
"end_sleep_time": "06:00",
"day_emotion": 4,
"sleep_emotion": 3,
"month": 6,
"year": 2019,
"day": 20
}
If you are missing the tracking information in the request body, the endpoint will return an HTTP response with a status code
400
and a body as below relating to the missing field(s).
example:
{
"message": "Missing tracker information."
}
If there is a server or database error, the endpoint will return an HTTP response with a status code
500
and a body as below.
example:
{
"message": "Sorry, but something went wrong while trying to add the tracking information."
}
Method Url: /tracker/
HTTP method: [PUT]
name | type | required | description |
---|---|---|---|
Content-Type |
String | Yes | Must be application/json |
Authorization |
String | Yes | JSON Web Token |
name | type | required | description |
---|---|---|---|
user_id |
String | Yes | Must be unique |
date |
String | Yes | |
start_sleep_time |
String | No | |
end_sleep_time |
String | No | |
day_emotion |
String | No | |
sleep_emotion |
Integer | No | |
month |
Integer | No | |
year |
Integer | No | |
day |
Integer | No |
example:
{
"user_id":4,
"date":"06/25/2019",
"end_sleep_time":"06:00",
"day_emotion":3,
"day":25
}
If a tracking info for the user is udpated successfully in the database, the endpoint will return an HTTP response with a status code
200
and a body as below.
example:
{
"user_id": 4,
"date": "06/25/2019",
"start_sleep_time": "22:00",
"end_sleep_time": "06:00",
"day_emotion": 3,
"sleep_emotion": 3,
"month": 6,
"year": 2019,
"day": 25
}
If the tracking information for the specified user and date can't be found in the database, the endpoint will return an HTTP response with a status code
404
and a body as below.
example:
{
"message": "The tracker information requested to update cannot be found."
}
If you are missing the tracking information in the request body, the endpoint will return an HTTP response with a status code
400
and a body as below relating to the missing field(s).
example:
{
"message": "Tracker is missing userId or date for update."
}
If there is a server or database error, the endpoint will return an HTTP response with a status code
500
and a body as below.
example:
{
"message": "Sorry, but something went wrong while trying to update the tracker details for the user."
}
Method Url: /tracker/:id/date/:date
HTTP method: [DELETE]
name | type | required | description |
---|---|---|---|
Content-Type |
String | Yes | Must be application/json |
Authorization |
String | Yes | JSON Web Token |
If a tracking info for the user is deleted successfully in the database, the endpoint will return an HTTP response with a status code
200
and a body as below.
example:
{
"message":"Tracker info successfully deleted."
}
If the tracking information for the specified user and date can't be found in the database, the endpoint will return an HTTP response with a status code
404
and a body as below.
example:
{
"message": "The tracker information requested to update cannot be found."
}
If you are missing the tracking information in the request parameter, the endpoint will return an HTTP response with a status code
400
and a body as below relating to the missing field(s).
example:
{
"message": "The userid or date request parameter is missing."
}
If there is a server or database error, the endpoint will return an HTTP response with a status code
500
and a body as below.
example:
{
"message": "Sorry, but something went wrong while trying to delete the tracker details for the user."
}
Method Url: /tracker/:id/date/:date
HTTP method: [GET]
name | type | required | description |
---|---|---|---|
Content-Type |
String | Yes | Must be application/json |
Authorization |
String | Yes | JSON Web Token |
name | type | required | description |
---|---|---|---|
id | Integer | Yes | ID of a specific user |
date | String | Yes |
No information is passed in the body
If a user with the specified ID and the date in the URL parameters is available in the database, all the tracking information for that user for that date will be retrieved. The endpoint will return an HTTP response with a status code
200
and a body as below.
example:
{
"user_id": 4,
"date": "06/21/2019",
"start_sleep_time": "22:00",
"end_sleep_time": "06:00",
"day_emotion": 4,
"sleep_emotion": 3,
"month": 6,
"year": 2019,
"day": 21
}
If the user profile for the specified id can't be found in the database, the endpoint will return an HTTP response with a status code
404
and a body as below.
example:
{
"message": "Sorry, unable to retrieve information for this user id."
}
If you are missing any of the required field(s) - userId , the endpoint will return an HTTP response with a status code
400
and a body as below relating to the missing field(s).
example:
{
"message": "The id or date is missing in request parameters."
}
If there is a server or database error, the endpoint will return an HTTP response with a status code
500
and a body as below.
example:
{
"message": "Sorry, but something went wrong while trying to retrieve the tracker details for the user."
}
Method Url: /recommendation/:id
HTTP method: [GET]
name | type | required | description |
---|---|---|---|
Content-Type |
String | Yes | Must be application/json |
Authorization |
String | Yes | JSON Web Token |
name | type | required | description |
---|---|---|---|
id | Integer | Yes | ID of a specific user |
No information is passed in the body
If a user with the specified ID in the URL parameters is available in the database, all the recommendation information for that user will be retrieved. The endpoint will return an HTTP response with a status code
200
and a body as below.
example:
[
{
"user_id": 4,
"month": 3,
"year": 2019,
"recommendation": "No data available for this time period."
},
{
"user_id": 4,
"month": 5,
"year": 2019,
"recommendation": "No data available for this time period"
},
{
"user_id": 4,
"month": 6,
"year": 2019,
"recommendation": "Very well slept!"
}
]
If the user profile for the specified id can't be found in the database, the endpoint will return an HTTP response with a status code
404
and a body as below.
example:
{
"message": "Sorry, unable to retrieve information for this user id."
}
If you are missing any of the required field(s) - userId , the endpoint will return an HTTP response with a status code
400
and a body as below relating to the missing field(s).
example:
{
"message": "The id is missing in request parameters."
}
If there is a server or database error, the endpoint will return an HTTP response with a status code
500
and a body as below.
example:
{
"message": "Sorry, but something went wrong while trying to retrieve the recommendation details for the user."
}
Method Url: /recommendation/:id/month/:month/year/:year
HTTP method: [GET]
name | type | required | description |
---|---|---|---|
Content-Type |
String | Yes | Must be application/json |
Authorization |
String | Yes | JSON Web Token |
name | type | required | description |
---|---|---|---|
id | Integer | Yes | ID of a specific user |
month | Integer | Yes | |
year | Integer | Yes |
No information is passed in the body
If a user with the specified ID and the date in the URL parameters is available in the database, all the tracking information for that user for that date will be retrieved. The endpoint will return an HTTP response with a status code
200
and a body as below.
example:
{
"user_id": 4,
"month": 6,
"year": 2019,
"recommendation": "Very well slept!"
}
If the user profile for the specified id can't be found in the database, the endpoint will return an HTTP response with a status code
404
and a body as below.
example:
{
"message": "Sorry, unable to retrieve information for this user id."
}
If you are missing any of the required field(s) - userId , the endpoint will return an HTTP response with a status code
400
and a body as below relating to the missing field(s).
example:
{
"message": "The id or date is missing in request parameters."
}
If there is a server or database error, the endpoint will return an HTTP response with a status code
500
and a body as below.
example:
{
"message": "Sorry, but something went wrong while trying to retrieve the recommendation details for the user."
}
Method Url: /recommendation/
HTTP method: [POST]
name | type | required | description |
---|---|---|---|
Content-Type |
String | Yes | Must be application/json |
Authorization |
String | Yes | JSON Web Token |
name | type | required | description |
---|---|---|---|
user_id |
String | Yes | Must be unique |
month |
Integer | Yes | |
year |
Integer | Yes | |
recommendation |
String | Yes |
example:
{
"user_id":4,
"month":4,
"year":2019,
"recommendation":"No data available for this time period"
}
If a tracking info for the user is added successfully in the database, the endpoint will return an HTTP response with a status code
200
and a body as below.
example:
{
"user_id":4,
"month":4,
"year":2019,
"recommendation":"No data available for this time period"
}
If you are missing the tracking information in the request body, the endpoint will return an HTTP response with a status code
400
and a body as below relating to the missing field(s).
example:
{
"message": "Missing recommendation information in request body."
}
If there is a server or database error, the endpoint will return an HTTP response with a status code
500
and a body as below.
example:
{
"message": "Sorry, but something went wrong while trying to add the recommendation information."
}
Method Url: /recommendation/
HTTP method: [PUT]
name | type | required | description |
---|---|---|---|
Content-Type |
String | Yes | Must be application/json |
Authorization |
String | Yes | JSON Web Token |
name | type | required | description |
---|---|---|---|
user_id |
String | Yes | Must be unique |
month |
Integer | Yes | |
year |
Integer | Yes | |
recommendation |
String | Yes |
example:
{
"user_id":4,
"month":4,
"year":2019,
"recommendation":"No data available for this time period.!!!"
}
If a tracking info for the user is udpated successfully in the database, the endpoint will return an HTTP response with a status code
200
and a body as below.
example:
{
"user_id": 4,
"month": 4,
"year": 2019,
"recommendation": "No data available for this time period.!!!"
}
If you are missing the tracking information in the request body, the endpoint will return an HTTP response with a status code
400
and a body as below relating to the missing field(s).
example:
{
"message": "Recommendation to be updated is missing in request parameter."
}
If there is a server or database error, the endpoint will return an HTTP response with a status code
500
and a body as below.
example:
{
"message": "Sorry, but something went wrong while trying to update the tracker details for the user."
}
Method Url: /recommendation/:id/month/:month/year/:year
HTTP method: [DELETE]
name | type | required | description |
---|---|---|---|
Content-Type |
String | Yes | Must be application/json |
Authorization |
String | Yes | JSON Web Token |
If a tracking info for the user is deleted successfully in the database, the endpoint will return an HTTP response with a status code
200
and a body as below.
example:
{
"message":"The Recommendation was deleted successfully."
}
If you are missing the tracking information in the request parameter, the endpoint will return an HTTP response with a status code
400
and a body as below relating to the missing field(s).
example:
{
"message": "The request parameters - userId, year and month are missing."
}
If there is a server or database error, the endpoint will return an HTTP response with a status code
500
and a body as below.
example:
{
"message": "Sorry, but something went wrong while trying to delete the recommendation details for the user."
}
Method Url: /logout
HTTP method: [GET]