A Collection Of Books API Using NodeJS MySQL ExpressJS
-
Clone repository
$ git clone https://github.com/wahyufahrozi/Backend
-
Install depedencies
# with npm
$ npm install
# or with yarn
$ yarn install
- Setup your environment variable in
.env
files (if not exists, create your own).
DB_HOST = 'localhost'
DB_USER = 'root'
DB_PASSWORD = 'xxx'
DB_DATABASE = 'databasename'
- Start API server
$ npm run server
- NodeJS
- MySQL
- ExpressJS
- expressjs - The server for handling and routing HTTP requests
- morgan - a HTTP request logger middleware for Node.js. It simplifies the process of logging requests to your application
- dotenv - is a zero-dependency module that loads environment variables from a
.env
file intoprocess.env
- mysql - NodeJs driver for MySQL
- body-parser - Node.js body parsing middleware
- nodemon - is a tool that helps develop node.js based applications by automatically restarting the node application when file changes in the directory are detected.
index.js
- Entry point of our aplicationsrc/Config
- This folder contain configuration files of our app, such as mysql connectionsrc/Models
- This folder containt files that define query of MysQLsrc/Routes
- Route of our app going heresrc/Helpers
- This folder contain file that help you simplify your code such as define the error handlingsrc/Controllers
- This folder contain configuration files that links Models to Route
Method | Endpoint | Description | Request Param | Request Body | Request Query |
---|---|---|---|---|---|
GET | /api/library | Get Books | - | - | title :STRING author :STRING genre : INTEGER status :INTEGER |
POST | /api/library | Add New Books | - | title :STRING (Required) author :STRING (Required)status :STRING (Required) genre :STRING (Required) |
- |
PUT | api/library/edit/:id_books | Edit Books By ID | id : INT (UUID) |
title :STRING (Required) author :STRING (Required) status :STRING (Required) genre :STRING (Required) |
- |
DELETE | api/library/delete/:id_books | Delete Books | - | id :INT |
- |
Method | Endpoint | Description | Request Param | Request Body | Request Query |
---|---|---|---|---|---|
GET | /api/library/genre | Get All Genres | - | - | - |
POST | /api/genre | Add New Genre | - | genre :STRING (Required) |
- |
Copyright © 2019 by Wahyu Fahrozi Rezeki Ramadhan (Wahyu Fahrozi Rezeki Ramadhan)