/koa-api-boilerplate

KoaJS api boilerplate with generators to easly handle versionning & avoid boilerplate code

Primary LanguageHTMLMIT LicenseMIT

koa-api-boilerplate

KoaJS api boilerplate with generators to easly handle versionning & avoid boilerplate code

Content

Language and Preprocessor


Get started

Installation

  1. Clone project
    git clone https://github.com/nathanloisel/koa-api-boilerplate [PATH/TO/YOUR/PROJECT_NAME]
    
  2. Install dependencies
    npm install
    

Commands

  1. Run
  • development
    npm run dev
    
  • production with forever
    npm run prod
    
  1. Run tests

    npm run test
    
  2. Run generators

    npm run generate [generator-name](#list-of-generators)
    
  3. Generate api documentation

    npm run doc
    
  4. Populate Mongo

    npm run populate
    

What is inside


List of generators:

  1. Version npm run generate version
  2. Module npm run generate module
  3. Route npm run generate route
  4. Mongoose Model npm run generate model
  5. Authentication npm run generate auth

Backend Philosophy

Prerequisites:

Folder Hierarchy:

- src
    - config
        - db
            - index.js (babel wrapper)
            - populate.js
            - users.js
        - env
            - common.js
            - production.js
            - development.js
            - test.js
        - index.js
        - passport.js
    - middleware
        - documentation.js
        - index.js
        - uploads.js
        - validators.js
    - modules
        - v1
            - users
                - index.js
                - routes.js
                - validation.js
            - index.js
        - v2
            - users
                - index.js
                - routes.js
                - validation.js
            - object
                - index.js
                - routes.js
                - validation.js
            - index.js
    - models
        - users.js
        - objects.js
    - utils
        -auth.js
    -index.js (babel wrapper)
    -api.js
- test
    - v1
        -users.spec.js
    - v2
        -users.spec.js
        -object.spec.js
- package.json
- .eslintrc
- .babelrc
- .gitignore
- .gitattributes
- .editorconfig
- LICENSE
- README.md

TODO:

  • Improve generators (generate CRUD module for a model, ...)
  • Implement Facebook & Google authentication
  • Implement pre commit linting

Team