@scaleway/configuration-loader 0.1.0-alpha.2 → 0.1.0-alpha.5
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 +57 -0
- package/dist/index.d.ts +1 -1
- package/package.json +3 -3
package/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Configuration Loader
|
|
2
|
+
|
|
3
|
+
Scaleway is a single way to create, deploy and scale your infrastructure in the cloud.
|
|
4
|
+
|
|
5
|
+
This package enables you to load a profile from a configuration file or environment variables.
|
|
6
|
+
|
|
7
|
+
**🔗 Important links:**
|
|
8
|
+
* [Scaleway SDK](./sdk)
|
|
9
|
+
* [Developers website](https://developers.scaleway.com) (API documentation)
|
|
10
|
+
|
|
11
|
+
## Getting Started
|
|
12
|
+
|
|
13
|
+
You could hardcode a profile directly within your code:
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
const profile = {
|
|
17
|
+
accessKey: 'SCWXXXXXXXXXXXXXXXXX',
|
|
18
|
+
secretKey: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
|
|
19
|
+
defaultProjectId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
|
|
20
|
+
defaultRegion: 'fr-par',
|
|
21
|
+
defaultZone: 'fr-par-1',
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
And then use this profile to instanciate the [SDK](./sdk) client with `const client = createClient(profile)`.
|
|
26
|
+
|
|
27
|
+
However, you might prefer to store these variables in either a configuration file (e.g. local testing) or environment variables (e.g. serverless).
|
|
28
|
+
|
|
29
|
+
**In case of configuration file**:
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import {
|
|
33
|
+
loadProfileFromConfigurationFile,
|
|
34
|
+
} from '@scaleway/configuration-loader'
|
|
35
|
+
|
|
36
|
+
const profile = loadProfileFromConfigurationFile()
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
For a specific profile:
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
const profile = loadProfileFromEnvironmentValues({ profileName: 'debug' })
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**In case of environment variables**:
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import {
|
|
49
|
+
loadProfileFromEnvironmentValues,
|
|
50
|
+
} from '@scaleway/configuration-loader'
|
|
51
|
+
|
|
52
|
+
const profile = loadProfileFromEnvironmentValues()
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Reach us
|
|
56
|
+
|
|
57
|
+
We love feedback. Feel free to reach us on [Scaleway Slack community](https://slack.scaleway.com/), we are waiting for you on [#opensource](https://scaleway-community.slack.com/app_redirect?channel=opensource).
|
package/dist/index.d.ts
CHANGED
|
@@ -81,6 +81,6 @@ declare const loadProfileFromEnvironmentValues: () => Profile;
|
|
|
81
81
|
*
|
|
82
82
|
* @public
|
|
83
83
|
*/
|
|
84
|
-
declare const loadProfileFromConfigurationFile: (params?: Readonly<ProfileFromFileParams>
|
|
84
|
+
declare const loadProfileFromConfigurationFile: (params?: Readonly<ProfileFromFileParams>) => Profile;
|
|
85
85
|
|
|
86
86
|
export { Profile, ProfileFromFileParams, loadProfileFromConfigurationFile, loadProfileFromEnvironmentValues };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scaleway/configuration-loader",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.5",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Load configuration via file or environment for NodeJS.",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"type": "module",
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@types/node": "^17.0.
|
|
21
|
+
"@types/node": "^17.0.36"
|
|
22
22
|
},
|
|
23
|
-
"gitHead": "
|
|
23
|
+
"gitHead": "b0867328654a44d7eb69e41e7f0330c4249f6762"
|
|
24
24
|
}
|