Skip to content

Commit

Permalink
updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
jwerre committed Nov 2, 2023
1 parent f322efe commit 0d77093
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,17 @@ npm install --save @jwerre/secrets
### Get all secrets

```js
const config = require('secrets').configSync({
const {configSync} = require('@jwerre/secrets');

// Retrieve all secrets that begin with 'my-project/production/'
const config = configSync({
region: 'us-east-1',
namespace: 'my-project',
env: 'production'
});
```

#### Result:
```js
{
name: 'My App'
Expand All @@ -42,28 +48,29 @@ const config = require('secrets').configSync({
Loading _all_ your secrets may not always be the best option. It's much faster to load a single secret like this:

```js
const config = require('secrets').secretSync({
region: 'us-east-2',
id: '/my-co/apis/',
});
const {secretSync} = require('@jwerre/secrets')
const dbCredentials = secretSync({ region: 'us-east-1', id: '/my-project/production/db' });
```

#### Result:
```js
{
username: 'admin',
password: 'Super$ercret!'
}
```


### Asynchronously get all secrets

In most cases, you'll want to get your configuration object synchronously since your app probably won't run without it. But, if you prefer, you can also get your secrets asynchronously.
In most cases, you'll want to get your configuration object synchronously before your application starts up. But, if you prefer, you can also get your secrets asynchronously like this.

```js
const {config} = require('secrets');
const {config} = require('@jwerre/secrets');

( async function(){

let appConfig;

try {
appConfig = await config(options);
} else (err) {
return Promise.reject(err)
}
const appConfig = await config(options);

})();
```
Expand Down Expand Up @@ -119,7 +126,7 @@ If you plan on using any of the higher level methods or any of the CLI tools in
You may want to access the higher level API which can be done like this:

```js
const { Secrets } = require('secrets');
const { Secrets } = require('@jwerre/secrets');
const secret = new Secrets(options);
const config = secrets.configSync();
```
Expand Down

0 comments on commit 0d77093

Please sign in to comment.