-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create migration docs from Koa 1.x to 2.x #621
Comments
@pensierinmusica I am using Koa 2.0.0-alpha.3 since a couple of weeks now. No problems so far. I had to write a little module for basic auth (well, 10loc only), a modified logger with winston and my own error handler and that's it. Just my 2 cents. |
@alqu thanks for the feedback!
Does Koa 2.x still provide this default error handler? app.on('error', function(err){
log.error('server error', err);
}); Cheers! |
well, it looks a bit different: app.on('error', function (err, ctx) {
if (err == null) return
if (!(err instanceof Error)) err = new Error(`non-error thrown: ${err}`)
if (ctx) {
// do some stuff here.
let msg = {} // whatever you want to respond with
// finally, make sure you finish properly:
msg = JSON.stringify(msg)
ctx.res.statusCode = err.status
ctx.res.length = Buffer.byteLength(msg)
ctx.res.end(msg)
}
}) |
But... yeah, you could write the one you suggested. But you should also react on errors... |
@alqu of course ;) That was just copy / paste from Koajs official docs, what I wondered is if the 'error' event handler was still there in Koa 2.x, which you confirm. Great! |
i updated the description here: #533 (comment) closing this issue - any future comments should go in that thread :) |
Refers to #523 (comment)
Are there any docs about:
Also, @tj how reliable is Koa 2.0.0-alpha.3 to be used in production?
Thanks!
The text was updated successfully, but these errors were encountered: