UNPKG

dino-express

Version:

DinO enabled REST framework based on express

55 lines 2.12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RuntimeContext = void 0; /** * Provide the runtime context where for the execution */ class RuntimeContext { serverType; cloudProvider; cloudService; environment; constructor(environment) { this.environment = environment; this.serverType = this.environment.getOrDefault('dino:server:type', 'express'); this.cloudProvider = this.environment.getOrDefault('dino:cloud:provider', 'google'); this.cloudService = this.environment.getOrDefault('dino:cloud:service', 'function'); } getEnvironment() { return this.environment; } isStandalone() { return ['express', 'standalone'].includes(this.serverType); } /** * Validate if the configuration identifies an embedded runtime, a runtime is embedded * if the server is provided from an external sources for instance an AWS lambda or GCP * function * * @returns true if the configuration identifies an embedded runtime, false otherwise */ isEmbedded() { return ['serverless', 'embedded'].includes(this.serverType); } isRunningOnAwsLambda() { // TODO: QB serverType check is here for backward compatibility and will be removed soon return this.cloudProvider === 'aws' && (this.cloudService === 'lambda' || this.isEmbedded()); } isExposedToHandleEvents() { return this.environment.getOrDefault('dino:server:expose', 'api') === 'event'; } isExposedToHandleMixedScenarios() { return this.environment.getOrDefault('dino:server:expose', 'api') === 'mixed'; } isMonitoringEnabled() { return this.environment.getOrDefault('dino:server:monitoring:enabled', true); } isCo2MonitoringEnabled() { return this.environment.getOrDefault('dino:server:monitoring:co2', true); } isExposedToHandleApis() { return this.environment.getOrDefault('dino:server:expose', 'api') === 'api'; } } exports.RuntimeContext = RuntimeContext; //# sourceMappingURL=RuntimeContext.js.map