Salta al contenuto principale
Versione: Successivo

Interface: ExpressMiddleware<PluginConfig, Storage, Auth>

pluginUtils.ExpressMiddleware

This function allow add additional middleware to the application.

import express, { Request, Response } from 'express';

class Middleware extends Plugin {
// instances of auth and storage are injected
register_middlewares(app, auth, storage) {
const router = express.Router();
router.post('/my-endpoint', (req: Request, res: Response): void => {
res.status(200).end();
});
}
}


const [plugin] = await asyncLoadPlugin(...);
plugin.register_middlewares(app, auth, storage);

Type parameters

Name
PluginConfig
Storage
Auth

Hierarchy

  • Plugin<PluginConfig>

    ExpressMiddleware

Properties

config

Readonly config: unknown

Inherited from

Plugin.config

Defined in

plugin-utils.ts:36


options

Readonly options: PluginOptions

Inherited from

Plugin.options

Defined in

plugin-utils.ts:37


version

Readonly version: number

Inherited from

Plugin.version

Defined in

plugin-utils.ts:35

Methods

getVersion

getVersion(): number

Returns

number

Inherited from

Plugin.getVersion

Defined in

plugin-utils.ts:44


register_middlewares

register_middlewares(app, auth, storage): void

Parameters

NameType
appExpress
authAuth
storageStorage

Returns

void

Defined in

plugin-utils.ts:104