📚Book My Novel API

A Collection Of Novels API Using NodeJS MySQL ExpressJS

David

Table Of Contents

Build Setup

  1. Clone repository $ git clone https://github.com/iyansr/book-my-novel-API.git

  2. Install depedencies

# with npm
$ npm install

# or with yarn
$ yarn install
  1. Setup your environment variable in .env files (if not exists, create your own).
CLOUDINARY_CLOUD_NAME = 
CLOUDINARY_API_KEY = 
CLOUDINARY_API_SECRET = 
JWT_SECRET = 

DB_NAME = 
DB_USER = 
DB_PASSWORD = 
DB_HOST = 
DB_PORT = 
  1. Start API server
$ npm run server

Stacks

  • NodeJS
  • MySQL
  • ExpressJS

Dependencies

  • 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 into process.env
  • momentjs - To convert dateTime from javascript format to mysql format easily
  • 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.

Aplication Structure

  • app.js - Entry point of our aplication
  • src/Config - This folder contain configuration files of our app, such as mysql connection
  • src/Models - This folder containt files that define query of MysQL
  • src/Routes - Route of our app going here
  • src/Helpers - This folder contain file that help you simplify your code such as define the error handling
  • src/Controllers - This folder contain configuration files that links Models to Route

API Docs

Novel

Method Endpoint Description Request Param Request Body Request Query
GET /api/novel Get Novels - - title:STRING author:STRING genre: INTEGER status:INTEGER
POST /api/novel Add New Novel - title:STRING (Required) author:STRING (Required) image_url:STRING status:STRING (Required) genre:STRING (Required) -
PUT api/novel/:id Edit Novel By ID id: INT (UUID) title:STRING (Required) author:STRING (Required) image_url:STRING status:STRING (Required) genre:STRING (Required) -
DELETE api/novel Delete Novel - id:INT -

Genre

Method Endpoint Description Request Param Request Body Request Query
GET /api/genre Get All Genres - - -
POST /api/genre Add New Genre - genre:STRING (Required) -

Copyright © 2019 by I Putu Saputrayana (Iyan Saputra)