Todo Application
Given an
Write APIs to perform operations on the table
Todo Table
Column | Type |
---|---|
id | INTEGER |
todo | TEXT |
category | TEXT |
priority | TEXT |
status | TEXT |
due_date | DATE |
- Replace the spaces in URL with %20.
- Possible values for priorityareHIGH,MEDIUM, andLOW.
- Possible values for statusareTO DO,IN PROGRESS, andDONE.
- Possible values for categoryareWORK,HOME, andLEARNING.
- Use the format yyyy-MM-ddfor formating with date-fnsformatfunction.
- The user may request with due date value as 2021-1-21, format the date to2021-01-21and perform Create, Read, Update operations on the database.
Invalid scenarios for all APIs
- Invalid Status
- Response
- Status code 400
- Body Invalid Todo Status
- Invalid Priority
- Response
- Status code 400
- Body Invalid Todo Priority
Invalid Category
- Response
- Status code 400
- Body Invalid Todo Category
Invalid Due Date
- Response
- Status code
400
- Body
Invalid Due Date
API 1
Path: /todos/
Method: GET
Scenario 1
- Sample API /todos/?status=TO%20DO
- Description:
Returns a list of all todos whose status is 'TO DO'
- Response
- Sample API
Scenario 2
- Sample API /todos/?priority=HIGH
- Description:
Returns a list of all todos whose priority is 'HIGH'
- Response
- Sample API
Scenario 3
- Sample API /todos/?priority=HIGH&status=IN%20PROGRESS
- Description:
Returns a list of all todos whose priority is 'HIGH' and status is 'IN PROGRESS'
- Response
- Sample API
Scenario 4
- Sample API /todos/?search_q=Buy
- Description:
Returns a list of all todos whose todo contains 'Buy' text
- Response
- Sample API
Scenario 5
- Sample API /todos/?category=WORK&status=DONE
- Description:
Returns a list of all todos whose category is 'WORK' and status is 'DONE'
- Response
- Sample API
Scenario 6
- Sample API /todos/?category=HOME
- Description:
Returns a list of all todos whose category is 'HOME'
- Response
- Sample API
Scenario 7
- Sample API /todos/?category=LEARNING&priority=HIGH
- Description:
Returns a list of all todos whose category is 'LEARNING' and priority is 'HIGH'
- Response
- Sample API
API 2
Path: /todos/:todoId/
Method: GET
Description:
Returns a specific todo based on the todo ID
Response
API 3
Path: /agenda/
Method: GET
Description:
Returns a list of all todos with a specific due date in the query parameter
Response
API 4
Path: /todos/
Method: POST
Description:
Create a todo in the todo table,
Request
Response
API 5
Path: /todos/:todoId/
Method: PUT
Description:
Updates the details of a specific todo based on the todo ID
Scenario 1
- Request { "status": "DONE" }
- Response
- Request
Scenario 2
- Request { "priority": "HIGH" }
- Response
- Request
Scenario 3
- Request
- Response
Scenario 4
- Request { "category": "LEARNING" }
- Response
- Request
Scenario 5
- Request { "dueDate": "2021-01-12" }
- Response
- Request
API 6
Path: /todos/:todoId/
Method: DELETE
Description:
Deletes a todo from the todo table based on the todo ID
Response
Use
Export the express instance using the default export syntax.
Use Common JS module syntax.
Given an
Write APIs to perform operations on the tables
User Table
Column | Type |
---|---|
user_id | INTEGER |
name | TEXT |
username | TEXT |
password | TEXT |
gender | TEXT |
Follower Table
Column | Type |
---|---|
follower_id | INTEGER |
follower_user_id | INTEGER |
following_user_id | INTEGER |
Here, if user1 follows user2 then,
Tweet Table
Column | Type |
---|---|
tweet_id | INTEGER |
tweet | TEXT |
user_id | INTEGER |
date_time | DATETIME |
Reply Table
Column | Type |
---|---|
reply_id | INTEGER |
tweet_id | INTEGER |
reply | TEXT |
user_id | INTEGER |
date_time | DATETIME |
Like Table
Column | Type |
---|---|
like_id | INTEGER |
tweet_id | INTEGER |
user_id | INTEGER |
date_time | DATETIME |
Sample Valid User Credentials
API 1
Path: /register/
Method: POST
Request
Scenario 1
Description:
If the username already exists
Response
- Status code
400
- Body
User already exists
- Status code
Scenario 2
Description:
If the registrant provides a password with less than 6 characters
Response
- Status code
400
- Body
Password is too short
- Status code
Scenario 3
Description:
Successful registration of the registrant
Response
Status code
Body
User created successfully
API 2
Path: /login/
Method: POST
Request
Scenario 1
Description:
If the user doesn't have a Twitter account
Response
- Status code
400
- Body
Invalid user
- Status code
Scenario 2
Description:
If the user provides an incorrect password
Response
- Status code
400
- Body
Invalid password
- Status code
Scenario 3
Description:
Successful login of the user
Response
Return the JWT Token
Authentication with JWT Token
Write a middleware to authenticate the JWT token.
Scenario 1
Description:
If the JWT token is not provided by the user or an invalid JWT token is provided
Response
- Status code
401
- Body
Invalid JWT Token
- Status code
Scenario 2
- After successful verification of JWT token, proceed to next middleware or handler
API 3
Path: /user/tweets/feed/
Method: GET
Description:
Returns the latest tweets of people whom the user follows. Return 4 tweets at a time
Response
API 4
Path: /user/following/
Method: GET
Description:
Returns the list of all names of people whom the user follows
Response
API 5
Path: /user/followers/
Method: GET
Description:
Returns the list of all names of people who follows the user
Response
API 6
Path: /tweets/:tweetId/
Method: GET
Scenario 1
Description:
If the user requests a tweet other than the users he is following
Response
- Status code
401
- Body
Invalid Request
- Status code
Scenario 2
Description:
If the user requests a tweet of the user he is following, return the tweet, likes count, replies count and date-time
Response
{ "tweet": "T 3859 - do something wonderful, people may imitate it ..", "likes": 3, "replies": 1, "dateTime": "2021-04-07 14:50:19" }
API 7
Path: /tweets/:tweetId/likes/
Method: GET
Scenario 1
Description:
If the user requests a tweet other than the users he is following
Response
- Status code
401
- Body
Invalid Request
- Status code
Scenario 2
Description:
If the user requests a tweet of a user he is following, return the list of usernames who liked the tweet
Response
{ "likes": ["albert", ] }
API 8
Path: /tweets/:tweetId/replies/
Method: GET
Scenario 1
Description:
If the user requests a tweet other than the users he is following
Response
- Status code
401
- Body
Invalid Request
- Status code
Scenario 2
Description:
If the user requests a tweet of a user he is following, return the list of replies.
Response
API 9
Path: /user/tweets/
Method: GET
Description:
Returns a list of all tweets of the user
Response
API 10
Path: /user/tweets/
Method: POST
Description:
Create a tweet in the tweet table
Request
Response
API 11
Path: /tweets/:tweetId/
Method: DELETE
Scenario 1
Description:
If the user requests to delete a tweet of other users
Response
- Status code
401
- Body
Invalid Request
- Status code
Scenario 2
Description:
If the user deletes his tweet
Response
Tweet Removed
Use
Export the express instance using the default export syntax.
Use Common JS module syntax.