@whook/whook
Version:
Build strong and efficient REST web services.
31 lines (30 loc) • 1.36 kB
TypeScript
import { type WhookObfuscatorService } from './obfuscator.js';
import { type WhookAPMService } from './apm.js';
import { type LogService, type TimeService, type DelayService } from 'common-services';
import { type IncomingMessage, type ServerResponse } from 'node:http';
import { type JsonValue } from 'type-fest';
import { type WhookRequest, type WhookResponse } from '../types/http.js';
export type WhookHTTPTransactionConfig = {
TIMEOUT?: number;
TRANSACTIONS?: Record<string, Record<string, JsonValue>>;
};
export type HTTPTransactionDependencies = WhookHTTPTransactionConfig & {
obfuscator: WhookObfuscatorService;
delay: DelayService;
log?: LogService;
apm?: WhookAPMService;
time?: TimeService;
uniqueId?: () => string;
};
export type WhookHTTPTransaction = {
request: WhookRequest;
transaction: {
id: string;
start: (buildResponse: () => Promise<WhookResponse>) => Promise<WhookResponse>;
catch: (err: Error) => Promise<void>;
end: (response: WhookResponse, operationId?: string) => Promise<void>;
};
};
export type WhookHTTPTransactionService = (req: IncomingMessage, res: ServerResponse) => Promise<WhookHTTPTransaction>;
declare const _default: import("knifecycle").ServiceInitializer<HTTPTransactionDependencies, WhookHTTPTransactionService>;
export default _default;