Skip to content

Latest commit

 

History

History
97 lines (78 loc) · 2.25 KB

README.md

File metadata and controls

97 lines (78 loc) · 2.25 KB

Classes

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.

Typedefs

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

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

new Server(methods)

Create server

Param Type
methods MethodMap

server.app()

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())

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.

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')
     }
}