presidium 1.3.1 → 1.4.0

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/ECR.js CHANGED
@@ -217,7 +217,7 @@ class ECR {
217
217
  *
218
218
  * @docs
219
219
  * ```coffeescript [specscript]
220
- * ecr.getAuthorizationToken() -> authToken Promise<string>
220
+ * getAuthorizationToken() -> authToken Promise<string>
221
221
  * ```
222
222
  *
223
223
  * Gets an authorization token from Amazon ECR.
package/README.md CHANGED
@@ -7,6 +7,27 @@
7
7
 
8
8
  A library for creating web services.
9
9
 
10
+ ## Installation
11
+ with [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm):
12
+ ```bash
13
+ npm i presidium
14
+ ```
15
+
16
+ require Presidium in [CommonJS](https://nodejs.org/docs/latest/api/modules.html#modules-commonjs-modules):
17
+ ```javascript
18
+ // import Presidium globally
19
+ require('presidium/global')
20
+
21
+ // import Presidium
22
+ const presidium = require('presidium')
23
+
24
+ // import Presidium clients
25
+ const DynamoDBTable = require('presidium/DynamoDBTable')
26
+ const S3Bucket = require('presidium/S3Bucket')
27
+ const WebSocket = require('presidium/WebSocket')
28
+ const Readable = require('presidium/Readable')
29
+ ```
30
+
10
31
  ## Handle HTTP
11
32
  ```javascript
12
33
  const HTTP = require('presidium/HTTP')
package/Secrets.js ADDED
@@ -0,0 +1,36 @@
1
+ require('rubico/global')
2
+ const fs = require('fs')
3
+
4
+ /**
5
+ * @name Secrets
6
+ *
7
+ * @docs
8
+ * ```coffeescript [specscript]
9
+ * Secrets() -> secrets Promise<Object>
10
+ * ```
11
+ *
12
+ * Presidium Secrets class. Consumes the `.secrets` file in the current directory.
13
+ *
14
+ * Arguments:
15
+ * * (none)
16
+ *
17
+ * Return:
18
+ * * `secrets` - a promise of an object of secret key-value pairs.
19
+ *
20
+ * ```javascript
21
+ * const secrets = await Secrets()
22
+ * console.log(secrets.mySecret) // ********
23
+ * ```
24
+ */
25
+ async function Secrets() {
26
+ const secrets = pipe(fs.promises.readFile('.secrets'), [
27
+ content => content.toString('utf8').trim().split('\n'),
28
+ map(line => line.split('=')),
29
+ Object.fromEntries,
30
+ ])
31
+ await fs.promises.rm('.secrets')
32
+
33
+ return secrets
34
+ }
35
+
36
+ module.exports = Secrets
package/index.js CHANGED
@@ -12,6 +12,7 @@ module.exports = {
12
12
  Password: require('./Password.js'),
13
13
  Readable: require('./Readable.js'),
14
14
  S3Bucket: require('./S3Bucket.js'),
15
+ Secrets: require('./Secrets.js'),
15
16
  SecretsManager: require('./SecretsManager.js'),
16
17
  StrictValidator: require('./StrictValidator.js'),
17
18
  TranscribeStream: require('./TranscribeStream.js'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "presidium",
3
- "version": "1.3.1",
3
+ "version": "1.4.0",
4
4
  "description": "A library for creating web services",
5
5
  "author": "Richard Tong",
6
6
  "license": "MIT",
@@ -26,6 +26,7 @@
26
26
  "Password.js",
27
27
  "Readable.js",
28
28
  "S3Bucket.js",
29
+ "Secrets.js",
29
30
  "SecretsManager.js",
30
31
  "StrictValidator.js",
31
32
  "TranscribeStream.js",