https://github.com/adriano-di-giovanni/express-jr2
Create a JSON-RPC 2.0 compliant HTTP server with jr2 and Express
https://github.com/adriano-di-giovanni/express-jr2
express-jr2 express-middleware jr2 json-rpc2
Last synced: 5 months ago
JSON representation
Create a JSON-RPC 2.0 compliant HTTP server with jr2 and Express
- Host: GitHub
- URL: https://github.com/adriano-di-giovanni/express-jr2
- Owner: adriano-di-giovanni
- Created: 2018-01-03T17:40:56.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-01-23T15:09:10.000Z (over 7 years ago)
- Last Synced: 2025-01-12T05:25:26.695Z (6 months ago)
- Topics: express-jr2, express-middleware, jr2, json-rpc2
- Language: JavaScript
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# jr2 HTTP Server Middleware
Create a [JSON-RPC 2.0](http://www.jsonrpc.org/specification) compliant HTTP server with [jr2](https://github.com/adriano-di-giovanni/jr2) and [Express](http://expressjs.com/).
## Installation
```bash
npm install --save express-jr2
```## Setup
```javascript
const express = require('express')
const bodyParser = require('body-parser')
const jr2HTTP = require('express-jr2')const delegate = {
sum(params, { responseWithResult }, callback) {
const result = params.reduce((a, b) => a + b, 0)
callback(null, responseWithResult(result))
},
}
const app = express()app
.use(bodyParser.json())
.use('/rpc', jr2HTTP(delegate))app.listen(3000)
```## License
MIT