improve error handling with koa-json-error
Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
cc7018a314
commit
6f59c0cda1
|
@ -12,6 +12,7 @@
|
|||
"koa-bodyparser": "^4.2.1",
|
||||
"koa-joi-router": "^5.1.0",
|
||||
"koa-json": "^2.0.2",
|
||||
"koa-json-error": "^3.1.2",
|
||||
"koa-logger": "^3.2.0",
|
||||
"lokijs": "^1.5.5",
|
||||
"nunjucks": "^3.1.4"
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import Koa from 'koa'
|
||||
import JSON from 'koa-json'
|
||||
import JsonError from 'koa-json-error'
|
||||
import JoiRouter from 'koa-joi-router'
|
||||
import BodyParser from 'koa-bodyparser'
|
||||
|
||||
|
@ -7,9 +8,10 @@ const App = (ghc) => {
|
|||
const app = new Koa()
|
||||
const router = new JoiRouter()
|
||||
|
||||
app.use(router.middleware())
|
||||
app.use(JSON({pretty: true}))
|
||||
.use(JsonError())
|
||||
.use(router.middleware())
|
||||
.use(BodyParser({onerror:console.error}))
|
||||
.use(JSON({pretty: true}))
|
||||
|
||||
app.on('error', (err, ctx) => {
|
||||
console.error('server error', err, ctx)
|
||||
|
|
Loading…
Reference in New Issue