add `res.assert()` function

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!');

Author: Fantashit

1 thought on “add `res.assert()` function

  1. 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 think res.assert should not be add as a built-in function.

Comments are closed.