All Projects → openfaas-incubator → node8-express-template

openfaas-incubator / node8-express-template

Licence: MIT license
Node.js 8 template for OpenFaaS with HTTP via Express.js

Programming Languages

javascript
184084 projects - #8 most used programming language
Dockerfile
14818 projects

Projects that are alternatives of or similar to node8-express-template

2020
Make your own 2020 ASCII art
Stars: ✭ 26 (+62.5%)
Mutual labels:  faas, openfaas
openfass-node-restful-api
Simple example of an OpenFaaS RESTful API
Stars: ✭ 33 (+106.25%)
Mutual labels:  faas, openfaas
faas-fargate
OpenFaaS on AWS Fargate. Open source Functions as a Service without any infrastructure to manage
Stars: ✭ 50 (+212.5%)
Mutual labels:  faas, openfaas
node10-express-template
Node.js 10 Express Template for OpenFaaS
Stars: ✭ 26 (+62.5%)
Mutual labels:  faas, openfaas
openfaas-rstats-templates
OpenFaaS templates for R
Stars: ✭ 17 (+6.25%)
Mutual labels:  faas, openfaas
vcenter-connector
Extend vCenter with OpenFaaS
Stars: ✭ 29 (+81.25%)
Mutual labels:  faas, openfaas
Bref
Serverless PHP on AWS Lambda
Stars: ✭ 2,382 (+14787.5%)
Mutual labels:  faas
hashicorp-labs
Deploy locally on VM an Hashicorp cluster formed by Vault, Consul and Nomad. Ready for deploying and testing your apps.
Stars: ✭ 32 (+100%)
Mutual labels:  openfaas
Templates
OpenFaaS Classic templates
Stars: ✭ 189 (+1081.25%)
Mutual labels:  faas
Of Watchdog
Reverse proxy for STDIO and HTTP microservices
Stars: ✭ 175 (+993.75%)
Mutual labels:  faas
daily-home
dailyhome - open home automation platform powered by openfaas targeted easy adaptation
Stars: ✭ 28 (+75%)
Mutual labels:  openfaas
openwhisk-runtime-java
Apache OpenWhisk Runtime Java supports Apache OpenWhisk functions written in Java and other JVM-hosted languages
Stars: ✭ 43 (+168.75%)
Mutual labels:  faas
openwhisk-package-kafka
Apache OpenWhisk package for communicating with Kafka or Message Hub
Stars: ✭ 35 (+118.75%)
Mutual labels:  faas
Malagu
Malagu Development Framework (QQ: 1013685855 钉钉群:31992376)
Stars: ✭ 196 (+1125%)
Mutual labels:  faas
openfaas-rust-template
An OpenFaaS template for writing functions in Rust
Stars: ✭ 29 (+81.25%)
Mutual labels:  openfaas
Malagu
Malagu is a Serverless First, component-based, platform-independent, progressive application framework based on TypeScript.
Stars: ✭ 184 (+1050%)
Mutual labels:  faas
Components
The Serverless Framework's new infrastructure provisioning technology — Build, compose, & deploy serverless apps in seconds...
Stars: ✭ 2,259 (+14018.75%)
Mutual labels:  faas
media
Press kit / Media pack for OpenFaaS
Stars: ✭ 44 (+175%)
Mutual labels:  openfaas
python-flask-template
HTTP and Flask-based OpenFaaS templates for Python 3
Stars: ✭ 76 (+375%)
Mutual labels:  faas
Docs
User documentation for Knative components.
Stars: ✭ 3,106 (+19312.5%)
Mutual labels:  faas

OpenFaaS Node.js 8 and Express.js template

This template provides additional context and control over the HTTP response from your function.

Status of the template

This template is pre-release and is likely to change - please provide feedback via https://github.com/openfaas/faas

The template makes use of the OpenFaaS incubator project of-watchdog.

See also: node10-express template

Supported platforms

  • x86_64 - node8-express
  • armhf - node8-express-armhf

Trying the template

$ faas template pull https://github.com/openfaas-incubator/node8-express-template
$ faas new --lang node8-express

Example usage

Example with success and JSON body:

"use strict"

module.exports = (event, context) => {
    let err;
    const result =             {
        status: "You said: " + JSON.stringify(event.body)
    };

    context.
        succeed(result);
}

Example of a custom HTTP status code:

"use strict"

module.exports = (event, context) => {
    let err;
    const result = {"message": "The record requested was not found."};

    context
        .status(404)
        .succeed(result);
}

Example of failure and plain-text body:

"use strict"

module.exports = (event, context) => {
    let err;
    const result = "Unable to process this event.";

    context
        .fail(result);
}

Example with use of optional callback parameter:

"use strict"

module.exports = (event, context, callback) => {
    let err;

    callback(err, {"result": "message received"});
}

Example with redirect (setting Location header):

"use strict"

module.exports = (event, context) => {
  context
    .headers({'Location': 'https://www.google.com/'})
    .status(307)    // Temporary
    .succeed('Page has moved.')
}

Other reference:

  • .status(code) - overrides the status code used by fail, or succeed
  • .fail(object) - returns a 500 error if .status(code) was not called prior to that
  • .succeed(object) - returns a 200 code if .status(code) was not called prior to that
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].