UNPKG

@thi.ng/server

Version:

Minimal HTTP server with declarative routing, static file serving and freely extensible via pre/post interceptors

33 lines 1.27 kB
import type { IncomingMessage } from "node:http"; import type { ParsedFormData } from "../api.js"; export declare const parseSearchParams: (params: URLSearchParams) => ParsedFormData; /** * Parses given URL's query string {@link parseFormData}. Any prefix * before/including the first `?` will be ignored. * * @param url */ export declare const parseQuerystring: (url: string) => ParsedFormData; export declare const parseRequestFormData: (req: IncomingMessage) => Promise<ParsedFormData>; /** * Parses given URI-encoded string of key-value pairs into a * {@link ParsedFormData} object. Throws an error if there're syntax/nesting * errors. * * @remarks * Supports the following syntax: * * - `key=value` * - `key[]=value`: append value to `key` array * - `key[a]=value`: set value `a` in object `key` * - `key[a][b]=value`: set nested value in object `key` * - `key[a][]=value`: append value to nested array in object `key` * * Ignores attempts to manipulate a JS prototype chain (via * [`isProtoPath()`](https://docs.thi.ng/umbrella/checks/functions/isProtoPath.html)), * i.e. `foo[__proto__][bar]=42` will be skipped. * * @param body */ export declare const parseFormData: (body: string) => ParsedFormData; //# sourceMappingURL=formdata.d.ts.map