initMiddleware() Function
Adapts an Express middleware into an async function suitable for use with Next.js API routes.
This is taken directly from https://github.com/vercel/next.js/blob/canary/examples/api-routes-cors/lib/init-middleware.js
Signature
export declare function initMiddleware<T extends Function>(middleware: T): (req: any, res: any) => Promise<any>;
Parameters
Parameter | Type | Description |
---|---|---|
middleware | T | The Express middleware instance |
(Returns) | (req: any, res: any) => Promise<any> | An async function that should be called with |