Skip to content

emilynakano/shining-back

Repository files navigation

33 SHINING SHINNING (1)

A memorization system based on the Ebbinghaus Deterioration Theory.

Technologies



👩‍🔧 Working Flow

  1. User creates a login (name, email, password).

  2. User logs in and receives a token.

  3. User can create a note, grab them all, get notes that need to be reviewed today, review notes, delete notes and edit notes.


🚀 Routes

User Registration

POST /sign-up

Send a request body in this format:

{
    name: 'fulana',
    email: 'fulana@gmail.com',
    password: '123456',
    confirmPassword: '123456'
}

Request:

body type description
name string valid name
email string valid email
password string at least 6 characters
confirmPassword string equal to password

Response:

code description
422 request body is invalid
409 email already registred
201 created

User Login

POST /sign-in

Send a request body in this format

{
    email: fulano@gmail.com,
    password: 123456
}

Request:

body type description
email string valid email
password string valid password

Response:

code description
422 request body is invalid
401 email doesn't exist or password doesn't match
200 ok, returns a token
{
    token: jyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9ASASASADL;;
}

Note Creation

POST /notes

Send a Authorization Header with format Bearer Token, and a Request Body in this format:

{
  "title": "How vaccines work",
  "content": "Vaccines differ from other medical drugs in two important ways..."
}

Request:

body type description
title string valid title
content string valid content

Response:

code description
422 request body is invalid
401 invalid or non-existent token
201 created

Note Edit

PATCH /notes/:id

Send a Authorization Header with format Bearer Token, param id and a Request Body in this format:

{
  "content": "Vaccines differ from other medical drugs in two important ways edited..."
}

Request:

body type description
content string valid content
param type description
id number valid note id

Response:

code description
422 request body is invalid
401 invalid or non-existent token
200 edited
400 param id is not a number
404 note not found

Note Review

PATCH /notes/:id/review

Send a Authorization Header with format Bearer Token and param id

Request:

param type description
id number id from note

Response:

code description
401 invalid or non-existent token
200 reviesed
400 param id is not a number
404 note id not found

Note Delete

DELETE /notes/:id

Send a Authorization Header with format Bearer Token and param id

Request:

param type description
id number id from note

Response:

code description
401 invalid or non-existent token
200 deleted
400 param id is not a number
404 note id not found

Get All User Notes

GET /notes

Send a Authorization Header with format Bearer Token.

Response:

code description
401 invalid or non-existent token
200 ok

If statusCode is 200, the server will respond with an array in this format:

[
  {
    "id": 1,
    "title": "How do vaccines Work",
    "content": "Vaccines differ from other medical drugs in two important ways...",
    "date: "10/10/2022"
    "progress": "0/4"
  }
]

Get Today Notes

GET /notes/today

Send a Authorization Header with format Bearer Token.

Response:

code description
401 invalid or non-existent token
200 ok

If statusCode is 200, the server will respond with an array in this format:

[
 {
    "id": 1,
    "title": "How do vaccines Work",
    "content": "Vaccines differ from other medical drugs in two important ways...",
 }
]

🏁 Running this project

Before starting, you will need to have the following tools installed on your machine: Docker.

Besides, it's good to have an editor to work with the code like VSCode.

	
# First, clone this repository.
$ git clone https://github.com/emilynakano/shining-back.git

# Acces this repository.
$ cd shining-back
	
# Go to the '.env.example' in your code editor.


ACCESS_TOKEN_SECRET="accesTokenScret"
REFRESH_TOKEN_SECRET="refreshTokenSecret"
	
# Put your DATABASE_URL, which must be a url. Like this: postgresql://user:password@localhost:5432/name
# Put your POSTGRES_USERNAME, which must be the username from your postgres.
# Put your POSTGRES_PASSWORD, which must be the password from your postgres.
# Put your POSTGRES_DB, which must be the name from your database.
# Put your ACCESS_TOKEN_SECRET, which must be a string.
# Put your REFRESH_TOKEN_SECRET, which must be a string.

# Finally, make a copy of '.env.example' to '.env'.
$ cp .env.example .env

# Install dependencies.
$ npm i -y
	
# Run the project in the development mode.
$ npm run dev	

	

About

Back end of a memorization program.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages