📡 ExpressJS Middleware
Using middleware to apply logic to multiple endpoints
http.ts
// Custom Middleware
const auth = (request, response, next) => {
if (!request.headers.authorization) {
response.status(400).send('unauthorized');
}
next();
};
// Multi Route ExpressJS HTTP Function
const app = express();
app.use(cors({ origin: true }));
app.use(auth);