Project created to practice my studies about how create REST APIs.
Server: Node.js, Javascript, Express, MySQL, Sequelize
⚙️ Set the environment variables to the Sequelize communicate with the database server
DBUSER=
DBNAME=
DBPASS=
DBHOST= localhost
DBDIALECT= mysqlInstall all the dependecies:
npm install💡 Turn on the MySQL server
Create the database with the sequelize
npx sequelize db:createCreate the database table with the sequelize
npx sequelize db:migrateRun all the seeders to seed the database book table
npx sequelize db:seed:allAfter install all the dependecies, create the database, database table and run all the seeders, we can start the server
npm start/bookstore/api/v1 GET /bookstore/api/v1/books GET /bookstore/api/v1/books/{id}| Parameter | Type | Description |
|---|---|---|
id |
string |
Required. Id of item to fetch |
POST /bookstore/api/v1/books| Parameter | Type | Description |
|---|---|---|
title |
string |
Required |
total_pages |
integer |
Required |
author |
string |
Required |
release_year |
string |
Required |
stock |
integer |
Required |
PUT /bookstore/api/v1/books/{id}| Parameter | Type |
|---|---|
title |
string |
total_pages |
integer |
author |
string |
release_year |
string |
stock |
integer |
DELETE /bookstore/api/v1/books/{id}- 200: Ok
- 201: Created
- 400: Bad request
- 404: Not found
- 422: Unprocessable entity
- 500: Internal server error