Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/petrgrishin/config-decorator

PoC: simple config decorator with type casting, validation and env-driven out of the box
https://github.com/petrgrishin/config-decorator

config decorator dotenv env poc

Last synced: 6 days ago
JSON representation

PoC: simple config decorator with type casting, validation and env-driven out of the box

Awesome Lists containing this project

README

        

# config-decorator
PoC: simple config decorator with type casting, validation and env-driven out of the box

## TL;DR
```bash
npm i config-decorator
```

```typescript
import { Config, Nullable, Option } from 'config-decorator';

@Config('app')
export class AppConfig {
@Option({
type: 'number',
default: 3000,
})
@Nullable()
public readonly port!: number;
}

const appConfig = new AppConfig();
console.log(appConfig.port);
// 3000
```

Environment:
```dotenv
APP_PORT=3000
```