-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from StatelessStudio/v1.0.0
V1.0.0
- Loading branch information
Showing
49 changed files
with
5,030 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
# ts-appconfig | ||
|
||
## [1.0.0] Initial Release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
Oops, something went wrong.