UNPKG

rjweb-server

Version:

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

78 lines (77 loc) 2.6 kB
import ValueCollection from "../../../classes/ValueCollection"; import Logger from "../../../classes/Logger"; import toArrayBuffer from "../../../functions/toArrayBuffer"; export default 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(); /** * Rate Limit Store * @since 9.0.0 */ this.rateLimits = new ValueCollection(); /** * 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: toArrayBuffer('Invalid Proxy Authentication Provided'), proxy_auth_required: toArrayBuffer('Proxy Authentication Required'), route_not_found: toArrayBuffer('Route Not Found'), rate_limit_exceeded: toArrayBuffer('Rate Limit Exceeded') }, /** * The Cache for the Compression Methods Header parsing * @since 9.0.0 */ compressionMethods: new ValueCollection(undefined, undefined, true, 100), /** * The Cache for static files * @since 9.0.0 */ staticFiles: new ValueCollection(undefined, undefined, true, 1500) }; this.options = options; this.logger = new Logger(options.logging); this.classContexts = classContexts; } }