UNPKG

pandora

Version:

A powerful and lightweight application manager for Node.js applications powered by TypeScript.

67 lines 1.78 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /** * Class WorkerContextAccessor * A easy way to access WorkerContext */ class WorkerContextAccessor { /** * @param context - Original context object */ constructor(context) { this.context = context; } /** * Current application name * @returns {string} */ get appName() { return this.context.processRepresentation.appName; } /** * Current application directory path * @returns {string} */ get appDir() { return this.context.processRepresentation.appDir; } /** * Current process name, such as worker, background * @returns {string} */ get processName() { return this.context.processRepresentation.processName; } /** * Current environment identical string, such as production, development * @returns {string} */ get env() { return this.context.getEnvironment().get('env'); } /** * Environment object, that should injected by procfile.js or globalConfig * @returns {Environment} */ get environment() { return this.context.getEnvironment(); } /** * Get service instance by service's name * @param {string} name - Name of service * @returns {Service} */ getService(name) { return this.context.serviceReconciler.get(name); } /** * Get a service class by service's name * @param {string} name - Name of service * @returns {class} */ getServiceClass(name) { return this.context.serviceReconciler.getServiceClass(name); } } exports.WorkerContextAccessor = WorkerContextAccessor; //# sourceMappingURL=WorkerContextAccessor.js.map