ProcessContext

ProcessContext

ProcessContext

The ProcessContext can be injected into your providers & modules in order to know whether it is being executed in the context of the main Vendure server or the worker.

Example

import { Injectable, OnApplicationBootstrap } from '@nestjs/common';
import { ProcessContext } from '@vendure/core';

@Injectable()
export class MyService implements OnApplicationBootstrap {
  constructor(private processContext: ProcessContext) {}

  onApplicationBootstrap() {
    if (this.processContext.isServer) {
      // code which will only execute when running in
      // the server process
    }
  }
}

Signature

class ProcessContext {
  isServer: boolean
  isWorker: boolean
}

Members

isServer

property
type:
boolean

isWorker

property
type:
boolean