-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
48 lines (39 loc) · 1.35 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
import { FastifyPluginAsync, FastifyReply } from 'fastify'
declare namespace fastifyQueue {
export type QueueInitializer<ValueType = unknown, ReturnType = unknown, KeyType = PropertyKey> = (
key: KeyType,
value: ValueType,
reply: FastifyReply
) => ReturnType | PromiseLike<ReturnType>
export type QueueResolver<ValueType = unknown, ReturnType = unknown, KeyType = PropertyKey> = (
key: KeyType,
value: ValueType,
reply: FastifyReply
) => ReturnType | PromiseLike<ReturnType>
export type OnQueueResolved<ValueType = unknown, KeyType = PropertyKey> = (
resolvedQueue: Map<KeyType, ValueType>,
reply: FastifyReply
) => void | Promise<void>
export type QueueInstance <InputType = unknown, KeyType = PropertyKey> = {
add(key: KeyType, value: InputType): void
resolve(cb?: OnQueueResolved): Promise<void>
get contents(): Map<KeyType, PromiseLike<InputType>>
}
export type QueuePluginOptions = {
initializer?: QueueInitializer
resolver?: QueueResolver
onResolved?: OnQueueResolved
onError?(e: unknown): void
queueName?: string
concurrency?: number
stopOnError?: boolean
}
const fastifyQueue: FastifyPluginAsync<QueuePluginOptions>
export { fastifyQueue as default }
}
declare module 'fastify' {
interface FastifyReply {
queue: fastifyQueue.QueueInstance
}
}
export = fastifyQueue