1.3.6 • Published 3 years ago
@mjsdevs/config.ts v1.3.6
config.ts
Config.ts is a generic configuration service that uses dotenv and typescript to improve the experience when using environment variables.
Install
// with NPM
npm install @mjsdevs/config.ts
// with yarn
yarn add @mjsdevs/config.ts
Usage
import {
Result,
ConfigurationServiceFactory,
} from '@mjsdevs/config.ts'
// create an interface/class with the desired environment variables
interface EnvDefinition {
NODE_ENV: string;
}
// get a factory for configuration service
const factory = new ConfigurationServiceFactory<EnvDefinition>();
// use the factory to create a new ConfigurationService instance.
// you need to implement the handler to return a success or failing Result
const service = factory.create({
validation:{
handler: (env) => Result.ok(env),
},
options: {}
});
// user the service to get environment variables
const env = service.get('NODE_ENV'); // development
Changelog
// WIP
Contributing
// WIP
1.3.6
3 years ago
1.3.4
3 years ago
1.3.3
3 years ago
1.3.2
3 years ago
1.3.1
3 years ago
1.3.0
3 years ago
1.2.1-0
3 years ago
1.2.1-1
3 years ago
1.2.3
3 years ago
1.2.2
3 years ago
1.2.1
3 years ago
1.2.0
3 years ago
2.0.0
3 years ago
1.0.1-7
3 years ago
1.0.1-6
3 years ago
1.0.1-5
3 years ago
1.0.1-4
3 years ago
1.0.1-3
3 years ago
1.0.1-2
3 years ago