how to use the environment variable in shared module of BFF architecture nodejs

51 views Asked by At

I have a util class which is shared to the UI. In this setup all the models are in the dist folder when the project is built and the same is shared to the UI and other microservices.

example:

import { someModel } from 'models/sharedModels'

class MyUtil {
  static isTrueOrFalse(a: string, b:string): boolean {

     if(something === 'abc' && process.env.SOMETHING === 'xyz'){
         return true;
      }

  }

with the above changes my project is deployed as a microservice in serverless framework. lets say the name and version is [email protected]

Now in my Angular UI, I installed this package and use it to define types etc. The model is shared by backend and available for other services, UI to use and comply with the structure.

I have a toggle in UI, that sets to yes or no through onclick using the MyUtil.isTrueOrFalse function.

ex: import { MyUtil } from 'some-project';

process.env.SOMETHING used in the MyUtil.isTrueOrFalse function is not recognized in the UI. Is there a way to use env variable in shared modules? If not, please suggest possible alternatives.

0

There are 0 answers