nodewrite-core-health
Version:
core health for nodewrite
58 lines (43 loc) • 1.37 kB
JavaScript
// Enforce use of a strict operating context.
;
// Define handler for this plugin.
const plugin = (nodewrite, options, nextPlugin) => {
// Use provided plugin options.
const { container, namespace } = options;
// Resolve dependencies from app container.
container.resolve((peers) => {
// Peer dependencies required before trying to load this plugin.
nodewrite.dependency(peers(__dirname), (server, nextDependency) => {
// Define methods used internally by this plugin.
const internals = {
// Register plugin controllers.
controllers: {
api: require('./controllers/api')(server)
}
};
// Register plugin views.
server.registerPluginAssets(__dirname);
// Attach plugin route(s) to api server.
server.select('api').route([
{
method: 'GET',
path: '/health/pulse',
config: {
id: namespace.api('pulse'),
handler: internals.controllers.api.pulse
}
}
]);
// Finished with peer dependency registration.
nextDependency();
});
// Finished with plugin registration.
nextPlugin();
});
};
// Attach plugin attributes.
plugin.attributes = {
pkg: require('./package.json')
};
// Expose plugin on module's register property.
exports.register = plugin;