UNPKG

pandora

Version:

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

60 lines (59 loc) 1.59 kB
/** * A proxy (or called accessor) of the WorkerContext, to provide a grace interface to use */ import { WorkerContext } from './WorkerContext'; import { Environment } from 'pandora-env'; import { Service } from '../domain'; import { Facade } from 'pandora-hub'; /** * Class WorkerContextAccessor * A easy way to access WorkerContext */ export declare class WorkerContextAccessor { /** * Original context object */ context: WorkerContext; /** * @param context - Original context object */ constructor(context: any); /** * Current application name * @returns {string} */ readonly appName: string; /** * Current application directory path * @returns {string} */ readonly appDir: string; /** * Current process name, such as worker, background * @returns {string} */ readonly processName: string; /** * Current environment identical string, such as production, development * @returns {string} */ readonly env: string; /** * Environment object, that should injected by procfile.js or globalConfig * @returns {Environment} */ readonly environment: Environment; hub: Facade; /** * Get service instance by service's name * @param {string} name - Name of service * @returns {Service} */ getService<T extends Service>(name: string): T; /** * Get a service class by service's name * @param {string} name - Name of service * @returns {class} */ getServiceClass(name: string): any; }