UNPKG

@mojojs/core

Version:

Real-time web framework

67 lines (66 loc) 2.17 kB
import type { MojoApp, ServerOptions } from './types.js'; import type { Socket } from 'node:net'; import http from 'node:http'; import https from 'node:https'; import { URL } from 'node:url'; import { ServerRequest } from './server/request.js'; import { WebSocketServer } from 'ws'; type ListenArgs = any[]; /** * HTTP and WebSocket server class. */ export declare class Server { /** * Application this server handles. */ app: MojoApp; /** * Limit the amount of time the parser will wait to receive the complete HTTP headers, defaults to `60000` * (60 seconds). */ headersTimeout: number | undefined; /** * Limit the amount of time of inactivity a server needs to wait for additional incoming data, after it has finished * writing the last response, before a socket will be destroyed, defaults to `5000` (5 seconds). */ keepAliveTimeout: number | undefined; /** * Maximum number of requests socket can handle before closing keep alive connection, defaults to `0`. */ maxRequestsPerSocket: number | undefined; /** * Limit the amount of time for receiving the entire request from the client, defaults to `300000` (300 seconds). */ requestTimeout: number | undefined; /** * Reverse proxy mode. */ reverseProxy: boolean; /** * Server URLs. */ urls: URL[]; _cluster: boolean; _listen: string[]; _servers: (http.Server | https.Server)[]; _quiet: boolean; _workers: number; constructor(app: MojoApp, options?: ServerOptions); /** * Turn URL into listen arguments. */ static listenArgsForURL(url: URL): ListenArgs; /** * Start server. */ start(): Promise<void>; /** * Stop server. */ stop(): Promise<void>; _createServer(location: string): Promise<void>; _handleRequest(req: http.IncomingMessage, raw: http.ServerResponse): void; _handleUpgrade(wss: WebSocketServer, req: http.IncomingMessage, socket: Socket, head: Buffer): void; _prepareRequest(req: http.IncomingMessage, socket: Socket, isWebSocket: boolean): ServerRequest; } export {};