@forwardimpact/librpc 0.1.77 → 0.1.79
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/bin/fit-unary.js +32 -0
- package/package.json +7 -1
package/bin/fit-unary.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createClient, createTracer } from "@forwardimpact/librpc";
|
|
3
|
+
import { createLogger } from "@forwardimpact/libtelemetry";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Makes a unary gRPC call to a service
|
|
7
|
+
* Usage: fit-unary <service> <method> [json-request]
|
|
8
|
+
* @returns {Promise<void>}
|
|
9
|
+
*/
|
|
10
|
+
async function main() {
|
|
11
|
+
const [service, method, requestJson] = process.argv.slice(2);
|
|
12
|
+
if (!service || !method) {
|
|
13
|
+
console.error("Usage: fit-unary <service> <method> [json-request]");
|
|
14
|
+
console.error(
|
|
15
|
+
'Example: fit-unary memory GetWindow \'{"resource_id":"..."}\'',
|
|
16
|
+
);
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const request = requestJson ? JSON.parse(requestJson) : {};
|
|
21
|
+
const logger = createLogger("cli");
|
|
22
|
+
const tracer = await createTracer("cli");
|
|
23
|
+
const client = await createClient(service, logger, tracer);
|
|
24
|
+
|
|
25
|
+
const response = await client.callUnary(method, request);
|
|
26
|
+
console.log(JSON.stringify(response, null, 2));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
main().catch((error) => {
|
|
30
|
+
console.error(error.message);
|
|
31
|
+
process.exit(1);
|
|
32
|
+
});
|
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forwardimpact/librpc",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.79",
|
|
4
4
|
"description": "gRPC framework and utilities for Guide",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "D. Olsson <hi@senzilla.io>",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "index.js",
|
|
9
|
+
"bin": {
|
|
10
|
+
"fit-unary": "./bin/fit-unary.js"
|
|
11
|
+
},
|
|
9
12
|
"engines": {
|
|
10
13
|
"node": ">=22.0.0"
|
|
11
14
|
},
|
|
@@ -20,5 +23,8 @@
|
|
|
20
23
|
},
|
|
21
24
|
"devDependencies": {
|
|
22
25
|
"@forwardimpact/libharness": "^0.1.5"
|
|
26
|
+
},
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
23
29
|
}
|
|
24
30
|
}
|