mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-15 01:35:17 +01:00
21 lines
395 B
JavaScript
21 lines
395 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 allowPost = use(
|
|
cors({
|
|
origin: '*',
|
|
methods: ['POST', 'OPTIONS'],
|
|
}),
|
|
);
|