Comparing version 1.2.0 to 1.2.1
{ | ||
"name": "koa-gen", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "Koa' application generator for Koa v1.x and v2.x", | ||
@@ -5,0 +5,0 @@ "main": "bin/koa", |
@@ -49,2 +49,3 @@ # koa-generator | ||
-1, --koa1 use Koa v1.x (defaults to Koa v2.x) | ||
-b, --babel use babel for Koa v2.x | ||
-e, --ejs add ejs engine support (defaults to jade) | ||
@@ -51,0 +52,0 @@ --hbs add handlebars engine support |
@@ -13,3 +13,8 @@ const app = require('koa')() | ||
// global middlewares | ||
// middlewares | ||
app.use(require('koa-bodyparser')()) | ||
app.use(json()) | ||
app.use(log4js.koaLogger(log4js.getLogger('http'), { level: 'auto' })) | ||
// setup view | ||
app.use(views('views', { | ||
@@ -19,8 +24,7 @@ root: path.join(__dirname, 'views'), | ||
})) | ||
app.use(require('koa-bodyparser')()) | ||
app.use(json()) | ||
app.use(log4js.koaLogger(log4js.getLogger('http'), { level: 'auto' })) | ||
// handle error | ||
onerror(app) | ||
// logger | ||
app.use(function *(next) { | ||
@@ -41,3 +45,5 @@ var start = new Date() | ||
app.use(koa.routes()) | ||
.use(router.allowedMethods()) | ||
// log error | ||
app.on('error', function (err, ctx) { | ||
@@ -44,0 +50,0 @@ logger.error('server error', err, ctx) |
@@ -22,4 +22,6 @@ const Koa = require('koa') | ||
// handle error | ||
onerror(app) | ||
// setup view | ||
app.use(views(__dirname + '/views', { | ||
@@ -43,8 +45,11 @@ extension: '{views}' | ||
// routes definition | ||
router.use('/', index.routes(), index.allowedMethods()) | ||
router.use('/users', users.routes(), users.allowedMethods()) | ||
app.use(router.routes(), router.allowedMethods()) | ||
// response | ||
// mount root routes | ||
app.use(router.routes()) | ||
.use(router.allowedMethods()) | ||
// log error | ||
app.on('error', function (err, ctx) { | ||
@@ -51,0 +56,0 @@ logger.error(err) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33743
329
60