Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use global variables in nest.js? #6460

Closed
ChoGathK opened this issue Feb 20, 2021 · 1 comment
Closed

How to use global variables in nest.js? #6460

ChoGathK opened this issue Feb 20, 2021 · 1 comment
Labels
needs triage This issue has not been looked into type: question 🙌

Comments

@ChoGathK
Copy link

ChoGathK commented Feb 20, 2021

Taking configuration as an example, the Nest.js documentation advocates registering Config Modules and injecting them into other modules in a dependency injection way.

The benefits are obvious, and the dependencies and code are clear, but what if I have a nest.js project that needs to invoke the configuration information at startup? This actually caused me trouble.

My idea is to use a store (actually a closure) to manage all the variables that might be needed globally, the client-side link objects, registered at startup, and introduced when needed.

When corresponding variables are registered in this way, they can be introduced anywhere. The drawback is that you need to manage dependencies yourself.

With the above concept design of demo: https://github.com/sophons-space/nest-server.

Please e help me correct, I am still a rookie.

@ChoGathK ChoGathK added needs triage This issue has not been looked into type: question 🙌 labels Feb 20, 2021
@ChoGathK ChoGathK changed the title How to use global variables in nest. Js How to use global variables in nest.js? Feb 20, 2021
@jmcdo29
Copy link
Member

jmcdo29 commented Feb 20, 2021

If you're looking for help, I suggest you visit our Discord. We're using GitHub to track bug reports, features requests, and regressions.

@jmcdo29 jmcdo29 closed this as completed Feb 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage This issue has not been looked into type: question 🙌
Projects
None yet
Development

No branches or pull requests

2 participants