srpc-framework

4.0.3 • Public • Published

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)

Package Sidebar

Install

npm i srpc-framework

Weekly Downloads

2

Version

4.0.3

License

ISC

Unpacked Size

350 kB

Total Files

7

Last publish

Collaborators

  • piliponful