From a3ff7069651022579ac910b9e7a0ca2ef5af3157 Mon Sep 17 00:00:00 2001 From: Edward Stone Date: Sat, 7 Oct 2023 22:53:22 -0700 Subject: [PATCH] types --- index.d.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..e2db556 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,27 @@ +declare module '@autotelic/fastify-queue' { + type InitializerFunc = (key: any, value: any, r: any) => any; + type ResolverFunc = (key: any, value: any, r: any) => any; + type OnErrorFunc = (e: Error, r: any) => void; + type OnResolvedFunc = (resolved: any, r: any) => Promise | void; + + interface FastifyQueueOptions { + initializer?: InitializerFunc; + resolver?: ResolverFunc; + onError?: OnErrorFunc; + onResolved?: OnResolvedFunc; + queueName?: string; + concurrency?: number; + stopOnError?: boolean; + } + + interface FastifyQueueInstance { + add: (key: any, value: any) => void; + resolve: (cb?: OnResolvedFunc) => Promise; + contents: any; + [key: string]: any; + } + + function fastifyQueue(fastify: any, options: FastifyQueueOptions): void; + + export = fastifyQueue; +}