UNPKG

rjweb-server

Version:

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

84 lines (83 loc) 3.01 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const ValueCollection_1 = __importDefault(require("../../../classes/ValueCollection")); const Logger_1 = __importDefault(require("../../../classes/Logger")); const toArrayBuffer_1 = __importDefault(require("../../../functions/toArrayBuffer")); class GlobalContext { constructor(options, implementation, classContexts) { this.implementation = implementation; /** * The Routes available for searching * @since 9.0.0 */ this.routes = { http: [], ws: [], static: [] }; /** * Channels that were used with the server * @since 9.0.0 */ this.channels = []; /** * The Error handlers * @since 9.0.0 */ this.errorHandlers = {}; /** * The Finish handlers * @since 9.0.0 */ this.finishHandlers = {}; /** * The Ratelimit Handlers * @since 9.0.0 */ this.rateLimitHandlers = {}; /** * The Not Found handler * @since 9.0.0 */ this.notFoundHandler = null; /** * The HTTP callback handler * @since 9.0.0 */ this.httpHandler = null; /** * Content Type Mappings * @since 9.0.0 */ this.contentTypes = new ValueCollection_1.default(); /** * Rate Limit Store * @since 9.0.0 */ this.rateLimits = new ValueCollection_1.default(); /** * Caches for various methods * @since 9.0.0 */ this.cache = { /** * The Cached base64 encoded proxy credentials * @since 9.0.0 */ proxyCredentials: '', /** * Cached ArrayBuffer Texts * @since 9.0.0 */ arrayBufferTexts: { proxy_auth_invalid: (0, toArrayBuffer_1.default)('Invalid Proxy Authentication Provided'), proxy_auth_required: (0, toArrayBuffer_1.default)('Proxy Authentication Required'), route_not_found: (0, toArrayBuffer_1.default)('Route Not Found'), rate_limit_exceeded: (0, toArrayBuffer_1.default)('Rate Limit Exceeded') }, /** * The Cache for the Compression Methods Header parsing * @since 9.0.0 */ compressionMethods: new ValueCollection_1.default(undefined, undefined, true, 100), /** * The Cache for static files * @since 9.0.0 */ staticFiles: new ValueCollection_1.default(undefined, undefined, true, 1500) }; this.options = options; this.logger = new Logger_1.default(options.logging); this.classContexts = classContexts; } } exports.default = GlobalContext;