iopa-serverless
v1.4.0
Published
API-First Serverless Cloud Function manager for Internet of Things (IoT), based on Internet of Protocols Alliance (IOPA) specification
Downloads
5
Maintainers
Readme
iopa-serverless
About
This repository contains a simple abstaction layer to translate various serverless host environments and localhost to a common open-standards defined request and response context.
The opportunity
Serverless hosts including AWS Lambda, Microsoft Azure Functions and Google Cloud Functions let you run code without provisioning or managing servers. You generally pay only for the compute time you consume - there is usually no charge when your code is not running. You can run code for virtually any type of application or backend service - all with zero administration.
The problem
It is currently not possible to reuse the same codeset across multiple cloud hosts, and yet the functionality provided by the host environment is very similar -- typically providing a request record for the inbound event trigger and a context record for the response. It is also not possible to develop and test locally without additional frameworks that vary based on the target host.
The solution
This libraryprovides a very lightweight abstraction layer to translate the request and response into a format that can be reused regardless of the host environment, and can be used locally just as easily as remotely.
It is now possible to write a single serverless function and host on multiple providers (to optimize pricing, load balance during catastrophic service provider failures etc.)
Middleware/Application Pipeline Builder: AppBuilder
app.use(middleware)
Adds a middleware node to the IOPA function pipeline. The middleware are
invoked in the order they are added: the first middleware passed to app.use
will
be the outermost function, and the last middleware passed to Use will be the
innermost.
example index.js for Azure
const iopaServerless=require('./iopa-serverless'),
demo = require('./demo');
module.exports = iopaCloud.azure(
demo
);
example function.json for Azure
{
"bindings": [
{
"webHookType": "",
"type": "httpTrigger",
"direction": "in",
"name": "req"
},
{
"type": "http",
"direction": "out",
"name": "res"
}
],
"disabled": false
}