I can use single-line to ensure if a variable is true like this in Koa:
ctx.assert(ctx.state.user, 401, 'User not found. Please login!');
So I wonder that if we could add same method to res
?
res.assert(ctx.state.user, 401, 'User not found. Please login!');
I love express because of it’s built-in functions like
view render
,body-parser
,static-server
,router
, so I hope you could add more great tools, but it’s ok if you thinkres.assert
should not be add as a built-in function.