import http, { IncomingMessage, ServerResponse } from 'node:http'; import { FastifyCorsOptions } from '@fastify/cors'; import { CorsOptions } from 'cors'; import TestAgent from 'supertest/lib/agent'; import { Pipe, PipeOutput } from 'valleyed'; import { EventBus } from './events/index.js'; import { A as AuthUser } from './overrides-6Hxg764S.js'; import { d as RouteDef, j as RouterConfig, i as RouteConfig, l as RouteDefHandler, k as MergeRouteDefs, e as Route, R as Request, a as Response, M as MethodsEnum } from './requestError-BmOhSuFb.js'; import { IncomingHttpHeaders } from 'node:http2'; import { Server as Server$1 } from 'socket.io'; import { E as Entity } from './core-tNlIMH9Y.js'; declare abstract class BaseRequestAuthMethod { abstract parse(headers: IncomingHttpHeaders): Promise; abstract routeSecuritySchemeName(): string | null; static process(methods: BaseRequestAuthMethod[], headers: IncomingHttpHeaders): Promise; } declare class Router { #private; constructor(config?: RouterConfig); head: (path: string, config?: RouteConfig) => (handler: RouteDefHandler>) => Route>; get: (path: string, config?: RouteConfig) => (handler: RouteDefHandler>) => Route>; post: (path: string, config?: RouteConfig) => (handler: RouteDefHandler>) => Route>; put: (path: string, config?: RouteConfig) => (handler: RouteDefHandler>) => Route>; patch: (path: string, config?: RouteConfig) => (handler: RouteDefHandler>) => Route>; delete: (path: string, config?: RouteConfig) => (handler: RouteDefHandler>) => Route>; options: (path: string, config?: RouteConfig) => (handler: RouteDefHandler>) => Route>; nest(...routers: Router[]): void; get routes(): Route[]; } type OnJoinFn = (data: { channel: string; user: AuthUser | null; }, params: Record, query: Record) => Promise; type SocketCallbacks = { onConnect: (userId: string, socketId: string) => Promise; onDisconnect: (userId: string, socketId: string) => Promise; }; declare class SocketEmitter { #private; private config; readonly socketInstance: Server$1; constructor(socket: Server$1, config: ServerConfig); created(channels: string[], data: T, to: string | string[] | null): Promise; updated(channels: string[], { after, before }: { after: T; before: T; }, to: string | string[] | null): Promise; deleted(channels: string[], data: T, to: string | string[] | null): Promise; set connectionCallbacks(callbacks: SocketCallbacks); register(channel: string, onJoin: OnJoinFn): this; } declare const serverConfigPipe: () => Pipe<{ port: number; cors: { origin: true | string[] | undefined; methods: ("head" | "get" | "post" | "put" | "patch" | "delete" | "options")[] | undefined; credentials: boolean | undefined; } | undefined; eventBus: EventBus | undefined; publicPath: string | undefined; healthPath: string | undefined; openapi: { docsVersion: string | undefined; docsBaseUrl: string[] | undefined; docsPath: string | undefined; } | undefined; requests: { log: boolean | undefined; rateLimit: { enabled: boolean | undefined; periodInMs: number | undefined; limit: number | undefined; } | undefined; slowdown: { enabled: boolean | undefined; periodInMs: number | undefined; delayAfter: number | undefined; delayInMs: number | undefined; } | undefined; } | undefined; socketsAuthMethods: BaseRequestAuthMethod[] | undefined; }, { port: number; cors: { origin: true | string[] | undefined; methods: ("head" | "get" | "post" | "put" | "patch" | "delete" | "options")[] | undefined; credentials: boolean | undefined; } | undefined; eventBus: EventBus | undefined; publicPath: string | undefined; healthPath: string | undefined; openapi: { docsVersion: string; docsBaseUrl: string[]; docsPath: string; }; requests: { log: boolean; rateLimit: { enabled: boolean; periodInMs: number; limit: number; }; slowdown: { enabled: boolean; periodInMs: number; delayAfter: number; delayInMs: number; }; }; socketsAuthMethods: BaseRequestAuthMethod[]; }>; type ServerConfig = PipeOutput>; declare const rawResponseHandledSymbol: unique symbol; type RawResponseHandled = { readonly [rawResponseHandledSymbol]: true; }; type RawResponseHandler = (request: IncomingMessage, response: ServerResponse) => unknown | Promise; type RawResponder = (handler: RawResponseHandler) => Promise; type ServerBeforeListenContext = { httpServer: http.Server; port: number; }; type ServerBeforeListenHandler = (context: ServerBeforeListenContext) => void | Promise; type ServerNotFoundContext = { request: Request; respondWithRaw: RawResponder; }; type ServerNotFoundHandler = (context: ServerNotFoundContext) => Response | RawResponseHandled | Promise | RawResponseHandled>; declare abstract class Server { #private; socket: SocketEmitter; cors: CorsOptions & FastifyCorsOptions; protected abstract parseRequest(req: any): Promise>; protected abstract handleResponse(res: any, response: Response): Promise; protected abstract createRawResponder(req: any, res: any): RawResponder; protected abstract registerRoute(method: MethodsEnum, path: string, cb: (req: any, res: any) => Promise): void; protected abstract registerErrorHandler(cb: (error: Error, req: any, res: any) => Promise): void; protected abstract registerNotFoundHandler(cb: (req: any, res: any) => Promise): void; protected abstract startServer(port: number): Promise; protected setup(httpServer: http.Server, config: ServerConfig): void; addRouter(...routers: Router[]): void; addRoute(...routes: Route[]): void; setNotFoundHandler(handler: ServerNotFoundHandler): this; onBeforeListen(handler: ServerBeforeListenHandler): this; test(): TestAgent; start(): Promise; protected createNodeRawResponder(input: { request: IncomingMessage; response: ServerResponse; beforeHandle?: () => void; }): RawResponder; } export { BaseRequestAuthMethod as B, type OnJoinFn as O, type RawResponder as R, Server as S, type ServerConfig as a, type RawResponseHandled as b, type RawResponseHandler as c, type ServerBeforeListenContext as d, type ServerBeforeListenHandler as e, type ServerNotFoundContext as f, type ServerNotFoundHandler as g, Router as h, type SocketCallbacks as i, SocketEmitter as j, serverConfigPipe as s };