mirror of
https://github.com/fergalmoran/supanextail.git
synced 2025-12-22 09:17:54 +00:00
User can subscribe and it will be effective in the database. We now need to reflect this on the front end. Issue : Need to check how to upgrade a current subscription
14 lines
424 B
JavaScript
14 lines
424 B
JavaScript
// Helper method to wait for a middleware to execute before continuing
|
|
// And to throw an error when an error happens in a middleware
|
|
export default function initMiddleware(middleware) {
|
|
return (req, res) =>
|
|
new Promise((resolve, reject) => {
|
|
middleware(req, res, (result) => {
|
|
if (result instanceof Error) {
|
|
return reject(result);
|
|
}
|
|
return resolve(result);
|
|
});
|
|
});
|
|
}
|