Giter VIP home page Giter VIP logo

koach-sql's Introduction

KOACH

KOACH

Production ready boilerplate for building APIs with koa2, sequelize and http/2 as the communication protocol.

Description

This project covers basic necessities of most APIs.

  • Authentication (passport & jwt)
  • Database (SQL)
  • Testing (mocha)
  • http/2 support for websites and apis
  • Doc generation with apidoc
  • linting using standard
  • Contains two versions of API

Please note, if you are planning to use this boilerplate for creating a web application then the 'https' protocol should be used to access its pages.

Visit https://localhost:3000/ to access the root page.

Requirements

  • node = v10.15.3
  • SQL Database

Installation

git clone https://github.com/SystangoTechnologies/Koach-SQL.git

Features

Structure

├── bin
│   └── server.js                   # Bootstrapping and entry point
├── cert
│   ├── server.cert                 # SSL certificate
│   └── server.key                  # SSL certificate key
├── config                          # Server configuration settings
│   ├── env                         # Environment specific config
│   │   ├── common.js
│   │   ├── development.js
│   │   ├── production.js
│   │   └── test.js
│   ├── index.js                    # Config entrypoint
│   └── passport.js                 # Passportjs config of strategies
├── src                             # Source code
│   ├── modules                     # Module-specific controllers
│   │    ├── common                 # Contains common modules
│   │    │   ├─── home              
│   │    │   └─ index.js
│   │    ├── v1                     # Version 1 of APIs
│   │    │   ├─ Auth
│   │    │   ├─ User   
│   │    │   └─ index.js            
│   │    └─── v2                    # Version 2 of APIs
│   │         ├─ Auth
│   │         ├─ User   
│   │         └─ index.js
│   ├── models                      # Sequelize models
│   │   ├── index.js                # Creates connection from database and load model
│   │   └── user.js                 # User model
    ├── requestModel
|   |   ├── v1
|   |   |  ├── auth.js
|   |   |  └── users.js
|   |   └── v2
|   |       ├── auth.js
|   |       └── users.js
|   ├── responseModel
|   |   ├── v1
|   |   |  ├── auth.js
|   |   |  └── users.js
|   |   └── v2
|   |       ├── auth.js
|   |       └── users.js
│   └── middleware                  # Custom middleware
│       └── validators              # Validation middleware
└── test                            # Unit tests
└── pm2.config.js                   # PM2 configuration file
└── Dockerfile                      # Docker file
└── docker-compose.yml              # Docker Compose file

Usage

  • npm start Start server on development mode with Nodemon
  • npm run prod Start server on production mode with PM2
  • npm run docs Generate API documentation
  • npm test Run mocha tests

Running the server in Docker Container

Prerequisite For Docker Configuration : Docker and docker compose must be installed on the system.

Steps to run app in docker container :

  1. CD to project dir
  2. Create build using cmd: $ docker-compose build
  3. Start the server in daemon thread using cmd: $ docker-compose up -d
  4. Stop the server using cmd : $ docker-compose down

Database

And one of the following databases with Sequelize:
  • npm install --save pg pg-hstore
  • npm install --save mysql2
  • npm install --save sqlite3
  • npm install --save tedious

Environment Variables

  • NODE_ENV
  • PORT
  • SESSION
  • TOKEN
  • DATABASE
  • DB_USERNAME
  • DB_PASSWORD
  • DB_HOST
  • DB_DBPORT
  • DB_DIALECT

Documentation

API documentation is written inline and generated by apidoc.

Visit https://localhost:3000/docs/ to view docs

To view swagger API documentation

Visit https://localhost:3000/swagger to view Swagger UI.

Performance Comparison

The environment for the test caes are following-

  • Node Version: 8.9.4
  • Number of Users: 1500
  • Ramp-up Period: 300 seconds
  • Loop Count: 100

Average Throughput

Contributors

Arpit Khandelwal Anurag Vikram Singh Vikas Patidar

License

MIT.

koach-sql's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

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.