/
erioxis
/
web-nodejs
Обзор
Документация
Войти
/
erioxis
/
web-nodejs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
backend/node_modules/@fastify/postgres/index.d.ts
64 строки
1 KB
erioxis
lab11fix
15 дек 2025, 23:21
15 дек 2025, 23:21
70dc7ba
Код
Авторство
О чём код?
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