Package Exports
- rpc-typescript
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (rpc-typescript) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
rpc-typescript
[Work In Progress] An RPC library for TypeScript.
It's an annotation-based library for RPC with different transport protocols.
Supported transports are:
- HTTP
- Electron (host/renderer RPC)
- Loopback
Syntax
The desired final work is like the following (still not implemented):
On server
@StubContract({
transport: 'loopback'
})
export class LoopbackServer {
@StubMethod()
public async foo(): Promise<string> {
return "Hello from foo";
}
}On client
@ProxyContract({
transport: 'loopback'
})
export class LoopbackClient {
@ProxyMethod()
public foo(): Promise<string> {
throw new RpcMethod('foo');
}
}
// Somewhere else:
const client = ProxyContext.getChannel<LoopbackClient>(LoopbackClient); //or pass 'LoopbackClient'
const result = await client.foo();
expect(result)
.toBe("Hello from foo");HTTP
On the servers' side, while using the express, you should do this:
import { ExpressMiddleware } from 'rpc-typescript';
app.use(new ExpressMiddleware());