@travetto/web-rpc 8.0.0-alpha.19 → 8.0.0-alpha.21
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 +8 -3
- package/package.json +4 -4
- package/support/cli.web_rpc-client.ts +4 -1
- package/support/client/rpc.ts +0 -7
package/README.md
CHANGED
|
@@ -16,21 +16,26 @@ yarn add @travetto/web-rpc
|
|
|
16
16
|
This module allows for a highly focused scenario, of supporting RPC operations within a [Web API](https://github.com/travetto/travetto/tree/main/module/web#readme "Declarative support for creating Web Applications") application. The module takes care of producing the appropriate handler for the RPC commands along with the ability to generate the appropriate client to be used to interact with the RPC functionality. The generated client uses Proxy-based objects, along with [Typescript](https://typescriptlang.org) magic to create a dynamic client that does not rely on generating a lot of code.
|
|
17
17
|
|
|
18
18
|
## CLI - web:rpc-client
|
|
19
|
-
|
|
19
|
+
Generate web-rpc client artifacts from a specified provider or leveraging local config.
|
|
20
20
|
|
|
21
|
-
**Terminal:
|
|
21
|
+
**Terminal: Help for web:rpc-client**
|
|
22
22
|
```bash
|
|
23
23
|
$ trv web:rpc-client --help
|
|
24
24
|
|
|
25
25
|
Usage: web:rpc-client [options] <type:config|node|web> [output:string]
|
|
26
26
|
|
|
27
|
+
Generate web-rpc client artifacts from a specified provider or leveraging local config.
|
|
28
|
+
|
|
29
|
+
Resolves generator services from DI and writes typed client code for the
|
|
30
|
+
selected provider target.
|
|
31
|
+
|
|
27
32
|
Options:
|
|
28
33
|
-p, --profile <string> Application profiles
|
|
29
34
|
-m, --module <module> Module to run for
|
|
30
35
|
--help display help for command
|
|
31
36
|
```
|
|
32
37
|
|
|
33
|
-
|
|
38
|
+
### Example
|
|
34
39
|
|
|
35
40
|
**Code: Example Controller**
|
|
36
41
|
```typescript
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/web-rpc",
|
|
3
|
-
"version": "8.0.0-alpha.
|
|
3
|
+
"version": "8.0.0-alpha.21",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "RPC support for a Web Application",
|
|
6
6
|
"keywords": [
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"directory": "module/web-rpc"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@travetto/config": "^8.0.0-alpha.
|
|
31
|
-
"@travetto/schema": "^8.0.0-alpha.
|
|
32
|
-
"@travetto/web": "^8.0.0-alpha.
|
|
30
|
+
"@travetto/config": "^8.0.0-alpha.17",
|
|
31
|
+
"@travetto/schema": "^8.0.0-alpha.17",
|
|
32
|
+
"@travetto/web": "^8.0.0-alpha.18"
|
|
33
33
|
},
|
|
34
34
|
"travetto": {
|
|
35
35
|
"displayName": "Web RPC Support"
|
|
@@ -10,7 +10,10 @@ import type { WebRpcClient } from '../src/config.ts';
|
|
|
10
10
|
import { WebRpcClientGeneratorService } from '../src/service.ts';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* Generate
|
|
13
|
+
* Generate web-rpc client artifacts from a specified provider or leveraging local config.
|
|
14
|
+
*
|
|
15
|
+
* Resolves generator services from DI and writes typed client code for the
|
|
16
|
+
* selected provider target.
|
|
14
17
|
*/
|
|
15
18
|
@CliCommand()
|
|
16
19
|
export class CliWebRpcCommand implements CliCommandShape {
|
package/support/client/rpc.ts
CHANGED
|
@@ -109,13 +109,7 @@ function registerTimeout<T>(
|
|
|
109
109
|
|
|
110
110
|
function buildRequest<T extends RequestInit>(base: T, controller: string, endpoint: string): T {
|
|
111
111
|
let verb: string;
|
|
112
|
-
let browserRedirect = false;
|
|
113
112
|
switch (endpoint.split(/[A-Z]/)[0]) {
|
|
114
|
-
case 'redirect': {
|
|
115
|
-
verb = 'GET';
|
|
116
|
-
browserRedirect = true;
|
|
117
|
-
break;
|
|
118
|
-
}
|
|
119
113
|
case 'get': verb = 'GET'; break;
|
|
120
114
|
case 'update': verb = 'PUT'; break;
|
|
121
115
|
case 'delete': verb = 'DELETE'; break;
|
|
@@ -123,7 +117,6 @@ function buildRequest<T extends RequestInit>(base: T, controller: string, endpoi
|
|
|
123
117
|
}
|
|
124
118
|
return {
|
|
125
119
|
...base,
|
|
126
|
-
browserRedirect,
|
|
127
120
|
method: verb,
|
|
128
121
|
path: `${controller}:${endpoint}`,
|
|
129
122
|
controller,
|