srpc-framework

JSON-RPC over HTTP web 'framework'


Keywords
web, app, http, application, framework, middleware, rack
License
ISC
Install
npm install srpc-framework@5.0.0

Documentation

JavaScript Style Guide

Link to npm package

Usage

const { createServer as createSrpcServer, callFunction } = require('srpc-framework')

const { createServer } = require('http') // or https

const functions = { add: ({ a, b }) => a + b }

const port = 8080
const onStartText = `Server successfully launched on port ${port}`

const handleErrors = result => {
  if (result.error) {
    console.log(error)

    return 'Internal Server Error'
  }

  return result
}

const { listen: startServer } = createServer({ functions, createServer, callFunction: compose(callFunction, handleErrors) })

startServer(port, onStartText)