UNPKG

txq

Version:

TXQ: Bitcoin Transaction Storage Queue Service

25 lines (19 loc) 639 B
import { Router, Request, Response, NextFunction } from 'express'; type Wrapper = (router: Router) => void; export const applyMiddleware = (middlewareWrappers: Wrapper[], router: Router) => { for (const wrapper of middlewareWrappers) { wrapper(router); } }; type Handler = (req: Request, res: Response, next: NextFunction) => Promise<void> | void; type Route = { path: string; method: string; handler: Handler | Handler[]; }; export const applyRoutes = (routes: Route[], router: Router) => { for (const route of routes) { const { method, path, handler } = route; (router as any)[method](path, handler); } };