@whook/whook
Version:
Build strong and efficient REST web services.
36 lines (35 loc) • 1.39 kB
TypeScript
import { type OpenAPI } from 'ya-open-api-types';
import { Readable, type Transform } from 'node:stream';
import { type WhookDecoders, type WhookEncoders, type WhookParsers, type WhookStringifiers } from '../libs/constants.js';
import { type WhookOpenAPIOperation } from '../types/openapi.js';
import { type WhookResponse } from '../types/http.js';
import { type WhookRequestBody } from '../types/http.js';
export interface WhookRequestBodySpec {
contentType: string;
contentLength: number;
charset: 'utf-8';
boundary?: string;
}
export declare const DEFAULT_REQUEST_BODY_SPEC: {
contentType: string;
contentLength: number;
charset: "utf-8";
};
export interface WhookResponseBodySpec {
contentTypes: string[];
charsets: string[];
}
export declare const DEFAULT_RESPONSE_BODY_SPEC: {
contentTypes: string[];
charsets: string[];
};
export declare function getBody({ DECODERS, PARSERS, API, bufferLimit, }: {
DECODERS?: WhookDecoders<Transform>;
PARSERS?: WhookParsers;
API: OpenAPI;
bufferLimit: number;
}, operation: WhookOpenAPIOperation, inputStream: Readable, bodySpec: WhookRequestBodySpec): Promise<WhookRequestBody | undefined>;
export declare function sendBody({ ENCODERS, STRINGIFIERS, }: {
ENCODERS?: WhookEncoders<Transform>;
STRINGIFIERS?: WhookStringifiers;
}, response: WhookResponse): Promise<WhookResponse>;