https://github.com/ervin-sungkono/todo-app-api
Todo App API using NodeJS, Express, and MySQL
https://github.com/ervin-sungkono/todo-app-api
express mysql nodejs rest-api
Last synced: 3 months ago
JSON representation
Todo App API using NodeJS, Express, and MySQL
- Host: GitHub
- URL: https://github.com/ervin-sungkono/todo-app-api
- Owner: ervin-sungkono
- Created: 2022-08-24T04:15:26.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2023-04-16T14:54:34.000Z (about 3 years ago)
- Last Synced: 2025-01-11T15:34:43.824Z (over 1 year ago)
- Topics: express, mysql, nodejs, rest-api
- Language: JavaScript
- Homepage: https://todo-app-api.glitch.me
- Size: 40 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Todo App API
Todo App API using NodeJS, Express, and MySQL
## Features
1. Authentication API using JWT Token
2. CRUD Todo using REST API
## Installation Guide
1. Clone the project
```sh
git clone https://github.com/ervin-sungkono/Todo-App-BE.git
```
2. Install dependencies
```sh
npm install
```
3. Generate .env file and remove .env.example
```sh
cp .env.example .env
```
4. Set up environment variables
5. Run the project
```sh
npm start
```
## Endpoints
This API uses Authentication from JWT Token to accesss certain endpoints, check guides below for getting authenticated.
### Authentication
Request:
```http
GET /user
```
Returns the information of the currently authenticated user.
Request:
```http
POST /user/register
```
| Parameter | Type | Description |
| :--- | :--- | :--- |
| `username` | `string` | **Required**. Your Username |
| `password` | `string` | **Required**. Your Password |
| `confirmPassword` | `string` | **Required**. Your Confirm Password |
| `email` | `string` | **Required**. Your Email Address |
Registers the user into database.
Request:
```http
POST /user/login
```
| Parameter | Type | Description |
| :--- | :--- | :--- |
| `username` | `string` | **Required**. Your Username |
| `password` | `string` | **Required**. Your Password |
Authenticate the user, will return a token in response.
### CRUD Todo
Request:
```http
GET /todo
```
Returns all the todo list that is created by the user.
Request:
```http
GET /todo/id
```
Returns a todo with the given id if it is created by the user.
Request:
```http
POST /todo
```
| Parameter | Type | Description |
| :--- | :--- | :--- |
| `title` | `string` | **Required**. Your Todo Title |
| `due_date` | `date` | **Required**. Due Date for the Todo |
Adds a todo into the database.
Request:
```http
PATCH /todo/id
```
| Parameter | Type | Description |
| :--- | :--- | :--- |
| `title` | `string` | **Required**. Your Todo Title |
| `due_date` | `date` | **Required**. Due Date for the Todo |
| `completed` | `tinyint` | **Required**. Determines whether Todo is completed or not |
Updates a todo with given id.
Request:
```http
DELETE/todo/id
```
Deletes a todo with given id.
## Status Codes
| Status Code | Description |
| :--- | :--- |
| 200 | `OK` |
| 201 | `CREATED` |
| 400 | `BAD REQUEST` |
| 409 | `CONFLICT` |
| 422 | `UNPROCESSABLE ENTITY` |