allserver 2.4.1 → 2.5.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/README.md +3 -0
- package/package.json +1 -1
- package/src/client/AllserverClient.js +5 -4
- package/src/server/Allserver.js +15 -6
- package/src/util.js +1 -0
package/README.md
CHANGED
|
@@ -6,8 +6,11 @@ Think of Remote Procedure Calls using exactly the same client and server code bu
|
|
|
6
6
|
|
|
7
7
|
Should be used in (micro)services where JavaScript is able to run - your computer, Docker, k8s, virtual machines, serverless functions (Lambdas, Google Cloud Functions, Azure Functions, etc), RaspberryPI, SharedWorker, thread, you name it.
|
|
8
8
|
|
|
9
|
+
> Uber [moved](https://www.infoq.com/news/2023/10/uber-up-cloud-microservices/) most of its containerized microservices from µDeploy to a new multi-cloud platform named Up in preparation for migrating a considerable portion of its compute footprint to the cloud. **The company spent two years** working on making its many microservices portable to migrate between different computing infrastructures and container management platforms.
|
|
10
|
+
|
|
9
11
|
Superpowers the `Allserver` gives you:
|
|
10
12
|
|
|
13
|
+
- Move your code around infrastructures, deployment types, runtimes, platforms, etc with ease.
|
|
11
14
|
- Call gRPC server methods from browser/curl/Postman.
|
|
12
15
|
- Run your HTTP server as gRPC with a single line change (almost).
|
|
13
16
|
- Serve same logic via HTTP and gRPC (or more) simultaneously in the same node.js process.
|
package/package.json
CHANGED
|
@@ -203,8 +203,8 @@ module.exports = require("stampit")({
|
|
|
203
203
|
this[p].transport = getTransport()({ uri });
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
if (before) this[p].before = [].concat(
|
|
207
|
-
if (after) this[p].after = [].concat(
|
|
206
|
+
if (before) this[p].before = [].concat(this[p].before).concat(before).filter(isFunction);
|
|
207
|
+
if (after) this[p].after = [].concat(this[p].after).concat(after).filter(isFunction);
|
|
208
208
|
},
|
|
209
209
|
|
|
210
210
|
methods: {
|
|
@@ -335,8 +335,9 @@ module.exports = require("stampit")({
|
|
|
335
335
|
before,
|
|
336
336
|
after,
|
|
337
337
|
} = {}) {
|
|
338
|
-
if (before) before = [].
|
|
339
|
-
if (after) after = [].
|
|
338
|
+
if (before != null) before = (Array.isArray(before) ? before : [before]).filter(isFunction);
|
|
339
|
+
if (after != null) after = (Array.isArray(after) ? after : [after]).filter(isFunction);
|
|
340
|
+
|
|
340
341
|
return this.deepProps({
|
|
341
342
|
[p]: {
|
|
342
343
|
transport,
|
package/src/server/Allserver.js
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
const assert = require("assert");
|
|
2
2
|
|
|
3
|
-
const { isObject, isBoolean, isFunction } = require("../util");
|
|
3
|
+
const { isObject, isBoolean, isFunction, uniq } = require("../util");
|
|
4
4
|
|
|
5
5
|
module.exports = require("stampit")({
|
|
6
6
|
name: "Allserver",
|
|
7
7
|
|
|
8
|
+
deepProps: {
|
|
9
|
+
before: null,
|
|
10
|
+
after: null,
|
|
11
|
+
},
|
|
12
|
+
|
|
8
13
|
props: {
|
|
9
14
|
procedures: {},
|
|
10
15
|
transport: null,
|
|
11
16
|
logger: console,
|
|
12
17
|
introspection: true,
|
|
13
|
-
before: null,
|
|
14
|
-
after: null,
|
|
15
18
|
|
|
16
19
|
callsCount: 0,
|
|
17
20
|
},
|
|
@@ -21,8 +24,8 @@ module.exports = require("stampit")({
|
|
|
21
24
|
this.transport = transport || this.transport || require("./HttpTransport")();
|
|
22
25
|
this.logger = logger || this.logger;
|
|
23
26
|
this.introspection = introspection != null ? introspection : this.introspection;
|
|
24
|
-
this.before =
|
|
25
|
-
this.after =
|
|
27
|
+
if (before) this.before = uniq([].concat(this.before).concat(before).filter(isFunction));
|
|
28
|
+
if (after) this.after = uniq([].concat(this.after).concat(after).filter(isFunction));
|
|
26
29
|
|
|
27
30
|
this._validateProcedures();
|
|
28
31
|
},
|
|
@@ -178,7 +181,13 @@ module.exports = require("stampit")({
|
|
|
178
181
|
|
|
179
182
|
statics: {
|
|
180
183
|
defaults({ procedures, transport, logger, introspection, before, after } = {}) {
|
|
181
|
-
|
|
184
|
+
if (before != null) before = (Array.isArray(before) ? before : [before]).filter(isFunction);
|
|
185
|
+
if (after != null) after = (Array.isArray(after) ? after : [after]).filter(isFunction);
|
|
186
|
+
|
|
187
|
+
return this.compose({
|
|
188
|
+
props: { procedures, transport, logger, introspection },
|
|
189
|
+
deepProps: { before, after },
|
|
190
|
+
});
|
|
182
191
|
},
|
|
183
192
|
},
|
|
184
193
|
});
|