umami/lib/middleware.js
2020-07-25 16:31:07 -07:00

16 lines
332 B
JavaScript

import cors from 'cors';
export function use(middleware) {
return (req, res) =>
new Promise((resolve, reject) => {
middleware(req, res, result => {
if (result instanceof Error) {
return reject(result);
}
return resolve(result);
});
});
}
export const useCors = use(cors());