1.1.0 • Published 7 years ago

fliteral v1.1.0

Weekly downloads
2
License
ISC
Repository
-
Last release
7 years ago

Function literal runner

A small Node app to run function literals, largely compatible with AWS Lambda + web gateway.

Use it for testing, or use it on your own server.

Do not allow untrusted code to run on your infrastructure. These are not sandboxed in any way.

Literals

These are really just Node modules with a standardised API. A literal consists of a folder, a package.json and an export.

Sample literal to echo response back to sender:

module.exports = {
  handler: (event, context, callback) => {
    callback(null, {
      statusCode: '200',
      headers: {'Content-Type': 'application/json'},
      body: JSON.stringify(event),
    });
  }
}

Usage

Run on the command line as follows:

LITERAL_PATH=foo fliteral

This will open the default HTTP port (see below), and any requests to http://myserver/* will run & return the literal named *.

Environment Variables

The following variables may be configured:

Variable nameDescriptionDefault
PORTHTTP port to open8080
LITERAL_PATHPath which contains function literals.path.join(__dirname, functions)
LITERAL_TIMEOUTNumber of milliseconds after which the server will send a 502 gateway timeout.15000
LITERAL_LOGGLY_TOKENOptional: Loggly token to remote log
LITERAL_LOGGLY_SUBDOMAINOptional: Loggly subdomain to remote log
LITERAL_LOGGLY_TAGOptional: Tag to log entries to loggly