@toa.io/bridges.node 1.0.0-alpha.28 → 1.0.0-alpha.29
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/package.json +5 -5
- package/src/context.js +2 -1
- package/src/shortcuts/amqp.js +3 -2
- package/src/shortcuts/configuration.js +1 -1
- package/src/shortcuts/http.js +1 -1
- package/src/shortcuts/index.js +2 -0
- package/src/shortcuts/pubsub.js +16 -0
- package/src/shortcuts/stash.js +1 -1
- package/src/shortcuts/state.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toa.io/bridges.node",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.29",
|
|
4
4
|
"description": "Toa Node Bridge (inproc)",
|
|
5
5
|
"homepage": "https://toa.io",
|
|
6
6
|
"author": {
|
|
@@ -26,14 +26,14 @@
|
|
|
26
26
|
"test": "echo \"Error: run tests from root\" && exit 1"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@toa.io/core": "1.0.0-alpha.
|
|
30
|
-
"@toa.io/filesystem": "1.0.0-alpha.
|
|
31
|
-
"@toa.io/generic": "1.0.0-alpha.
|
|
29
|
+
"@toa.io/core": "1.0.0-alpha.29",
|
|
30
|
+
"@toa.io/filesystem": "1.0.0-alpha.29",
|
|
31
|
+
"@toa.io/generic": "1.0.0-alpha.29",
|
|
32
32
|
"fast-glob": "3.2.7",
|
|
33
33
|
"matchacho": "0.3.5"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"clone-deep": "4.0.1"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "186d0e17c12a9016b8076edf925963cbb32b9219"
|
|
39
39
|
}
|
package/src/context.js
CHANGED
package/src/shortcuts/amqp.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const { underlay } = require('@toa.io/generic')
|
|
4
|
+
const assert = require('node:assert')
|
|
4
5
|
|
|
5
6
|
/** @type {toa.node.shortcut} */
|
|
6
|
-
|
|
7
|
+
function amqp (context, aspect) {
|
|
7
8
|
context.amqp = underlay(async (segs, args) => {
|
|
8
|
-
|
|
9
|
+
assert(segs.length === 2, `AMQP aspect call should have 2 segments [${segs.join(', ')}] given`)
|
|
9
10
|
|
|
10
11
|
const [origin, method] = segs
|
|
11
12
|
|
package/src/shortcuts/http.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const { underlay } = require('@toa.io/generic')
|
|
4
4
|
|
|
5
5
|
/** @type {toa.node.shortcut} */
|
|
6
|
-
|
|
6
|
+
function http (context, aspect) {
|
|
7
7
|
context.http = underlay(async (segs, args) => {
|
|
8
8
|
if (segs.length < 2) throw new Error(`Origins call requires at least 2 arguments, ${segs.length} given`)
|
|
9
9
|
|
package/src/shortcuts/index.js
CHANGED
|
@@ -6,6 +6,7 @@ const { configuration } = require('./configuration')
|
|
|
6
6
|
const { state } = require('./state')
|
|
7
7
|
const { stash } = require('./stash')
|
|
8
8
|
const { storages } = require('./storages')
|
|
9
|
+
const { pubsub } = require('./pubsub')
|
|
9
10
|
|
|
10
11
|
exports.http = http
|
|
11
12
|
exports.amqp = amqp
|
|
@@ -13,3 +14,4 @@ exports.configuration = configuration
|
|
|
13
14
|
exports.state = state
|
|
14
15
|
exports.stash = stash
|
|
15
16
|
exports.storages = storages
|
|
17
|
+
exports.pubsub = pubsub
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { underlay } = require('@toa.io/generic')
|
|
4
|
+
const assert = require('node:assert')
|
|
5
|
+
|
|
6
|
+
function pubsub (context, aspect) {
|
|
7
|
+
context.pubsub = underlay(async (segs, args) => {
|
|
8
|
+
assert(segs.length === 2, `Pub/Sub aspect call should have 2 segments [${segs.join(', ')}] given`)
|
|
9
|
+
|
|
10
|
+
const [origin, method] = segs
|
|
11
|
+
|
|
12
|
+
return aspect.invoke(method, origin, ...args)
|
|
13
|
+
})
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
exports.pubsub = pubsub
|
package/src/shortcuts/stash.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const { underlay } = require('@toa.io/generic')
|
|
4
4
|
|
|
5
5
|
/** @type {toa.node.shortcut} */
|
|
6
|
-
|
|
6
|
+
function stash (context, aspect) {
|
|
7
7
|
context.stash = underlay(async (segs, args) => {
|
|
8
8
|
if (segs.length !== 1)
|
|
9
9
|
throw new Error(`Stash aspect call should have 1 segment, [${segs.join(', ')}] given`)
|
package/src/shortcuts/state.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const { generate } = require('@toa.io/generic')
|
|
4
4
|
|
|
5
5
|
/** @type {toa.node.shortcut} */
|
|
6
|
-
|
|
6
|
+
function state (context, aspect) {
|
|
7
7
|
context.state = generate((segs, value) => {
|
|
8
8
|
if (value === undefined) return get(aspect, segs)
|
|
9
9
|
else set(aspect, segs, value)
|