Skip to content

farnsworth2008/moar-aws-rpc-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A server to for AWS/RPC

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published