Skip to content

How can I use external configuration parameters (not part of molecular.config.js) to be used in mixins or services #1110

Answered by ccampanale
rohitpatidar007 asked this question in Q&A
Discussion options

You must be logged in to vote

When I develop new microservices or types of microservices for my team we generally use the process environment variable approach in order to adhere to factor 3 of the 12 factor app.

Generally, this is as simple as referencing the process environment variable in the microservice settings object and using it elsewhere:

// keycloak.service.js
module.exports = {
    name: "keycloak",
    settings: {
        keycloakUrl: process.env.KEYCLOAK_URL,
    },
    action: {
        doSomething(ctx) {
            callKeycloakAPI(this.settings.keycloakUrl);
        }
    },
}

I tend to take the same approach with secrets but leverage Moleculer's secure service settings feature which allows you to prev…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@intech
Comment options

@rohitpatidar007
Comment options

Answer selected by rohitpatidar007
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants