A simple to-do app created in node.js, express, postgres. It has following features:
- RESTful endpoint to do CRUD actions on to-do item and returns JSON formatted response.
- User system, separate to-dos by user
- Stateless authentication using JSONWebToken
- Uses Bored API to add new random activity to to-do list
- Uses Google Sign-In for Websites to log in with Google Account
The client is a Single Page App created in HTML, CSS, and JavaScript using Materialize and jQuery
Registers a new account
{
"Content-Type": "application/json"
}
{
"email": "[email protected]",
"password": "passwordhere"
}
{
"id": 9,
"email": "[email protected]",
"password": "test"
}
Happens when the validation doesn't pass or the e-mail has been registered
{
"errors": [
"This E-mail has been registered."
]
}
{
"errors": [
"password is required.",
"email is required.",
"email is not valid."
]
}
Logs in to an account to access to-do item
{
"Content-Type": "application/json"
}
{
"email": "[email protected]",
"password": "passwordhere"
}
Returns an access token that you can use to access the to-do item
{
"accessToken": "[ACCESS TOKEN HERE]"
}
Happens when the password or e-mail entered is not valid
{
"errors": "Invalid Username/Password"
}
Get the list of all to-dos created by logged in user
{
"accessToken": "ACCESS TOKEN HERE"
}
[
{
"id": 1,
"title": "Todo 1",
"description": "Todo List 1",
"status": "uncompleted",
"due_date": "2020-04-10T17:00:00.000Z"
},
{
"id": 2,
"title": "Todo 2",
"description": "Todo List 2",
"status": "uncompleted",
"due_date": "2020-04-14T17:00:00.000Z"
},
{
"id": 3,
"title": "Todo 3",
"description": "Todo List 3",
"status": "completed",
"due_date": "2020-04-18T17:00:00.000Z"
}
]
Happens if you haven't set "accessToken" request header or the token is invalid
{
"errors": "Invalid or missing token"
}
Get the specific to-do item. Only can access todo item created by logged in user.
Name | Description |
---|---|
id | ID of the to-do item |
{
"accessToken": "ACCESS TOKEN HERE"
}
Returns data of the to-dos
{
"id": 1,
"title": "Todo 1",
"description": "Todo List 1",
"status": "uncompleted",
"due_date": "2020-04-10T17:00:00.000Z"
}
Happens if you haven't set "accessToken" request header or the token is invalid
{
"errors": "Invalid or missing token"
}
Happens if you access other user to-do item
{
"errors": "You are not authorized to access this item"
}
{
"errors": "Todo not found"
}
Add new to-do item
{
"Content-Type": "application/json",
"accessToken": "ACCESS TOKEN HERE"
}
{
"title": "Todo Title",
"description": "Descriptions here",
"status": "uncompleted",
"due_date": "2020-01-01"
}
Returns data of the created to-do item
{
"id": 7,
"title": "Todo Title",
"description": "Descriptions here",
"status": "uncompleted",
"due_date": "2020-01-01T00:00:00.000Z"
}
Usually returns validation errors
{
"errors": [
"title is empty",
"description is empty",
"status is empty",
"due_date is empty",
"due_date must be in date format: YYYY-MM-DD"
]
}
Happens if you haven't set "accessToken" request header or the token is invalid
{
"errors": "Invalid or missing token"
}
Add new to-do item with random activity
{
"Content-Type": "application/json"
}
If omitted, the due date will be calculated by how accessible/possible the activity is ranged from 3 to 30 days
{
"due_date": "2020-01-01"
}
Returns data of the created to-do item
{
"id": 15,
"title": "Random activity #4708863",
"description": "Listen to a new music genre",
"status": "uncompleted",
"due_date": "2020-04-03T13:49:10.974Z"
}
Usually returns validation errors
{
"errors": [
"due_date must be in date format: YYYY-MM-DD"
]
}
Happens if you haven't set "accessToken" request header or the token is invalid
{
"errors": "Invalid or missing token"
}
Edit specific to-do item. Only can access todo item created by logged in user.
Name | Description |
---|---|
id | ID of the to-do item |
{
"Content-Type": "application/json",
"accessToken": "ACCESS TOKEN HERE"
}
{
"title": "Todo Title",
"description": "Descriptions here",
"status": "uncompleted",
"due_date": "2020-01-01"
}
Returns updated data of the edited to-do item
{
"id": 7,
"title": "Todo Title",
"description": "Descriptions here",
"status": "uncompleted",
"due_date": "2020-01-01T00:00:00.000Z"
}
Usually returns validation errors
{
"errors": [
"title is empty",
"description is empty",
"status is empty",
"due_date is empty",
"due_date must be in date format: YYYY-MM-DD"
]
}
Happens if you haven't set "accessToken" request header or the token is invalid
{
"errors": "Invalid or missing token"
}
Happens if you access other user to-do item
{
"errors": "You are not authorized to access this item"
}
{
"errors": "Todo not found"
}
Delete specific to-do item. Only can access todo item created by logged in user.
Name | Description |
---|---|
id | ID of the to-do item |
{
"accessToken": "ACCESS TOKEN HERE"
}
Returns data of the deleted to-do item
{
"id": 7,
"title": "Todo Title",
"description": "Descriptions here",
"status": "uncompleted",
"due_date": "2020-01-01T00:00:00.000Z"
}
Happens if you haven't set "accessToken" request header or the token is invalid
{
"errors": "Invalid or missing token"
}
Happens if you access other user to-do item
{
"errors": "You are not authorized to access this item"
}
{
"errors": "Todo not found"
}