Elemental lowcode development platform.
The environment service allows you to fetch values based upon the environment that the system is running in. You can access the following methods on this service:
These methods are covered in more detail below.
Parameters:
name
- string, the name of the environmental variableReturns the value of the environmental variable, if defined, on the system.
This can be called from your controllers like so:
module.exports = {
events : {
load : (event) => {
let logLevel = this.environmentService.getEnvironmentalVariable("DEGUG") === "1" ? "debug" : "error";
}
}
};
Returns a list of all environmental variables, excluding secrets.
This can be called from your controllers like so:
module.exports = {
events : {
load : (event) => {
let env = this.environmentService.listEnvironmentVariables();
}
}
};
Parameters:
name
- string, the name of the secret as defined within the security centerReturns the value of the named secret.
This can be called from your services like so:
const emailProvider = function(environmentService) {
this.client = require('@sendgrid/mail');
this.client.setApiKey(environmentService.getSecret("sendGridKey"));
};
emailProvider.prototype.sendEmail = function(from, subject, body, to) {
const msg = {
to: to,
from: from,
subject: subject,
text: body,
html: body,
};
return this.client.send(msg);
};
module.exports = emailProvider;
; and from within your controllers:
module.exports = {
events : {
load : (event) => {
let secretValue = this.environmentService.getSecret("mySecret");
}
}
};
Returns a list of all secrets.
This can be called from your controllers like so:
module.exports = {
events : {
load : (event) => {
let secrets = this.environmentService.listSecrets();
}
}
};