forked from fastify/fastify-nextjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
50 lines (42 loc) · 1.13 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/// <reference types="next" />
import {
FastifyReply,
FastifyRequest,
FastifyPluginCallback,
FastifySchema,
HTTPMethods
} from 'fastify';
import { NextServer } from 'next/dist/server/next';
import underPressure from 'under-pressure';
declare module 'fastify' {
type FastifyNextCallback = (
app: NextServer,
req: FastifyRequest,
reply: FastifyReply
) => Promise<void>;
interface FastifyInstance {
next(
path: string,
opts?:
| {
method: HTTPMethods;
schema: FastifySchema;
}
| FastifyNextCallback,
handle?: FastifyNextCallback
): void;
}
interface FastifyReply {
nextRender(path: string): Promise<void>;
}
}
// Infer options type, because not exported from Next.
type NextServerConstructor = ConstructorParameters<typeof NextServer>[0]
declare namespace fastifyNext {
interface FastifyNextOptions extends NextServerConstructor {
underPressure?: boolean | underPressure.UnderPressureOptions;
noServeAssets?: boolean;
}
}
declare const fastifyNext: FastifyPluginCallback<fastifyNext.FastifyNextOptions>;
export default fastifyNext;