Skip to content

Instantly share code, notes, and snippets.

@matthewhudson
Last active September 17, 2019 10:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthewhudson/a8f53284feee997dea8d9cf1573f894b to your computer and use it in GitHub Desktop.
Save matthewhudson/a8f53284feee997dea8d9cf1573f894b to your computer and use it in GitHub Desktop.
OMG & @webpipe/server interface idea
const WebPipeServer = require('@webpipe/server');
// Automatically exposes service definition
// Automatically exposes `/health` checkpoint
module.exports = new WebPipeServer()
// .enableDevelopmentMode() // This line enables dev mode
// .enableMonitorMode() // This line enables monitor mode
.configureEnvironment(environment => {
environment.setVariable()
// environment.setPort()
// environment.setHost()
})
.configurePolicies(policy => {
// Configure policies by using the `policy` object
policy.outboundHttp.allowGet(
'
)
})
.setHandlerName('handler')
.setHandlerFile(`${__dirname}/handler.js`)
.run()
const OMG = require('@omg/service');
// Automatically exposes service definition
// Automatically exposes `/health` checkpoint
module.exports = new OMG()
// .enableDevelopmentMode() // This line enables dev mode
// .enableMonitorMode() // This line enables monitor mode
.configureEnvironment(environment => {
environment.setVariable()
// environment.setPort()
// environment.setHost()
})
.configurePolicies(policy => {
// OMG should set up internally based on routes?
// Configure policies by using the `policy` object
policy.outboundHttp.allowGet(
''
)
})
.configureInput(input => {
// Use JOI for
input.setName('x').setType('number').setDescription('...')
input.setName('y').setType('number').setDescription('...')
})
.setHandlerName('handler') // Cruft, this should be the default
.setHandlerFile(`${__dirname}/index.js`) // Cruft, this should be the default
.run()
/**
* Interface assumes
*
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment