UNPKG

@thi.ng/server

Version:

Minimal HTTP server with declarative routing, static file serving and freely extensible via pre/post interceptors

13 lines (12 loc) 208 B
const authenticateWith = (pred) => ({ pre: (ctx) => { if (ctx.route.auth && !pred(ctx)) { ctx.res.unauthorized(); return false; } return true; } }); export { authenticateWith };