@digicms/cms
Version:
An open source headless CMS solution to create and manage your own API. It provides a powerful dashboard and features to make your life easier. Databases supported: MySQL, MariaDB, PostgreSQL, SQLite
20 lines (15 loc) • 360 B
JavaScript
;
const { prop, isFunction } = require('lodash/fp');
/**
* @type {import('./').MiddlewareFactory}
*/
module.exports = (config = {}) => {
return async (ctx, next) => {
await next();
const { status } = ctx;
const handler = prop(`handlers.${status}`, config);
if (isFunction(handler)) {
await handler(ctx);
}
};
};