1 | /// <reference types="fastify" />
|
2 |
|
3 | import * as fastify from 'fastify';
|
4 |
|
5 | /**
|
6 | * This function does three things for you:
|
7 | * 1. Add the `skip-override` hidden property
|
8 | * 2. Check bare-minimum version of Fastify
|
9 | * 3. Pass some custom metadata of the plugin to Fastify
|
10 | * @param fn Fastify plugin function
|
11 | * @param options Optional plugin options
|
12 | * @param next The `next` callback is not available when using `async`/`await`. If you do invoke a `next` callback in this situation unexpected behavior may occur.
|
13 | */
|
14 | declare function fastifyPlugin<HttpServer, HttpRequest, HttpResponse, T>(
|
15 | fn: fastify.Plugin<HttpServer, HttpRequest, HttpResponse, T>,
|
16 | options?: fastifyPlugin.PluginOptions | string,
|
17 | next?: fastifyPlugin.nextCallback
|
18 | ): fastify.Plugin<HttpServer, HttpRequest, HttpResponse, T>;
|
19 |
|
20 | declare namespace fastifyPlugin {
|
21 | type nextCallback = () => void;
|
22 | interface PluginOptions {
|
23 | /** Bare-minimum version of Fastify for your plugin, just add the semver range that you need. */
|
24 | fastify?: string,
|
25 | name?: string,
|
26 | /** Decorator dependencies for this plugin */
|
27 | decorators?: {
|
28 | fastify?: string[],
|
29 | reply?: string[],
|
30 | request?: string[]
|
31 | },
|
32 | /** The plugin dependencies */
|
33 | dependencies?: string[]
|
34 | }
|
35 | }
|
36 |
|
37 | export = fastifyPlugin; |
\ | No newline at end of file |