Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/qiwi/json-rpc
Tools, utils and helpers for JSON RPC 2.0 integration
https://github.com/qiwi/json-rpc
js-platform json-rpc nestjs
Last synced: 4 days ago
JSON representation
Tools, utils and helpers for JSON RPC 2.0 integration
- Host: GitHub
- URL: https://github.com/qiwi/json-rpc
- Owner: qiwi
- License: mit
- Created: 2019-10-03T10:06:26.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-03-08T01:44:37.000Z (over 1 year ago)
- Last Synced: 2024-10-29T20:53:22.251Z (17 days ago)
- Topics: js-platform, json-rpc, nestjs
- Language: TypeScript
- Homepage:
- Size: 2.84 MB
- Stars: 14
- Watchers: 7
- Forks: 2
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @qiwi/json-rpc
Tools, utils and helpers for [JSON RPC 2.0](https://www.jsonrpc.org) integration.* [nestjs-json-rpc](./packages/nestjs/README.md)
* [expressjs-json-rpc](./packages/expressjs/README.md)## Status
🚧 Work in progress 🚧 / Experimental / Early preview / pre-alpha version / 0.0.0-draft## Usage
With [Nestjs](https://nestjs.com/):
```typescript
import {
JsonRpcController,
JsonRpcMethod,
IJsonRpcId,
IJsonRpcParams
} from 'nestjs-json-rpc'@JsonRpcController('/jsonrpc/endpoint')
export class SomeJsonRpcController {
@JsonRpcMethod('some-method')
doSomething(@JsonRpcId() id: IJsonRpcId, @JsonRpcParams() params: IJsonRpcParams) {
const {foo} = params
if (foo === 'bar') {
return new JsonRpcError(-100, '"foo" param should not be equal "bar"')
}
return 'ok'
}
}// App.ts
@Module({
imports: [...],
controllers: [SomeJsonRpcController],
providers: [...],
})
export class AppModule {}
```With [Express](https://expressjs.com/):
```typescript
import {
JsonRpcMiddleware,
JsonRpcMethod,
IJsonRpcId,
IJsonRpcParams
} from 'expressjs-json-rpc'@JsonRpcMiddleware()
export class SomeJsonRpcMware {
@JsonRpcMethod('some-method')
doSomething(@JsonRpcId() id: IJsonRpcId, @JsonRpcParams() params: IJsonRpcParams) {
const {foo} = params
if (foo === 'bar') {
return new JsonRpcError(-100, '"foo" param should not be equal "bar"')
}
return 'ok'
}
}const jsonRpcMware = new SomeJsonRpcMware().middleware
app.use('/rpc', jsonRpcMware)
```## Specification
[https://www.jsonrpc.org/specification](https://www.jsonrpc.org/specification)## License
[MIT](./LICENSE)