
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)