Merge pull request #12 from adrianObel/2.2.0

2.2.0
This commit is contained in:
Adrian Obelmejias
2016-08-30 17:27:19 -04:00
committed by GitHub
12 changed files with 38 additions and 42 deletions
+1 -11
View File
@@ -1,16 +1,6 @@
{
"parser": "babel-eslint",
"extends": "airbnb",
"plugins": [
"react"
],
"rules": {
"semi": [2, "never"],
"no-param-reassign": [2, { "props": false }],
"strict": 0,
"comma-dangle": [2, "never"],
"max-len": [2, 80, 2, { "ignoreComments": true }]
},
"extends": "standard",
"env": {
"node": true,
"mocha": true
+6 -3
View File
@@ -1,11 +1,14 @@
#koa2-api-boilerplate
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com)
Boilerplate for building APIs with [koa2](https://github.com/koajs/koa/tree/v2.x) and mongodb.
This project covers basic necessities of most APIs.
* Authentication (passport & jwt)
* Database (mongoose)
* Testing (mocha)
* Doc generation with jsondoc
* Doc generation with apidoc
* linting using standard
##Requirements
* node __^4.0.0__
@@ -27,7 +30,7 @@ git clone https://github.com/adrianObel/koa2-api-boilerplate.git
* [Passport](http://passportjs.org/)
* [Nodemon](http://nodemon.io/)
* [Mocha](https://mochajs.org/)
* [jsondoc](http://apidocjs.com/)
* [apidoc](http://apidocjs.com/)
* [Babel](https://github.com/babel/babel)
* [ESLint](http://eslint.org/)
@@ -60,7 +63,7 @@ git clone https://github.com/adrianObel/koa2-api-boilerplate.git
* `npm test` Run mocha tests
##Documentation
API documentation is written inline and generated by [jsondoc](http://apidocjs.com/).
API documentation is written inline and generated by [apidoc](http://apidocjs.com/).
Visit `http://localhost:5000/docs/` to view docs
+1
View File
@@ -14,6 +14,7 @@ import { errorMiddleware } from '../src/middleware'
const app = new Koa()
app.keys = [config.session]
mongoose.Promise = global.Promise
mongoose.connect(config.database)
app.use(convert(logger()))
+12 -10
View File
@@ -1,6 +1,6 @@
{
"name": "koa2-api-boilerplate",
"version": "2.1.2",
"version": "2.2.0",
"description": "Koa2 boilerplate covering essentials for APIs",
"main": "index.js",
"scripts": {
@@ -18,7 +18,8 @@
"boilerplate",
"es6",
"mongoose",
"passportjs"
"passportjs",
"apidoc"
],
"author": "Adrian Obelmejias <adrian@obel.me>",
"license": "MIT",
@@ -31,14 +32,15 @@
"url": "https://github.com/adrianObel/koa2-api-boilerplate"
},
"dependencies": {
"apidoc": "^0.16.1",
"babel-core": "^6.5.1",
"babel-polyfill": "^6.5.0",
"babel-preset-es2015-node5": "^1.2.0",
"babel-preset-stage-0": "^6.5.0",
"bcrypt": "^0.8.5",
"glob": "^7.0.0",
"jsonwebtoken": "^5.5.4",
"koa": "^2.0.0-alpha.3",
"jsonwebtoken": "^7.1.9",
"koa": "^2.0.0-alpha.6",
"koa-bodyparser": "^3.0.0",
"koa-convert": "^1.2.0",
"koa-generic-session": "^1.10.1",
@@ -51,15 +53,15 @@
"passport-local": "^1.0.0"
},
"devDependencies": {
"apidoc": "^0.15.1",
"babel-eslint": "^6.0.2",
"babel-register": "^6.5.1",
"chai": "^3.5.0",
"eslint": "^2.8.0",
"eslint-config-airbnb": "^7.0.0",
"eslint-plugin-react": "^4.3.0",
"mocha": "^2.4.5",
"eslint": "^3.4.0",
"eslint-config-standard": "^6.0.0",
"eslint-plugin-promise": "^2.0.1",
"eslint-plugin-standard": "^2.0.0",
"mocha": "^3.0.2",
"nodemon": "^1.8.1",
"supertest": "^1.2.0"
"supertest": "^2.0.0"
}
}
+2 -2
View File
@@ -17,8 +17,8 @@ export async function ensureUser(ctx, next) {
ctx.throw(401)
}
const user = await User.findById(decoded.id, '-password')
if (!user) {
ctx.state.user = await User.findById(decoded.id, '-password')
if (!ctx.state.user) {
ctx.throw(401)
}
+1 -1
View File
@@ -134,7 +134,7 @@ export async function getUser(ctx, next) {
ctx.throw(500)
}
if(next) return next()
if (next) { return next() }
}
/**