UNPKG

pg-server

Version:

Postgres DB server emulator, proxy or honeypot

29 lines 1.1 kB
/// <reference types="node" /> /// <reference types="node" /> import { Socket } from 'net'; import { DbCommand } from './protocol/commands'; import { IResponseWriter } from './protocol/responses'; export type DbRawCommand = { command: DbCommand; /** Get raw data associated with this command (if you plan to forward it) */ getRawData: () => Buffer; }; export type DbCommandHandler = (command: DbRawCommand, response: IResponseWriter) => void; export interface IAdvanceServerSession { /** Subscribe to new connections */ onConnect?(socket: Socket): any | void; /** Handle inbound requests from connecting clients. Must not throw any error */ onCommand(command: DbRawCommand, response: IResponseWriter): void; } export interface AdvanceServerCtor { new (): IAdvanceServerSession; } /** * * @param settings */ export declare function createAdvancedServer(ctor: AdvanceServerCtor): import("net").Server; export declare function bindSocket(this: void, socket: Socket, handler: DbCommandHandler): { writer: IResponseWriter; }; //# sourceMappingURL=server.d.ts.map