import { NextApiRequest , NextApiResponse } from 'next' ; const runMiddleware = ( req , res , fn ) => { return new Promise ( ( resolve , reject ) => { fn ( req , res , ( result ) => { if ( result instanceof Error ) { return reject ( result ) ; } return resolve ( result ) ; } ) ; } ) ; } ; export default runMiddleware ;