Skip to content

kevink1103/restapi_project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

78 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RESTful API Boilerplate

Build Status

A Production Grade RESTful API Boilerplate using Express.js, PostgreSQL and Redis as Caching.

  • Express.js
  • Sequelize
  • Docker Compose
  • PostgeSQL
  • Babel
  • Compression
  • Helmet
  • UUID
  • CRUD Separation
  • JWT
  • Unified Response
  • Redis
  • Jest
  • Supertest
  • Travis CI
  • Sentry
  • Slack

Getting Started

# Get the latest snapshot
git clone https://github.com/kevink1103/restapi_project.git

# Change directory
cd restapi_project/src

# Make sure to set env variables
cp example.env .env && vi .env

# Run PostgreSQL and Redis using Docker
docker-compose up

# Open a new bash to proceed

# Install sequelize-cli and nodemon globally
npm install -g sequelize-cli
npm install -g nodemon

# Install NPM dependencies
npm install --save-dev
# If this does not work
sudo npm install --save-dev --unsafe-perm=true --allow-root

# Create a database for testing
# Replace <DB_USER> and <DB_TEST> to your own in .env
docker exec -it restapi_postgres psql -U <DB_USER> -c "CREATE DATABASE <DB_TEST>;"

# Try testing - this should be successful!
npm test

# Migrate using Sequelize
sequelize db:migrate

# Then simply start your app
npm start

How to use (with Postman)

  1. Create a user
    POST request
    Body - x-www-form-urlencoded
    KEY:
    email
    password
127.0.0.1:3000/v1/users/
  1. Get specific user with UUID
    GET request
127.0.0.1:3000/v1/users/UUID_FROM_ABOVE_RESULT/
  1. Get all users
    GET request
127.0.0.1:3000/v1/users/
  1. Login
    POST request
    Body - x-www-form-urlencoded
    KEY:
    email
    password
127.0.0.1:3000/v1/auth/login/
  1. Test token
    GET request
    Authorization - Bearer Token
    Token: TOKEN_RECEIVED_FROM_ABOVE_RESULT
127.0.0.1:3000/v1/auth/tokenTest/
  1. Delete all users
    DELETE request
127.0.0.1:3000/v1/users/

You can start developing your server from here.
Integration with Sequelize, PostgreSQL and Redis is done for you.

Resources

https://medium.com/@final.lee

  1. 아하 REST API 서버 개발 (1)
  2. 아하 REST API 서버 개발 (2)
  3. 아하 REST API 서버 개발 (3)
  4. 아하 REST API 서버 개발 (4)
  5. 아하 REST API 서버 개발 (5)
  6. 아하 REST API 서버 개발 (6)
  7. 아하 REST API 서버 개발 (7)
  8. 아하 REST API 서버 개발 (8)
  9. 아하 REST API 서버 개발 (9)
  10. 아하 REST API 서버 개발 (10)
  11. 아하 REST API 서버 개발 (11)
  12. 아하 REST API 서버 개발 (12)
  13. 아하 REST API 서버 개발 (13)
  14. 아하 REST API 서버 개발 (14)

About

A Production Grade RESTful API Boilerplate.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published