UNPKG

@whook/whook

Version:

Build strong and efficient REST web services.

32 lines (31 loc) 1.53 kB
import { PassThrough, type Transform } from 'node:stream'; import { type JsonValue } from 'type-fest'; import { type WhookRequestBodySpec } from './body.js'; export type WhookParser = (content: string, bodySpec?: WhookRequestBodySpec) => JsonValue; export type WhookParsers = Record<string, WhookParser>; export type WhookStringifyer = (content: string) => string; export type WhookStringifiers = Record<string, WhookStringifyer>; export type WhookEncoder<T extends Transform = Transform> = () => T; export type WhookEncoders<T extends Transform = Transform> = Record<string, WhookEncoder<T>>; export type WhookDecoder<T extends Transform = Transform> = () => T; export type WhookDecoders<T extends Transform = Transform> = Record<string, WhookDecoder<T>>; export declare const DEFAULT_DEBUG_NODE_ENVS: string[]; export declare const DEFAULT_BUFFER_LIMIT = "500kB"; export declare const DEFAULT_PARSERS: { 'text/plain': (content: string) => JsonValue; 'application/json': (content: string) => JsonValue; 'application/x-www-form-urlencoded': (content: string) => JsonValue; }; export declare const DEFAULT_STRINGIFIERS: { 'text/plain': typeof ensureString; 'application/json': (content: JsonValue) => string; 'application/x-www-form-urlencoded': (content: JsonValue) => string; }; export declare const DEFAULT_DECODERS: { 'utf-8': () => PassThrough; }; export declare const DEFAULT_ENCODERS: { 'utf-8': () => PassThrough; }; declare function ensureString(maybeString: unknown): string; export {};