Skip to content

Commit aa7f678

Browse files
committed
.
0 parents  commit aa7f678

12 files changed

+8026
-0
lines changed

.editorconfig

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# EditorConfig is awesome: http://EditorConfig.org
2+
3+
root = true
4+
5+
[*]
6+
indent_size = 2
7+
indent_style = space
8+
end_of_line = lf
9+
charset = utf-8
10+
trim_trailing_whitespace = true
11+
insert_final_newline = true

.eslintrc.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module.exports = {
2+
parser: "@typescript-eslint/parser",
3+
extends: [
4+
"plugin:react/recommended",
5+
"plugin:@typescript-eslint/recommended",
6+
"prettier/@typescript-eslint",
7+
"plugin:prettier/recommended"
8+
],
9+
parserOptions: {
10+
ecmaVersion: 2018,
11+
sourceType: "module"
12+
}
13+
};

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules/
2+
coverage/
3+
.DS_Store
4+
npm-debug.log
5+
dist/
6+
dist.es2015/

.travis.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
language: node_js
2+
3+
notifications:
4+
email:
5+
on_success: never
6+
on_failure: change
7+
8+
node_js:
9+
- "10"
10+
- stable
11+
12+
after_script:
13+
- npm install coveralls@2
14+
- cat ./coverage/lcov.info | coveralls

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2020 Blake Embrey ([email protected])
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# JSON RPC
2+
3+
[![NPM version][npm-image]][npm-url]
4+
[![NPM downloads][downloads-image]][downloads-url]
5+
[![Build status][travis-image]][travis-url]
6+
[![Test coverage][coveralls-image]][coveralls-url]
7+
8+
> Tiny, type-safe [JSON-RPC 2.0](https://www.jsonrpc.org/specification) implementation.
9+
10+
## Installation
11+
12+
```sh
13+
npm install @borderlesslabs/json-rpc --save
14+
15+
# Peer dependencies.
16+
npm install io-ts fp-ts --save
17+
```
18+
19+
## Usage
20+
21+
```ts
22+
import { createHandler } from "@borderlesslabs/json-rpc";
23+
import * as t from "io-ts";
24+
25+
const rpc = createRpc(
26+
{
27+
hello: {
28+
// `request` is required, even when empty.
29+
request: t.type({}),
30+
response: t.string
31+
},
32+
echo: {
33+
// Specify `request` parameters as keys of the object.
34+
request: t.type({ arg: t.string }),
35+
response: t.string
36+
}
37+
},
38+
{
39+
hello: _ => "Hello World!",
40+
echo: ({ arg }) => arg
41+
}
42+
);
43+
44+
const res = await rpc({
45+
jsonrpc: "2.0",
46+
id: "test",
47+
method: "hello"
48+
}); //=> { jsonrpc: "2.0", id: "test", result: "Hello World!" }
49+
```
50+
51+
## License
52+
53+
MIT
54+
55+
[npm-image]: https://img.shields.io/npm/v/@borderlesslabs/json-rpc.svg?style=flat
56+
[npm-url]: https://npmjs.org/package/@borderlesslabs/json-rpc
57+
[downloads-image]: https://img.shields.io/npm/dm/@borderlesslabs/json-rpc.svg?style=flat
58+
[downloads-url]: https://npmjs.org/package/@borderlesslabs/json-rpc
59+
[travis-image]: https://img.shields.io/travis/BorderlessLabs/json-rpc.svg?style=flat
60+
[travis-url]: https://travis-ci.org/BorderlessLabs/json-rpc
61+
[coveralls-image]: https://img.shields.io/coveralls/BorderlessLabs/json-rpc.svg?style=flat
62+
[coveralls-url]: https://coveralls.io/r/BorderlessLabs/json-rpc?branch=master

0 commit comments

Comments
 (0)