UNPKG

stackpress

Version:

Incept is a content management framework.

26 lines (25 loc) 746 B
export default function plugin(ctx) { ctx.on('listen', (_req, _res, ctx) => { try { const client = ctx.plugin('client'); if (!client?.model) return; for (const model of Object.values(client.model)) { ctx.use(model.events); } } 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`] = {}; }); } ;