RESTful API with ExpressJS
Build a simple RESTful API with ExpressJS.
Binar Challenge - Backend JavaScript - Chapter 4
This project is one of Challenge from Binar Academy Kampus Merdeka.
The challenge is to create a simple RESTful API with ExpressJS. The API must be able to do CRUD operation on User Game, User Game Biodata, and User Game History.
The API must also be able to do authentication using JWT.
Requirements
- Required Table
- User Game
- User Game Biodata
- User Game History
- Authentication Middleware
Features
- User Game CRUD
- User Game Biodata CRUD
- User Game History CRUD
- Authentication
Tech Stack
- NodeJS
- ExpressJS
- pg - PostgreSQL client for Node.js
- sequelize - ORM
- bcrypt - Password hashing
- jsonwebtoken - JWT Authentication
- dotenv - Environment variables
- joi - Validation schema
- joi-password-complexity - Password complexity validation
- morgan - HTTP request logger
- helmet - Security HTTP headers
- compression - HTTP compression
Prerequisites
- NodeJS
- PostgreSQL
- sequelize-cli - Sequelize command line interface, make sure you install it globally.
- nodemon - Nodemon will watch the files in the directory in which nodemon was started, and if any files change, nodemon will automatically restart your node application. Make sure you install it globally.
Installation and Usage
Clone the repository
1git clone https://github.com/raprmdn/binar-challenge.git
bash
Cd into the project directory
1cd binar-challenge/chapter4
bash
Install dependencies
1npm install
bash
Copy .env.example
to .env
1cp .env.example .env
bash
Configure the required environment variables in .env
file
Create database
1sequelize db:create
bash
Run migration
1sequelize db:migrate
bash
Run the development server
1npm run dev
bash
API Documentation
Documentation for this API can be found in Postman Collection Documentation or GitHub README.md.
Next Challenge
The next Challenge for Chapter 5 is create a Postman Collection Documentation for this API. Check it out here.