generated from metcoder95/lib_template
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.d.ts
34 lines (28 loc) · 1.02 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
/// <reference types="node" />
import { FastifyPluginCallback } from 'fastify'
import { FastifyError } from '@fastify/error'
export interface FastifyRacingSignal extends AbortSignal {
then: (
onFulfilled?: (value: AbortEvent) => void | PromiseLike<unknown>,
onRejected?: (reason: Error | FastifyError) => void | PromiseLike<unknown>
) => void | Promise<unknown>
}
export interface AbortEvent {
type: 'abort' | string
reason?: FastifyError | Error
}
export interface FastifyRacingOptions {
handleError?: boolean
onRequestClosed?: ((evt: AbortEvent) => void) | null
}
declare module 'fastify' {
interface FastifyRequest {
race(cb: FastifyRacingOptions['onRequestClosed']): void
race(opts: Omit<FastifyRacingOptions, 'onRequestClosed'>): FastifyRacingSignal
race(opts: Omit<FastifyRacingOptions, 'onRequestClosed'>): Promise<AbortEvent>
race(): FastifyRacingSignal
race(): Promise<AbortEvent>
}
}
declare const FastifyRacing: FastifyPluginCallback<FastifyRacingOptions>
export default FastifyRacing