move error handler to before middlewares

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2018-12-13 22:21:54 +01:00
parent f10c1caf70
commit 8846e1e206
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
1 changed files with 5 additions and 5 deletions

View File

@ -9,16 +9,16 @@ const App = (ghc) => {
const app = new Koa()
const router = new JoiRouter()
app.on('error', (err, ctx) => {
console.error('server error', err, ctx)
})
app.use(Logger())
.use(JSON({pretty: true}))
.use(JsonError())
.use(router.middleware())
.use(BodyParser({onerror:console.error}))
app.on('error', (err, ctx) => {
console.error('server error', err, ctx)
})
router.get('/health', async (ctx) => {
ctx.body = 'OK'
})