Skip to content

Create a JSON-RPC 2.0 compliant HTTP server with jr2 and Express

Notifications You must be signed in to change notification settings

adriano-di-giovanni/express-jr2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jr2 HTTP Server Middleware

Create a JSON-RPC 2.0 compliant HTTP server with jr2 and Express.

Installation

npm install --save express-jr2

Setup

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

About

Create a JSON-RPC 2.0 compliant HTTP server with jr2 and Express

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published