import { Method } from "../types/global"; import ValueCollection from "./ValueCollection"; import { EndFn, RateLimitConfig, RealAny } from "../types/internal"; import { UsableValidator } from "./Validator"; import { oas31 } from "openapi3-ts"; import HttpRequestContext from "./request/HttpRequestContext"; import WsOpenContext from "./request/WsOpenContext"; import WsMessageContext from "./request/WsMessageContext"; import WsCloseContext from "./request/WsCloseContext"; import Base from "./request/Base"; type Segment = { raw: string; paramsRegExp: RegExp; params: string[]; }; type URLData = { type: 'regexp'; value: RegExp; prefix: string; segments: Segment[]; } | { type: 'normal'; value: string; segments: Segment[]; }; type RequestType = 'http' | 'static' | 'ws'; type Data = Type extends 'http' ? { onRawBody?(ctr: HttpRequestContext, end: EndFn, chunk: ArrayBuffer, isLast: boolean): RealAny; onRequest?(ctr: HttpRequestContext): RealAny; onFinish?(ctr: Base, ms: number): RealAny; } : Type extends 'static' ? { folder: string; stripHtmlEnding: boolean; } : { onUpgrade?(ctr: HttpRequestContext, end: EndFn): RealAny; onOpen?(ctr: WsOpenContext): RealAny; onOpenFinish?(ctr: Base, ms: number): RealAny; onMessage?(ctr: WsMessageContext): RealAny; onMessageFinish?(ctr: Base, ms: number): RealAny; onClose?(ctr: WsCloseContext): RealAny; onCloseFinish?(ctr: Base, ms: number): RealAny; }; export default class Route { type: Type; private urlMethod; urlData: URLData; /** * Create a new Route * @since 9.0.0 */ constructor(type: Type, urlMethod: Method, path: string | RegExp, data: Data); /** * The Data of this Route * @since 9.0.0 */ data: Data; /** * The Validators of this Route * @since 9.0.0 */ validators: UsableValidator[]; /** * The Ratelimit of this Route * @since 9.0.0 */ ratelimit: Type extends 'static' ? null : RateLimitConfig | null; /** * The OpenAPI Schema of this Route * @since 9.0.0 */ openApi: oas31.OperationObject; /** * Test the Path against the Request Path * @warn NOT FOR STATIC ROUTES * @since 9.0.0 */ matches(method: Method, collection: ValueCollection | null, requestPath: string, requestPathSplit: string[]): boolean; } export {};