Docs
Apis
Plugin Guide
Plugin Guide
Plugins allow you to go beyond simple middleware-based server implementations and extend your server at the framework level.
#Applying a Plugin
To apply a plugin, add it to the plugins field in your configuration.
Typescript
import { defineConfig } from "dobs";
import { MY_PLUGIN } from "./plugin";
export default defineConfig({
plugins: [MY_PLUGIN()],
});#Plugin Example
Typescript
import type { Plugin } from "dobs";
let config;
export const PLUGIN: Plugin = {
name: "TEST_PLUGIN", // used for debugging
// Plugin target
// - undefined : all
// - "development" : only dev mode
// - "production" : only prod mode
apply: "development",
// Access the unresolved config
config(cfg) {
cfg.port = 8080;
},
// Access the resolved config
resolvedConfig(_config) {
config = _config;
},
// Access compiler options
resolveBuildOptions(buildOptions) {
buildOptions.tsconfig = "./tsconfig.json";
},
// Access route definitions
// Example: https://github.com/zely-js/dobs/blob/main/packages/dobs/src/experimental/cache.ts#L140
async generateRoute(route) {},
};See plugin.ts for reference.