update
This commit is contained in:
parent
2247b18cda
commit
c072d18c36
@ -3,19 +3,23 @@ const koaBody = require('koa-body')
|
|||||||
const {
|
const {
|
||||||
chkObject
|
chkObject
|
||||||
} = require('@libs/route-utils')
|
} = require('@libs/route-utils')
|
||||||
|
const DB = require('@libs/database')
|
||||||
const r = new Router()
|
const r = new Router()
|
||||||
|
|
||||||
r.use(async (c, n) => {
|
r.use(async (c, n) => {
|
||||||
c.obj = {}
|
c.obj = {}
|
||||||
|
c.db = await DB.connect()
|
||||||
c.chkBody = chkObject.bind({body: c.request.body})
|
c.chkBody = chkObject.bind({body: c.request.body})
|
||||||
try {
|
try {
|
||||||
await n()
|
await n()
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err)
|
console.log(err)
|
||||||
}
|
}
|
||||||
|
c.db.release()
|
||||||
})
|
})
|
||||||
|
|
||||||
r.post('/login', koaBody(), async (c, n) => {
|
r.post('/login', koaBody(), async (c, n) => {
|
||||||
|
if (!c.chkBody('account', 'string') || !c.chkBody('password', 'string')) throw new Error('DataFormat')
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user