@dsmrt/axiom-config 0.0.5 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +119 -0
- package/lib/index.d.ts +3 -2
- package/package.json +3 -2
package/README.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
<picture>
|
|
2
|
+
<source media="(prefers-color-scheme: dark)" srcset="../images/axiom-dark-mode.svg">
|
|
3
|
+
<source media="(prefers-color-scheme: light)" srcset="../images/axiom-light-mode.svg">
|
|
4
|
+
<img alt="Axiom logo" src="./images/axiom-light-mode.svg">
|
|
5
|
+
</picture>
|
|
6
|
+
|
|
7
|
+
# Axiom - Config
|
|
8
|
+
|
|
9
|
+
> An AWS focused config manager
|
|
10
|
+
|
|
11
|
+
This package focuses on the config part of axiom
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
- Customize your application's config type interface
|
|
15
|
+
- load config based on environment
|
|
16
|
+
- Multiple environments/accounts/regions
|
|
17
|
+
- Secrets with SSM Parameters
|
|
18
|
+
|
|
19
|
+
## Getting Started
|
|
20
|
+
|
|
21
|
+
### Install Config
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install @dsmrt/axiom-config
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Config Usage
|
|
28
|
+
|
|
29
|
+
#### Example
|
|
30
|
+
|
|
31
|
+
1. Add your config to the base of your project
|
|
32
|
+
|
|
33
|
+
Your project file structure
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
.
|
|
37
|
+
├── .axiom.dev.js
|
|
38
|
+
├── .axiom.js
|
|
39
|
+
├── README.md
|
|
40
|
+
├── package.json
|
|
41
|
+
├── src
|
|
42
|
+
│ └── config.ts
|
|
43
|
+
│ └── index.ts
|
|
44
|
+
└── tsconfig.json
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Prod Config
|
|
48
|
+
|
|
49
|
+
```js
|
|
50
|
+
// .axiom.js
|
|
51
|
+
const config = {
|
|
52
|
+
name: "my-prod-app",
|
|
53
|
+
env: "prod",
|
|
54
|
+
aws: {
|
|
55
|
+
account: "prod-account",
|
|
56
|
+
profile: "prod-profile",
|
|
57
|
+
region: "us-east-1",
|
|
58
|
+
// baseParameterPath can be used to secrets using ssm parameters (secure strings)
|
|
59
|
+
baseParameterPath: "/my-app/prod",
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
module.exports = config;
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Dev Config
|
|
66
|
+
|
|
67
|
+
```js
|
|
68
|
+
// .axiom.dev.js
|
|
69
|
+
|
|
70
|
+
const config = {
|
|
71
|
+
name: "my-prod-app",
|
|
72
|
+
env: "dev",
|
|
73
|
+
aws: {
|
|
74
|
+
account: "dev-account",
|
|
75
|
+
profile: "dev-profile",
|
|
76
|
+
region: "us-north-1",
|
|
77
|
+
baseParameterPath: "/my-app/dev",
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
module.exports = config;
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Adding configs for your application based on your needs
|
|
85
|
+
|
|
86
|
+
```typescript
|
|
87
|
+
// ./config.ts
|
|
88
|
+
// within your code
|
|
89
|
+
|
|
90
|
+
import { Config } from "@dsmrt/axiom-config"
|
|
91
|
+
|
|
92
|
+
export interface MyAppConfig extends Config {
|
|
93
|
+
appDomain: string;
|
|
94
|
+
appAcmCertArn: string;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Load the config within AWS CDK or your node application
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
import { MyAppConfig } from "./config"
|
|
103
|
+
import { loadConfig } from "@dsmrt/axiom-config"
|
|
104
|
+
|
|
105
|
+
const config = loadConfig<MyAppConfig>();
|
|
106
|
+
|
|
107
|
+
// or for dev
|
|
108
|
+
const config = loadConfig<MyAppConfig>({
|
|
109
|
+
env: "dev"
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
console.log(config.appDomain);
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Acknowledgements
|
|
116
|
+
|
|
117
|
+
- [Nate Iler](https://github.com/nateiler)
|
|
118
|
+
- [Flipbox Digital](https://www.flipboxdigital.com)
|
|
119
|
+
- [Go Mondo](https://www.flipboxdigital.com)
|
package/lib/index.d.ts
CHANGED
|
@@ -4,11 +4,12 @@ export interface AwsConfigs {
|
|
|
4
4
|
profile: string;
|
|
5
5
|
baseParameterPath: string;
|
|
6
6
|
}
|
|
7
|
-
export interface
|
|
7
|
+
export interface BaseConfig {
|
|
8
8
|
name: string;
|
|
9
9
|
env: string;
|
|
10
10
|
aws: AwsConfigs;
|
|
11
11
|
}
|
|
12
|
+
export type Config<T = object> = T & BaseConfig;
|
|
12
13
|
export interface LoadConfigInput {
|
|
13
14
|
/**
|
|
14
15
|
* defaults to prod
|
|
@@ -24,7 +25,7 @@ export interface LoadConfigInput {
|
|
|
24
25
|
cwd?: string;
|
|
25
26
|
}
|
|
26
27
|
export declare const importConfigFromPath: (path: string) => Config;
|
|
27
|
-
export declare const loadConfig: <T extends object>(input?: LoadConfigInput) =>
|
|
28
|
+
export declare const loadConfig: <T extends object>(input?: LoadConfigInput) => object & BaseConfig & T;
|
|
28
29
|
/**
|
|
29
30
|
* Simple object check.
|
|
30
31
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dsmrt/axiom-config",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "Config library for axiom cli",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
"lint:fix": "eslint ./src/ --ext .ts --fix",
|
|
43
43
|
"test": "vitest run --coverage -c ./vitest.config.ts",
|
|
44
44
|
"watch": "vitest watch --coverage -c ./vitest.config.ts",
|
|
45
|
-
"build": "tsc -d -p ./tsconfig.json"
|
|
45
|
+
"build": "tsc -d -p ./tsconfig.json",
|
|
46
|
+
"version:patch": "pnpm version patch"
|
|
46
47
|
}
|
|
47
48
|
}
|