-
-
Notifications
You must be signed in to change notification settings - Fork 34
/
index.d.ts
64 lines (51 loc) · 1.48 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { FastifyPluginCallback } from 'fastify';
import * as Pg from 'pg';
declare module 'fastify' {
export interface FastifyInstance {
pg: fastifyPostgres.PostgresDb & Record<string, fastifyPostgres.PostgresDb>;
}
export interface FastifyRequest {
pg?: Pg.PoolClient;
}
export interface RouteShorthandOptions {
pg?: fastifyPostgres.FastifyPostgresRouteOptions;
}
}
type FastifyPostgres = FastifyPluginCallback<fastifyPostgres.PostgresPluginOptions>;
declare namespace fastifyPostgres {
export type PostgresDb = {
pool: Pg.Pool;
Client: Pg.Client;
query: Pg.Pool['query'];
connect: Pg.Pool['connect'];
transact: typeof transact;
};
export type FastifyPostgresRouteOptions = {
transact: boolean | string;
};
export type PostgresPluginOptions = {
/**
* Custom pg
*/
pg?: typeof Pg;
/**
* Use pg-native
*/
native?: boolean;
/**
* Instance name of fastify-postgres
*/
name?: string;
} & Pg.PoolConfig;
export function transact<TResult>(
fn: (client: Pg.PoolClient) => Promise<TResult>
): Promise<TResult>;
export function transact<TResult>(
fn: (client: Pg.PoolClient) => Promise<TResult>,
cb: (error: Error | null, result?: TResult) => void
): void;
export const fastifyPostgres: FastifyPostgres
export { fastifyPostgres as default }
}
declare function fastifyPostgres(...params: Parameters<FastifyPostgres>): ReturnType<FastifyPostgres>
export = fastifyPostgres