koa-api-boilerplate
KoaJS api boilerplate with generators to easly handle versionning & avoid boilerplate code
Content
Language and Preprocessor
Get started
Installation
- Clone project
git clone https://github.com/nathanloisel/koa-api-boilerplate [PATH/TO/YOUR/PROJECT_NAME]
- Install dependencies
npm install
Commands
- Run
- development
npm run dev
- production with forever
npm run prod
-
Run tests
npm run test
-
Run generators
npm run generate [generator-name](#list-of-generators)
-
Generate api documentation
npm run doc
-
Populate Mongo
npm run populate
What is inside
- Api documentation with apidoc
- Api versionning
- MongoDB with [mongoose] (http://mongoosejs.com/)
- User Authentication with passport (local, facebook, google, twitter)
- File upload management
- Endpoint parameters/files/query validation with koa-validation
- Test with supertest
- Generators based on plop
List of generators:
- Version
npm run generate version
- Module
npm run generate module
- Route
npm run generate route
- Mongoose Model
npm run generate model
- 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