UNPKG

@juspay/neurolink

Version:

The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types — generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002

33 lines (32 loc) • 1.76 kB
/** * Raw request bodies and raw responses for the server adapters. * * The adapters parse JSON (and url-encoded forms) into `ctx.body`. Routes that * take uploads — `POST /v1/audio/transcriptions` takes `multipart/form-data` * the way OpenAI's API does — need the bytes instead, so for the content types * below every adapter hands the route the unparsed body as a `Buffer`, bounded * by `bodyParser.maxSize`. A route that must answer in a wire format other than * the adapters' `{ data, metadata }` envelope (an OpenAI-compatible route, a * plain-text response) returns a web `Response`, which every adapter sends as is. * * @module server/utils/rawBody */ /** `true` for a content type whose body the adapters pass through unparsed. */ export declare function isRawBodyContentType(contentType: unknown): boolean; /** "10mb" / "512kb" / "1gb" / a byte count → bytes. Falls back to 10 MB. */ export declare function parseByteLimit(limit: string | number | undefined): number; /** Thrown when a raw body grows past the adapter's `maxSize`. */ export declare class RawBodyTooLargeError extends Error { readonly status = 413; constructor(limit: number); } /** Read a Node request stream into one `Buffer`, refusing more than `maxBytes`. */ export declare function readRawBody(stream: AsyncIterable<Buffer | string>, maxBytes: number): Promise<Buffer>; /** A web `Response` returned by a route handler. */ export declare function isWebResponse(value: unknown): value is Response; /** Status, headers and body bytes of a web `Response`, for adapters that write to a Node response. */ export declare function readWebResponse(response: Response): Promise<{ status: number; headers: Record<string, string>; body: Buffer; }>;