https://github.com/gtcore902/p7-backend-nodejs-vieux-grimoire
The goal is to create the backend part of a book consultation website.
https://github.com/gtcore902/p7-backend-nodejs-vieux-grimoire
api-rest bcrypt-nodejs express-js express-middleware jsonwebtoken node-js
Last synced: 4 months ago
JSON representation
The goal is to create the backend part of a book consultation website.
- Host: GitHub
- URL: https://github.com/gtcore902/p7-backend-nodejs-vieux-grimoire
- Owner: gtcore902
- Created: 2024-02-29T08:21:54.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-09T20:33:17.000Z (7 months ago)
- Last Synced: 2025-01-01T17:18:45.654Z (6 months ago)
- Topics: api-rest, bcrypt-nodejs, express-js, express-middleware, jsonwebtoken, node-js
- Language: JavaScript
- Homepage:
- Size: 85.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# P7-backend-nodejs-vieux-grimoire
## OpenClassrooms Web Developer Path Project
This project is part of the [OpenClassrooms](https://www.openclassrooms.com/) Web Developer Path.
## :checkered_flag:Objective
The goal is to create the backend part of a book consultation website :books:.
## :computer:Technologies Used
- [Node.js](https://nodejs.org/en/)
- [Express](https://expressjs.com/)
- [JsonWebTokens](https://jwt.io/)
- [Bcrypt](https://www.bcrypt.fr/)## :smiley:Functional Specifications
### Context
The "Au Vieux Grimoire" libraries have numerous passionate customers. The objective of the "Mon Vieux Grimoire" site is to allow readers to create books, rate them, and consult existing books along with their ratings.
### General Architecture
The web application will consist of 4 pages:
- A page to allow user registration/login;
- A homepage displaying books already added by users (visible whether logged in or not);
- A "book" page displaying all information about a proposed book (visible whether logged in or not);
- A page allowing users to add new books to the platform (visible only to logged-in users).### Additional Information
#### Connection/Registration Page
This page is quite simple; it must contain:
- Two input fields: an "email" field and a "password" field;
- Two buttons: a "registration" button and a "login" button.This page contains nothing else, not even the header or footer.
#### Header
In the header, we should find the company logo and a menu.
This menu should present the following links:- "Home": directs to the homepage;
- "Create a Book": directs to the book creation page;
- "Logout": this should allow the user to log out from the platform, before being redirected to the connection/registration page.We will find the header on all pages, except the connection/registration page.
#### Footer
In the footer, we should find the address, phone number, a visual of a map, and the copyright.
We will find the footer on all pages, except the connection/registration page.#### :house:Homepage
The homepage should present the list of all books added by users. This page is visible to all visitors, whether they are logged in or not.
For each book, the image and title should appear.
In the first version of the platform, there will be no pagination.#### :books:Book Page
In this page, we will find all the information related to a book, i.e., image, title, author, year, genre, and average rating.
The average rating is a 5-star evaluation.
A user should be able to provide a rating, between 0 and 5 stars.
Special Case: If the user viewing a book is the creator of that book on the platform, this user will have 2 additional buttons available, one button to delete the book, and another to edit it.#### :pencil:Book Creation Page
In this page, users will have the possibility to create a book by providing all the necessary information, i.e., image (upload field for an image), title, author, year, and genre.
A validation/creation button will confirm the creation of the book once all the information is entered.## :wrench:API Technical Specifications
This table details the requirements of the API required for the proper functioning of the frontend.
### API Specification
| Endpoint | Authentication | Request Body (if applicable) | Expected Response | Function |
| ------------------------- | -------------- | ----------------------------------- | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| POST /api/auth/signup | Not required | { email: string, password: string } | { message: string } | Hashes the user's password, adds the user to the database. |
| POST /api/auth/login | Not required | { email: string, password: string } | { userId: string, token: string } | Verifies user's login credentials; returns the user's \_id from the database and a signed JSON web token (also containing the user's \_id). |
| GET /api/books | Not required | - | Array of books | Returns an array of all books from the database. |
| GET /api/books/:id | Not required | - | Single book | Returns the book with the provided \_id. |
| GET /api/books/bestrating | Not required | - | Array of books | Returns an array of the top 3 books from the database with the highest average rating. |
| POST /api/books | Required | { book: string, image: file } | { message: string } | Captures and saves the image, processes the book turned into a string, and saves it in the database setting its ImageUrl correctly. |### Installation and Running
Read the instructions for launching and installing [the frontend code](https://github.com/OpenClassrooms-Student-Center/P7-Dev-Web-livres).
The frontend runs on port 3000.
Then:
```
npm install
npm start
```The backend runs on port 4000.
## Contributing :
_No contribution needed but you can use this repository._
_[How to use Git?](https://docs.github.com/fr/get-started/using-git/about-git)_
## Contact :
[](https://github.com/gtcore902)
[](https://linkedin.com/in/ga%C3%ABtan-tremois-a956a91a3)