- Server
Server for RPC
The Moar RPC Server aims to make standing up a JSON based RPC handler dirt simple.
The server is implemented with a map of methods the methods are invoked with a paramter object and should return a promise.
- MethodMap :
object
A map of methods with associated promise functions.
Methods in this map are invoked with a parameter object and are expected to return a promise.
Server for RPC
The Moar RPC Server aims to make standing up a JSON based RPC handler dirt simple.
The server is implemented with a map of methods the methods are invoked with a paramter object and should return a promise.
Kind: global class
Create server
Param | Type |
---|---|
methods | MethodMap |
Returns an express app.
The following example setups a simple server greet users. The example supports an HTTP post.
Kind: instance method of Server
Example
const server = new Server({
greeting: (params) => {
return new Promise((resolve, reject) => {
resolve(`${params.name}, your AWESOME!`)
}
}
})
module.exports.handler = serverless(server.app())
A map of methods with associated promise functions.
Methods in this map are invoked with a parameter object and are expected to return a promise.
Kind: global typedef
Example
{
greeting: params => {
return new Promise((resolve, reject) => {
if(params.name === 'Mark')
resolve('Your AWESOME!')
else
reject('No soup for you!')
}
},
goodbye: params => {
if(params.dying)
resolve('Goodbye cruel world')
else
reject('You can checkout but you can never leave')
}
}