UNPKG

@intuitionrobotics/thunderstorm

Version:
45 lines 1.9 kB
import { Module } from "@intuitionrobotics/ts-common"; import type { ObjectTS } from "@intuitionrobotics/ts-common"; import type { ApiResponse, HttpRequestData } from "./server-api.js"; import { ApiException } from "../../exceptions.js"; import type { Express, ExpressRequest } from "../../utils/types.js"; type ConfigType = { baseUrl: string; cors: { origins?: string[]; methods?: string[]; headers?: string[]; exposedHeaders?: string[]; }; bodyParserLimit: number | string; }; export type HttpErrorHandler = (requestData: HttpRequestData, error: ApiException) => Promise<string>; export type ServerApi_Middleware = (request: ExpressRequest, data: HttpRequestData, response: ApiResponse, scopes: string[]) => Promise<ObjectTS | void>; export declare class HttpServer_Class extends Module<ConfigType> { private readonly express; constructor(_express: Express, configElement: ConfigType); getBaseUrl(): string; /** * Collapse duplicate slashes in a URL's PATH only — the query string is * preserved verbatim (a naive global replace mangles values like * `?redirect=https://...`). */ static normalizeUrlPath(url: string): string; /** * Collapse duplicate slashes and trim the trailing slash WITHOUT mangling * the protocol separator. (The old in-line replace turned `http://` into * `http:/` — which is why configs grew `http:////` workarounds. Both forms * normalize correctly now.) */ static normalizeBaseUrl(baseUrl: string): string; setup(): void; mountRouter(router: import("express").Router, urlPrefix?: string): void; } export declare class HeaderKey { private readonly key; private readonly responseCode; constructor(key: string, responseCode?: number); get(request: ExpressRequest): string; } export {}; //# sourceMappingURL=HttpServer.d.ts.map