Skip to content

felp-gomes/back-end-bookadinho

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bookadinho

A website aimed at sharing books and democratizing reading.

Summary

  1. About project
  2. Main technologies used in the project
  3. Endpoints
    1. Route /profiles
      1. POST /profile/authorization
      2. GET /profiles
      3. GET /profile/:id
      4. POST /profile
      5. PUT /profile
      6. DELETE /profile
      7. PUT /profile/password
    2. Route /books
      1. GET /books
      2. GET /book/:id
      3. POST /book
      4. PATCH /book/read/:id
      5. PATCH /book/change/:id
      6. DELETE /book/:id
  4. Final considerations

About project

This project is divided into two repositories, the back-end, the one you're looking at, and the front-end, which can be accessed by clicking on the link: front-end-bookadinho.

OBS:

  • The application is for academic and disciplinary purposes, so there will be constant changes to the structure, coding and dependencies of the project.
  • It's in mock-up form, i.e. it doesn't have a database yet.
  • Any user or book registration is not permanent.

Main technologies used in the project:

  • Node.js
  • Express.js
  • TypeScript
  • JSONWebToken

Endpoints:

The routes are /books and /profiles, both of which have create, query, update and delete (CRUD) routes.

Route /profiles

POST /profile/authorization

  • In order to query, update or delete a profile or book, you must have a token.
  • This token is returned when the user and password have been validated.

Value Required Note Data type
user_name Yes Informed on the body String
password Yes Informed on the body String
  curl --request POST \
    --url https://bookadinho-api.onrender.com/profile/authorization \
    --header 'Content-Type: application/json' \
    --data '{
      "user_name": "<user_name>",
      "password": "<password>"
    }'

GET /profiles

  • It will return all the registered profiles.

Value Required Note Data type
Token Yes Informed in the header String
  curl --request GET \
    --url https://bookadinho-api.onrender.com/profiles \
    --header 'Authorization: <token>'

GET /profile/:id

  • It will return the profile registered with the id entered.

Value Required Note Data type
Id Yes Informed on the route Number
Token Yes Informed in the header String
  curl --request GET \
    --url https://bookadinho-api.onrender.com/profile/:id \
    --header 'Authorization: <token>'

POST /profile

  • It will create a new profile.

Value Required Note Data type
user_name Yes Informed on the body String
name Yes Informed on the body String
password Yes Informed on the body String
email Yes Informed on the body String
description No Informed on the body String
likes No Informed on the body Array['Like1', 'Like2', ...]
latest_readings No Informed on the body Array['Like1', 'Like2', ...]
photo No Informed on the body String
  curl --request POST \
    --url https://bookadinho-api.onrender.com/profile \
    --header 'Content-Type: application/json' \
    --data '{
      "user_name": "<user_name>",
      "name": "<name>",
      "password": "<password>",
      "email": "<email>"
    }'

PUT /profile

  • It will update some information in the logged-in profile.

Value Required Note Data type
Token Yes Informed in the header String
User_name Yes Informed on the body String
Name Yes Informed on the body String
Password Yes Informed on the body String
Email Yes Informed on the body String
Description No Informed on the body String
Likes No Informed on the body Array['Like1', 'Like2', ...]
Latest_readings No Informed on the body Array['Like1', 'Like2', ...]
Photo No Informed on the body String
  curl --request PUT \
    --url https://bookadinho-api.onrender.com/profile \
    --header 'Authorization: <token>' \
    --header 'Content-Type: application/json' \
    --data '{
      "user_name": "<user_name>",
      "name": "<name>",
      "password": "<password>",
      "email": "<email>"
    }'

DELETE /profile

  • Will delete the logged-in user's profile.

Value Required Note Data type
Token Yes Informed in the header String
  curl --request DELETE \
    --url https://bookadinho-api.onrender.com/profile \
    --header 'Authorization: <toke>'

PUT /profile/password

  • It will update the password of the logged-in user.

Value Required Note Data type
Token Yes Informed in the header String
Password Yes Informed on the body String
  curl --request PUT \
    --url https://bookadinho-api.onrender.com/profile/password \
    --header 'Authorization: <token>' \
    --header 'Content-Type: application/json' \
    --data '{
      "password": "<password>"
    }'

Route /books

GET /books

  • It will return all the books registered.
curl --request GET \
  --url https://bookadinho-api.onrender.com/books

GET /book/:id

  • It will return the book registered with the id entered.

Value Required Note Data type
Id Yes Informed on the route Number
  curl --request GET \
    --url https://bookadinho-api.onrender.com/book/:id

POST /book

  • It will create a new book.

Value Required Note Data type
Token Yes Informed in the header String
Title Yes Informed on the body String
Author Yes Informed on the body String
Description Yes Informed on the body String
Is_read Yes Informed on the body Boolean
Photo No Informed on the body String
  curl --request POST \
    --url https://bookadinho-api.onrender.com/book \
    --header 'Authorization: <token>' \
    --header 'Content-Type: application/json' \
    --data '{
      "name": "<name>",
      "author": "<author>",
      "description": "<description>",
      "photo": "<photo>",
      "is_read": <is_read>
    }'

PATCH /book/read/:id

  • It will update the book's reading status.

Value Required Note Data type
Token Yes Informed in the header String
Id Yes Informed on the route Number
  curl --request PATCH \
  --url https://bookadinho-api.onrender.com/book/read/:id \
  --header 'Authorization: <token>' \

PATCH /book/change/:id

  • It will update the book's exchange status.

Value Required Note Data type
Token Yes Informed in the header String
Id Yes Informed on the route Number
  curl --request PATCH \
  --url https://bookadinho-api.onrender.com/book/read/:id \
  --header 'Authorization: <token>' \

DELETE /book/:id

  • It will delete the book with the id entered.

Value Required Note Data type
Token Yes Informed in the header String
Id Yes Informed on the route Number
  curl --request DELETE \
    --url https://bookadinho-api.onrender.com/book/:id \
    --header 'Authorization: <token>' \

Final considerations:

"Work around we accept, what we don't accept is defeat" - My clan

About

No description or website provided.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published