Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Service<T>

Use this object for representing a service in the application A Service is a singleton in the application, that is init after all others services are created

You can use a Service to create Listeners or implement shared behavior between others services

exports
abstract

Type parameters

Hierarchy

Constructors

  • new Service(webda: Core, name: string, params?: any): Service

Properties

_createException: string
_initException: any = undefined
_initTime: number
_name: string

Service name

_webda: Core

Webda Core object

logger: Logger

Logger with class context

parameters: T

Hold the parameters for your service

It will be bring from the webda.config.json

defaultMaxListeners: number

Methods

  • __clean(): Promise<any>
  • addListener(event: string | symbol, listener: function): this
  • addRoute(url: string, methods: HttpMethodType[], executer: Function, openapi?: object, allowPath?: boolean): void
  • Add a route dynamicaly

    Parameters

    • url: string

      of the route can contains dynamic part like {uuid}

    • methods: HttpMethodType[]
    • executer: Function

      Method to execute for this route

    • Default value openapi: object = {}
    • Default value allowPath: boolean = false

    Returns void

  • computeParameters(): void
  • emit(event: string | symbol, ...args: any[]): boolean
  • emitSync(event: any, data: any): Promise<any[]>
  • eventNames(): Array<string | symbol>
  • getMaxListeners(): number
  • getName(): string
  • getParameters(): T
  • getService<T>(service: string): T
  • init(): Promise<void>
  • initRoutes(): void
  • listenerCount(type: string | symbol): number
  • listeners(event: string | symbol): Function[]
  • off(event: string | symbol, listener: function): this
  • on(event: string | symbol, listener: function): this
  • onAsync(event: any, callback: any, queue?: string): void
  • Listen to an event as on(...) would do except that it will be asynchronous

    Parameters

    • event: any
    • callback: any
    • Default value queue: string = undefined

      Name of queue to use, can be undefined, queue name are used to define differents priorities

    Returns void

  • once(event: string | symbol, listener: function): this
  • prependListener(event: string | symbol, listener: function): this
  • prependOnceListener(event: string | symbol, listener: function): this
  • rawListeners(event: string | symbol): Function[]
  • reinit(config: any): Promise<void>
  • removeAllListeners(event?: string | symbol): this
  • removeListener(event: string | symbol, listener: function): this
  • resolve(): void
  • setMaxListeners(n: number): this
  • toPublicJSON(object: any): string
  • Convert an object to JSON using the Webda json filter

    Parameters

    • object: any

      The object to export

    Returns string

    The export of the strip object ( removed all attribute with _ )

  • listenerCount(emitter: EventEmitter, event: string | symbol): number

Generated using TypeDoc