Files
ipfs-bch-wallet-consumer/README.md
T

113 lines
4.3 KiB
Markdown
Raw Normal View History

2019-02-10 16:46:49 -08:00
# koa-api-boilerplate
2019-05-17 08:17:43 -07:00
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com) [![Coverage Status](https://coveralls.io/repos/github/christroutner/babel-free-koa2-api-boilerplate/badge.svg?branch=unstable)](https://coveralls.io/github/christroutner/babel-free-koa2-api-boilerplate?branch=unstable) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) [![Greenkeeper badge](https://badges.greenkeeper.io/christroutner/koa-api-boilerplate.svg)](https://greenkeeper.io/)
2016-08-30 16:58:35 -04:00
2018-11-07 20:37:45 -08:00
2019-02-10 16:46:49 -08:00
This repository is a boilerplate for building APIs with
[koa2](https://github.com/koajs/koa/tree/v2.x) and Mongo DB.
This repository was originally forked from Adrian Obelmejias'
[koa-api-boilerplate repository](https://github.com/adrianObel/koa2-api-boilerplate).
2018-10-16 11:10:23 -07:00
It makes the following modifications:
2016-02-17 19:15:43 -05:00
2019-02-10 16:46:49 -08:00
- Removes babel as a dependency. This repository is now naively compatible with
2018-10-16 11:10:23 -07:00
node v8.9 or higher.
2018-03-05 19:40:50 -08:00
2018-10-16 11:10:23 -07:00
- Replaced `bcrypt` dependency with `bcryptjs`. This improves compatibility across
versions of node.js and across OSs.
2019-02-10 16:46:49 -08:00
- Configured for Travis CI (continuous integration), Coveralls (code coverage), Green Keeper (automated dependency management), and Semantic Release (automated versioning).
2018-11-07 21:09:55 -08:00
- 'Production' environment is targeted for packaging as a Docker container.
2019-05-17 08:17:43 -07:00
- 'admin' user type added in addition to standard 'user' type. Allows the creation
of private vs public APIs that only be accessed by an admin. Useful for privileged
commands like updating and deleting other users.
2019-05-20 20:58:33 -07:00
- Winston logging integrated for daily rotated logs and a maximum size of
1 megabyte.
2018-10-16 11:10:23 -07:00
## Features
2016-02-17 19:15:43 -05:00
This project covers basic necessities of most APIs.
* Authentication (passport & jwt)
* Database (mongoose)
* Testing (mocha)
2016-08-30 15:27:07 -04:00
* Doc generation with apidoc
* Linting using standard
* Packaged as a Docker container
2016-02-17 19:15:43 -05:00
2018-10-16 11:10:23 -07:00
2018-03-05 19:43:00 -08:00
## Requirements
* node __^10.15.1__
* npm __^6.7.0__
2016-02-17 19:15:43 -05:00
2018-03-05 19:43:00 -08:00
## Installation
2016-02-17 19:15:43 -05:00
```bash
2019-02-10 16:46:49 -08:00
git clone https://github.com/christroutner/koa-api-boilerplate
2019-09-29 17:22:06 -07:00
cd koa-api-boilerplate
npm install
npm start
2016-02-17 19:15:43 -05:00
```
2018-03-05 19:43:00 -08:00
## Structure
2016-02-17 19:15:43 -05:00
```
2016-03-04 23:58:22 -05:00
├── bin
│ └── server.js # Bootstrapping and entry point
2016-02-17 19:15:43 -05:00
├── config # Server configuration settings
2016-03-04 23:58:22 -05:00
│ ├── env # Environment specific config
│ │ ├── common.js
│ │ ├── development.js
│ │ ├── production.js
│ │ └── test.js
│ ├── index.js # Config entrypoint - exports config according to envionrment and commons
2016-02-17 19:15:43 -05:00
│ └── passport.js # Passportjs config of strategies
2019-02-08 16:47:06 -08:00
|
├── production # Dockerfile for build production container
|
2016-02-17 19:15:43 -05:00
├── src # Source code
2019-05-17 08:17:43 -07:00
│ ├── lib # Business logic libraries
2016-03-19 11:39:21 -04:00
│ ├── modules
│ │ ├── controller.js # Module-specific controllers
│ │ └── router.js # Router definitions for module
2016-02-17 19:15:43 -05:00
│ ├── models # Mongoose models
│ └── middleware # Custom middleware
│ └── validators # Validation middleware
└── test # Unit tests
```
2018-03-05 19:43:00 -08:00
## Usage
2016-02-17 19:15:43 -05:00
* `npm start` Start server on live mode
* `npm run dev` Start server on dev mode with nodemon
2016-03-04 23:58:22 -05:00
* `npm run docs` Generate API documentation
2016-02-17 19:15:43 -05:00
* `npm test` Run mocha tests
* `docker-compose build` Build a 'production' Docker container
* `docker-compose up` Run the docker container
2016-02-17 19:15:43 -05:00
2018-03-05 19:43:00 -08:00
## Documentation
2016-08-30 15:27:07 -04:00
API documentation is written inline and generated by [apidoc](http://apidocjs.com/).
2016-03-04 23:58:22 -05:00
Visit `http://localhost:5000/docs/` to view docs
2018-10-16 11:10:23 -07:00
## Dependencies
* [koa2](https://github.com/koajs/koa/tree/v2.x)
* [koa-router](https://github.com/alexmingoia/koa-router)
* [koa-bodyparser](https://github.com/koajs/bodyparser)
* [koa-generic-session](https://github.com/koajs/generic-session)
* [koa-logger](https://github.com/koajs/logger)
* [MongoDB](http://mongodb.org/)
* [Mongoose](http://mongoosejs.com/)
* [Passport](http://passportjs.org/)
* [Nodemon](http://nodemon.io/)
* [Mocha](https://mochajs.org/)
* [apidoc](http://apidocjs.com/)
* [ESLint](http://eslint.org/)
## IPFS
v2.3.0 uploaded to IPFS:
2019-05-19 20:19:19 -07:00
- Get it: `ipfs get QmUz4b2KwNLNvHZRTYcgrPCuKAhMB73XWN8vY8LLVVEYV1`
- Pin it: `ipfs pin add -r QmUz4b2KwNLNvHZRTYcgrPCuKAhMB73XWN8vY8LLVVEYV1`
2018-03-05 19:43:00 -08:00
## License
2016-02-17 19:15:43 -05:00
MIT