Merge branch 'master' into release
This commit is contained in:
commit
dc4cde886f
@ -16,12 +16,24 @@ r.use(async (c, n) => {
|
||||
c.obj = {}
|
||||
c.db = await DB.connect()
|
||||
c.chkBody = chkObject.bind(c.request)
|
||||
|
||||
let obj = null
|
||||
try {
|
||||
await n()
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
c.obj = resObject(err instanceof APIError ? err.resKey : 'InternalError', err.apiMsg || null, err.msgCode || null)
|
||||
obj = resObject(err instanceof APIError ? err.resKey : 'InternalError', err.apiMsg || null, err.msgCode || null)
|
||||
}
|
||||
|
||||
if (Object.keys(c.obj).length > 0 && 'status' in c.obj && 'obj' in c.obj) {
|
||||
c.status = c.obj.status
|
||||
c.body = c.obj.obj
|
||||
}
|
||||
if (obj !== null) {
|
||||
c.status = obj.status
|
||||
c.body = obj.obj
|
||||
}
|
||||
|
||||
c.db.release()
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user