define-plugin.d.ts 845 B

12345678910111213141516171819202122232425
  1. import type * as http from 'node:http';
  2. import type { Plugin } from '../types.js';
  3. /**
  4. * Helper function to define a http-proxy-middleware plugin
  5. * @see proxyServer {@link ProxyServer} - proxy server instance to which the plugin is being applied
  6. * @see options {@link Options} - options object passed to `createProxyMiddleware`
  7. *
  8. * @example defining a plugin
  9. * ```js
  10. * export const myPlugin = definePlugin((proxyServer, options) => {
  11. * // plugin implementation
  12. * });
  13. * ```
  14. *
  15. * @example using a plugin
  16. * ```js
  17. * createProxyMiddleware({
  18. * target: 'http://example.com',
  19. * plugins: [myPlugin],
  20. * });
  21. * ```
  22. *
  23. * @since 4.1.0
  24. */
  25. export declare function definePlugin<TReq extends http.IncomingMessage = http.IncomingMessage, TRes extends http.ServerResponse = http.ServerResponse>(fn: Plugin<TReq, TRes>): Plugin<TReq, TRes>;