UNPKG

@greenpress/plugins

Version:
25 lines (19 loc) 692 B
import {getRouter, verifyUser, populateUser} from '@greenpress/api-kit'; import {createPlugin, getAllPlugins, getPlugin, removePlugin, updatePlugin} from '../controllers/manage-plugins'; import onlyPrivileged from '../middlewares/privileged-check'; export function managePlugins() { const router = getRouter(); const AUTHENTICATION_MIDDLEWARES = [populateUser, verifyUser, onlyPrivileged] router .route('/api/plugins') .use(AUTHENTICATION_MIDDLEWARES) .get(getAllPlugins) .post(createPlugin); router .route('/api/plugins/:pluginId') .use(AUTHENTICATION_MIDDLEWARES) .get(getPlugin) .put(updatePlugin) .delete(removePlugin); return router; }