UNPKG

rjweb-server

Version:

Easy and Robust Way to create a Web Server with Many Easy-to-use Features in NodeJS

98 lines (97 loc) 3.21 kB
import Route from "../../../classes/Route"; import ValueCollection from "../../../classes/ValueCollection"; import { Implementation } from "../../implementation"; import { FullServerOptions } from "../../structures/ServerOptions"; import { ClassContexts, EndFn, ErrorCallbacks, FinishCallbacks, RatelimitCallbacks, RealAny } from ".."; import Logger from "../../../classes/Logger"; import Channel from "../../../classes/Channel"; import { CompressionAlgorithm } from "../../global"; import HttpRequestContext from "../../../classes/request/HttpRequestContext"; export default class GlobalContext { implementation: Implementation; constructor(options: FullServerOptions, implementation: Implementation, classContexts: ClassContexts); /** * The Routes available for searching * @since 9.0.0 */ routes: { http: Route<'http'>[]; ws: Route<'ws'>[]; static: Route<'static'>[]; }; /** * The Options for the Server * @since 9.0.0 */ options: FullServerOptions; /** * The Logger for Internal Events * @since 9.0.0 */ logger: Logger; /** * Channels that were used with the server * @since 9.0.0 */ channels: Channel[]; /** * Class Contexts used to create the ctr object * @since 9.0.0 */ classContexts: ClassContexts; /** * The Error handlers * @since 9.0.0 */ errorHandlers: ErrorCallbacks<any>; /** * The Finish handlers * @since 9.0.0 */ finishHandlers: FinishCallbacks<any>; /** * The Ratelimit Handlers * @since 9.0.0 */ rateLimitHandlers: RatelimitCallbacks<any>; /** * The Not Found handler * @since 9.0.0 */ notFoundHandler: ((ctr: HttpRequestContext<any>) => RealAny) | null; /** * The HTTP callback handler * @since 9.0.0 */ httpHandler: ((ctr: HttpRequestContext<any>, end: EndFn) => RealAny) | null; /** * Content Type Mappings * @since 9.0.0 */ contentTypes: ValueCollection<string, string, string>; /** * Rate Limit Store * @since 9.0.0 */ rateLimits: ValueCollection<`http+${string}-${number}` | `ws+${string}-${number}`, { hits: number; end: number; }, { hits: number; end: number; }>; /** * Caches for various methods * @since 9.0.0 */ cache: { /** * The Cached base64 encoded proxy credentials * @since 9.0.0 */ proxyCredentials: string; /** * Cached ArrayBuffer Texts * @since 9.0.0 */ arrayBufferTexts: { proxy_auth_invalid: ArrayBufferLike; proxy_auth_required: ArrayBufferLike; route_not_found: ArrayBufferLike; rate_limit_exceeded: ArrayBufferLike; }; /** * The Cache for the Compression Methods Header parsing * @since 9.0.0 */ compressionMethods: ValueCollection<string, CompressionAlgorithm, CompressionAlgorithm>; /** * The Cache for static files * @since 9.0.0 */ staticFiles: ValueCollection<string, [path: string, route: Route<"static">], [path: string, route: Route<"static">]>; }; }