@sigiljs/sigil
Version:
TypeScript-first Node.js HTTP framework offering schema-driven routing, modifier-based middleware, plugin extensibility, and flexible response templating
41 lines (40 loc) • 1.1 kB
JavaScript
import g from "../../utils/make-log.mjs";
function n(a, e) {
const u = `Plugin:${a.name}`;
a.prototype.__$ctx = {
/**
* Access to all application routes.
*/
routes: {
forEach: (i, l) => e.routes.forEach(i, l),
values: () => e.routes.values(),
toArray: () => Array.from(e.routes)
},
/**
* Raw configuration object (e.g., from nodemon).
*/
pluginConfig: e.pluginConfig || {},
/**
* Internal Sigil APIs exposed to plugins.
*/
sigilApi: {
addPlugin: (i, l) => e.sigilApi.addPlugin(i, l),
addMiddleware: (i) => e.sigilApi.addMiddleware(i),
plugin: (i) => e.sigilApi.plugin(i),
withPlugin: (i, l) => e.sigilApi.withPlugin(i, l),
mount: (i, l) => e.sigilApi.mount(i, l),
route: (i, l) => e.sigilApi.route(i, l)
},
/**
* Response templating function for use in plugins.
*/
responseTemplate: (i) => e.responseTemplate(i),
/**
* Logger function scoped to this plugin.
*/
logger: (i) => g(e.debugOpts, { module: u, ...i })
};
}
export {
n as default
};