Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Luky Winata #10

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
323 changes: 322 additions & 1 deletion README.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1 +1,322 @@
# fancy-todo
# Fancy To Do
# Author : Luky Winata

**How To**

```
Client Site: http://localhost:8080/
Server Site: http://35.197.153.90 /
npm init -y (inside root server folder)
npm run dev (on terminal inside root server folder)
live-server --host=localhost (on terminal inside root client folder)
.env-template: PORT, DB_URI, JWT_SECRET, CLIENT_ID (Google), API_KEY (Air Visual)
```

**List of Routes User:**

| **Route** | **HTTP** | **Description** |
| ----------------- | -------- | ------------------------------------------- |
| /user/register | POST | Sign up with new user info |
| /user/login | POST | Sign in and get an access token |
| /user/googleLogin | POST | Sign in with google and get an access token |

**List of Routes Task:**

| **Route** | **HTTP** | **Description** | **Notes** |
| --------- | -------- | ------------------------------- | ----------------------- |
| /task | POST | Create a task | Authenticated user only |
| /task | GET | Get all tasks' info | Authenticated user only |
| /task/:id | GET | Get a single task's detail | Authorized user only |
| /task/:id | PUT | Update a task with new details | Authorized user only |
| /task/:id | PATCH | Undo a task from Done to Active | Authorized user only |
| /task/:id | DELETE | Delete a task | Authorized user only |

**Errors:**

| Code | Name | Description |
| ---- | --------------------- | --------------------- |
| 400 | Bad Request | Client's Mistake |
| 401 | Authentication Failed | Unauthorized Access |
| 403 | Unauthorized Access | Invalid Access Token |
| 500 | Internal Server Error | Internal Error |

**400:**
```
{
[
"Name is required",
"E-mail is required",
"Password is required"
]
}
```

**401:**
```
{
"message": "User is unauthorized for this access"
}
```

**403:**
```
{
"message": "User's session has been expired"
}
```

**500:**

```
{
"message": "Internal Server Error"
}
```

**Register User**
----
* **URL:** `/user/register`

* **Method:** `POST`

* **Body Data:**

```
name: Luky Winata
email: [email protected]
password: 12345678
```

* **Success Response:**

* **Status:** 201
**Content:**

```
{
"_id": "5dbd4a607ad5b61201781b95",
"name": "Luky Winata",
"email": "[email protected]",
"password": "$2a$10$dSgyVFM47duFThRKlEBJG.paG2GMt.pMbcsBKgWcjlfDVSZQmLdO6",
"__v": 0
}
```


**Login User**
----

* **URL:** `/user/login`

* **Method:** `POST`

* **Body Data:**

```
email: [email protected]
password: 12345678
```

* **Success Response:**

* **Status:** 200
**Content:**

```
{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
```


**Add New Task**
----

* **URL:** `/task`

* **Method:** `POST`

* **Headers:** `access_token = [string]`

* **Body Data:**

```
title: Hacktiv8 Phase 2
description: (allow empty)
dueDate: 30 November 2019
```

* **Success Response:**

* **Status:** 201
**Content:**

```
{
"_id": "5dbd56c73b90dd0eaaf71f10",
"title": "Hacktiv8 Phase 2",
"description": "",
"status": "Active",
"dueDate": "2019-11-29T17:00:00.000Z",
"UserId": "5dbd3fb1dd9f80375017fff9",
"createdAt": "2019-11-02T10:13:27.019Z",
"updatedAt": "2019-11-02T10:13:27.019Z",
"__v": 0
}
```


**List Tasks**
----

* **URL:** `/task/`

* **Method:** `GET`

* **Headers:** `access_token = [string]`

* **Success Response:**

* **Status:** 201
**Content:**

```
[
{
"_id": "5dbd504808bd83165a1263b0",
"title": "Angular",
"description": "",
"status": "Done",
"dueDate": null,
"UserId": "5dbd3fb1dd9f80375017fff9",
"createdAt": "2019-11-02T09:45:44.885Z",
"updatedAt": "2019-11-02T10:09:46.633Z",
"__v": 0
},
......
]
```


**Get Task's Detail**
----

* **URL:** `/task/:id`

* **Method:** `GET`

* **Headers:** `access_token = [string]`

* **Params:** `id = [string]`

* **Success Response:**

* **Status:** 200
**Content:**

```
[
{
"_id": "5dbd504808bd83165a1263b0",
"title": "Angular",
"description": "",
"status": "Done",
"dueDate": null,
"UserId": "5dbd3fb1dd9f80375017fff9",
"createdAt": "2019-11-02T09:45:44.885Z",
"updatedAt": "2019-11-02T10:09:46.633Z",
"__v": 0
},
......
]
```


**Update Task**
----

* **URL:** `/task/:id`

* **Method:** `PUT`

* **Headers:** `access_token = [string]`

* **Params:** `id = [string]`

* **Success Response:**

* **Status:** 200
**Content:**

```
[
{
"_id": "5dbd504808bd83165a1263b0",
"title": "Angular",
"description": "",
"status": "Done",
"dueDate": null,
"UserId": "5dbd3fb1dd9f80375017fff9",
"createdAt": "2019-11-02T09:45:44.885Z",
"updatedAt": "2019-11-02T10:09:46.633Z",
"__v": 0
},
......
]
```


**Undo Task**
----

* **URL:** `/task/:id`

* **Method:** `PATCH`

* **Headers:** `access_token = [string]`

* **Params:** `id = [string]`

* **Success Response:**

* **Status:** 200
**Content:**

```
{
"_id": "5dbeb98459a4341f896bb00f",
"title": "Belajar Javascript",
"description": "Hacktiv8",
"status": "Active",
"dueDate": "2019-11-30T00:00:00.000Z",
"UserId": "5dbeb5ed59a4341f896bb00d",
"createdAt": "2019-11-03T11:27:00.790Z",
"updatedAt": "2019-11-03T11:27:00.790Z",
"__v": 0
}
```


**Delete Task**
----

* **URL:** `/task/:id`

* **Method:** `DELETE`

* **Headers:** `access_token = [string]`

* **Params:** `id = [string]`

* **Success Response:**

* **Status:** 200
**Content:**

```
{
"n": 1,
"ok": 1,
"deletedCount": 1
}
```
Binary file added client/img/picture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading