Coder Social home page Coder Social logo

restapi_project's Introduction

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)

restapi_project's People

Contributors

kevink1103 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

wowplus2

restapi_project's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.