Skip to content

Commit

Permalink
Merge pull request #1 from StatelessStudio/v1.0.0
Browse files Browse the repository at this point in the history
V1.0.0
  • Loading branch information
DrewImm authored Jan 19, 2022
2 parents 1dfdf7a + bb77b37 commit 37338f0
Show file tree
Hide file tree
Showing 49 changed files with 5,030 additions and 103 deletions.
6 changes: 5 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
APP_TITLE="ts-appconfig"
APP_TITLE="Typescript App Config"
NODE_ENV=test
GREETING=hello
SHOULD_LOG_GREETING=true
NUMBER_OF_TIMES=4
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: node_js
node_js:
- "12.13.0"
- 16
install:
- npm install --ignore-scripts
- npm install
after_success:
- npm run coveralls
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# ts-appconfig

## [1.0.0] Initial Release
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,35 @@
# ts-appconfig

## Install

`npm i ts-appconfig`

## Setup

`.env`
```
APP_TITLE="Cool App"
```

`src/index.ts`
```typescript
import { env } from './environment.ts';

console.log(env.APP_TITLE);
```

`src/environment.ts`
```typescript
import { AppConfig, configure } from '../src';

export class Environment extends AppConfig {
readonly APP_TITLE: string = '';
}

export const env: Environment = configure(Environment);
```

Output:
```
Cool App
```
10 changes: 10 additions & 0 deletions example/env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { AppConfig, configure } from '../src';

export class Environment extends AppConfig {
readonly APP_TITLE: string = '';
readonly GREETING: string = '';
readonly SHOULD_LOG_GREETING = false;
readonly NUMBER_OF_TIMES = 1;
}

export const env: Environment = configure(Environment);
14 changes: 14 additions & 0 deletions example/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* eslint-disable no-console */
import { env } from './env';

// Log the APP_TITLE from .env
console.log(env.APP_TITLE);

// Should log a greeting?
if (env.SHOULD_LOG_GREETING) {
// Log the greeting X times, where X = NUMBER_OF_TIMES
for (let i = 0; i < env.NUMBER_OF_TIMES; i++) {
// Log the greeting
console.log(env.GREETING);
}
}
Loading

0 comments on commit 37338f0

Please sign in to comment.