From c072d18c36297182a384720c91752ea05856e10e Mon Sep 17 00:00:00 2001 From: Jay Date: Tue, 14 Aug 2018 17:30:27 +0800 Subject: [PATCH] update --- route/api/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/route/api/index.js b/route/api/index.js index b202c17..f8c14da 100644 --- a/route/api/index.js +++ b/route/api/index.js @@ -3,20 +3,24 @@ const koaBody = require('koa-body') const { chkObject } = require('@libs/route-utils') +const DB = require('@libs/database') const r = new Router() r.use(async (c, n) => { c.obj = {} + c.db = await DB.connect() c.chkBody = chkObject.bind({body: c.request.body}) try { await n() } catch (err) { console.log(err) } + c.db.release() }) r.post('/login', koaBody(), async (c, n) => { - + if (!c.chkBody('account', 'string') || !c.chkBody('password', 'string')) throw new Error('DataFormat') + }) module.exports = r