🌍Environment variables
Multijet offers environment variable validation for microservices using Joi
.
To add an environment variable to a microservice, simply edit the env.ts
file located in <service-name>/src/utils/env.ts
:
import Joi from 'joi'
// add variable and corresponding type here
export type Environment = {
ENVIRONMENT: string
}
// add validation rule for the variables defined above
export const JoiEnvironmentValidationSchema = Joi.object<Environment>()
.keys({
ENVIRONMENT: Joi.string().required(),
})
.required()
.unknown()
If you want to run your project locally using AWS Lambda or Docker, you can specify the environment variables in the global .env
file located in <project-name>/.env
(the file is ignored by default for security reasons, if it does not exists you can simply create it).
Example of a simple .env
file containing one variable called environment
:
ENVIRONMENT=dev
With this, running your project locally will assign every environment variables needed by your microservices.
Last updated