Giter Site home page Giter Site logo

openfaas-incubator / node10-express-template Goto Github PK

View Code? Open in Web Editor NEW
24.0 24.0 26.0 23 KB

Node.js 10 Express Template for OpenFaaS

License: MIT License

Dockerfile 34.22% JavaScript 65.78%
docker faas javascript kubernetes lambda node openfaas

node10-express-template's People

Contributors

alexellis avatar burtonr avatar kenfdev avatar kturcios avatar martindekov avatar omerzamir avatar rdimitrov avatar telackey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

node10-express-template's Issues

Serving PNG images

Hi, I was trying to use this template to serve SPA files. I was following the article https://www.openfaas.com/blog/serverless-single-page-app/ . It works well except for images and I suspect for contents such as pdf. I tried modifying the template to use express' sendFile() and setting the right Content-Type and it works with that. However, I was not able to succeed sending files with either end() or pipe(). If there is an alternative without modifying the template, please let me know. Based on the suggestion, I can also make a pull request to correct the issue. Thanks in advance.

Context.fail does not support custom status codes

Expected Behaviour

The following code snippet should return a 501 status code along with the error message.

module.exports = (event, context) => {
    context
        .status(501)
        .fail('An error occurred');
}

Current Behaviour

The snippet is returning the default 500 status code along with the error message.

Possible Solution

Modify the fail method inside index.js to use this.value

fail(value) {
        let message;
        this.cb(this.value, message);
}

Steps to Reproduce (for bugs)

Create a handler that returns the following

module.exports = (event, context) => {
    context
        .status(501)
        .fail('An error occurred');
}

Context

I am trying to create a stateless microservice that returns proper status codes.

Your Environment

faas-cli version: 0.8.3
docker version: 18.09.1
OS: MacOS

event.body is empty when using kafka-connector

I am using kafka-connector to trigger a function but the body is always empty. I set RAW_BODY to true but it is still empty.
Is there another way I can try to solve this issues ?

here is the log of the function request:

{
    "body": {},
    "headers": {
      "host": "transform.openfaas-fn.svc.cluster.local:8080",
      "user-agent": "Go-http-client/1.1",
      "transfer-encoding": "chunked",
      "accept-encoding": "gzip",
      "x-forwarded-for": "10.244.0.193:58756",
      "x-forwarded-host": "gateway.openfaas:8080"
    },
    "method": "POST",
    "query": {},
    "path": "/"
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.