Salta al contenuto principale
Versione: Successivo

Interface: ExpressMiddleware<PluginConfig, Storage, Auth>

pluginUtils.ExpressMiddleware

Middleware Plugin Interface

https://verdaccio.org/docs/next/plugin-middleware

This function allow add 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:31


options

Readonly options: PluginOptions

Inherited from

Plugin.options

Defined in

plugin-utils.ts:32


version

Readonly version: number

Inherited from

Plugin.version

Defined in

plugin-utils.ts:30

Methods

getVersion

getVersion(): number

Returns

number

Inherited from

Plugin.getVersion

Defined in

plugin-utils.ts:39


register_middlewares

register_middlewares(app, auth, storage): void

Parameters

NameType
appExpress
authAuth
storageStorage

Returns

void

Defined in

plugin-utils.ts:117