mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-31 00:16:47 +01:00
53354224fc
Upgrades biome to 1.6.1, and updates husky pre-commit hook. Most changes here are making type imports explicit.
19 lines
392 B
TypeScript
19 lines
392 B
TypeScript
import { type RequestHandler, Router } from 'express';
|
|
|
|
export const conditionalMiddleware = (
|
|
condition: () => boolean,
|
|
middleware: RequestHandler,
|
|
): RequestHandler => {
|
|
const router = Router();
|
|
|
|
router.use((req, res, next) => {
|
|
if (condition()) {
|
|
middleware(req, res, next);
|
|
} else {
|
|
next();
|
|
}
|
|
});
|
|
|
|
return router;
|
|
};
|