UNPKG

stackpress

Version:

Incept is a content management framework.

26 lines (25 loc) 742 B
export default function plugin(ctx) { ctx.on('route', (_req, _res, ctx) => { if (!ctx.config.get('admin')) return; try { const client = ctx.plugin('client'); for (const model of Object.values(client.model)) { model.admin(ctx); } } catch (e) { } }); ctx.on('idea', async (req) => { const transformer = req.data('transformer'); const schema = await transformer.schema(); if (!schema.plugin) { schema.plugin = {}; } const dirname = typeof __dirname === 'string' ? __dirname : import.meta.dirname; schema.plugin[`${dirname}/transform`] = {}; }); } ;