@sigiljs/sigil
Version:
TypeScript-first Node.js HTTP framework offering schema-driven routing, modifier-based middleware, plugin extensibility, and flexible response templating
38 lines (37 loc) • 1.21 kB
TypeScript
import { Route } from '../../route';
import { SigilPluginConstructor } from './sigil-plugin';
import { $SigilInternalPluginAPI, DebugOptions, SigilOptions } from '../types';
/**
* Options provided to plugin context for internal framework APIs.
*/
interface Options {
/**
* Internal API enabling plugin to register other plugins, middleware, and routes.
*/
sigilApi: $SigilInternalPluginAPI;
/**
* Set of mounted routes in the application.
*/
routes: Set<[string, Route<any>]>;
/**
* Template function for formatting responses.
*/
responseTemplate: SigilOptions["responseTemplate"];
/**
* Debug options for plugin logging.
*/
debugOpts: Partial<DebugOptions>;
/**
* Plugin configuration
*/
pluginConfig?: Record<any, any>;
}
/**
* Attaches internal Sigil framework context to a plugin prototype.
* Adds routing, middleware, plugin APIs, response templating, and logging.
*
* @param plugin constructor of the Sigil plugin to augment.
* @param opts internal context options supplied by the framework.
*/
export default function attachPluginContext(plugin: SigilPluginConstructor<any>, opts: Options): void;
export {};