node package manager
Orgs are free. Discover, share, and reuse code in your team. Create a free org »

functions-io

Functions-IO

Functional Micro Framework

work in progress...

Minimalist functional framework for node.

Features

  • Focus on high performance
  • Auto reload change in javascript files
  • Input/Output with automatic validation
  • Unit Test with automatic execution
  • Openapi/Swagger definition generated automatically
  • Statistics - access, error, abort, time

Installation

$ npm install functions-io

Usage

Create a function in folder functions

module.version = "v1";
module.category = "test";
module.summary = "sum";
module.description = "sum x + y";
 
module.input = {
    x:{type:"integer", required:true},
    y:{type:"integer", required:true}
};
module.output = {
    value:{type:"integer"}
};
 
module.exports = function(context, message, callBack){
    callBack(null, {value: message.x + message.y});
};

Start Server

var functionsio = require("functions-io");
var app = functionsio();
 
app.listen(8080);

swagger.json

http://localhost:8080/swagger.json

Catalog API (Openapi / Swagger)

http://localhost:8080/_admin/catalog

Admin

http://localhost:8080/_admin/stats

Unit Test

http://localhost:8080/_admin/test

Options property

  • path (default: functions)
  • enableStatistics (default: true)
  • enableSecurity (default: false)
  • unitTest
    • load (default: true)
    • executeOnStart (default: false)
  • scan
    • automatic (default: true)
    • interval (default: 2000)
  • cors
    • enable (default: false)
    • fromOrigin (default: *)
  • html
    • static (default: static)
  • db
    • provider (default: sys.db.provider.mongo)
  • functions
    • sys.db.provider.mongo
      • db
        • url (default: mongodb://localhost:27017/sample)
//example 
var functionsio = require("functions-io");
var app = functionsio();
 
app.listen(8080);
  • example file config.json
{
    "functions":{
        "sys.db.provider.mongo":{
            "db":{
                "url":"mongodb://localhost:27017/sample"
            }
        }
    }
}
  • example file config.json
{
    "unitTest":{
        "load": true,
        "executeOnStart": false
    },
    "functions":{
        "sys.db.provider.mongo":{
            "db":{
                "url":"mongodb://localhost:27017/sample"
            }
        }
    }
}
  • example file config.json
{
    "scan":{
        "automatic": true
    },
    "unitTest":{
        "load": true,
        "executeOnStart": false
    },
    "functions":{
        "sys.db.provider.mongo":{
            "db":{
                "url":"mongodb://localhost:27017/sample"
            }
        }
    }
}
  • example file config.json
{
    "scan":{
        "automatic": true
    },
    "unitTest":{
        "load": true,
        "executeOnStart": false
    },
    "global":{
        "db":{
            "provider":"sys.db.provider.myprovider"
        }
    }
}