middleware
Introduction
Usage
const { send } = require('light');
const checkAuth = async (req, res) => {
if (!req.headers.authorization) {
return send(401, 'please include authorization header');
}
return req.isAuthenticated = true;
}const { createRoute } = require('light');
const { route, addMiddleware } = route('middleware');
addMiddleware(checkAuth, someOtherMiddleare);
addMiddleware(whoopsForgotOne);
module.exports = route((req) => {
return {
isAuthenticated: req.isAuthenticated,
};
});Express and Koa Support
Last updated
Was this helpful?