skweb-plugin
v2.2.0
Published
Plugin interface and types for skweb framework.
Readme
skweb-plugin
Plugin system for skweb framework. A plugin is a module that implements the
PluginModule interface; the framework discovers and orchestrates it.
Installation
npm install skweb-pluginUsage
import type { PluginModule, PluginContext } from 'skweb-plugin'
import { VERSION } from 'skweb-plugin'
const myPlugin: PluginModule = {
name: 'my-plugin',
version: '1.0.0',
description: 'Does something useful',
async beforeSetup(ctx: PluginContext) {
// Run before the framework finishes setup.
// Use ctx.db / ctx.redis here.
},
async afterSetup(ctx: PluginContext) {
// Run after the framework finishes setup.
// ctx.app is available here.
},
async initData(ctx: PluginContext) {
// Seed initial data.
}
}
export default myPluginA plugin module is a plain object — no base class required. All hooks are optional; implement only the ones you need.
The package also exports VERSION (the running skweb-plugin version) which
is useful for diagnostics.
License
MIT
