dougmoscrop / serverless-http

Use your existing middleware framework (e.g. Express, Koa) in AWS Lambda 🎉
Other
1.74k stars 167 forks source link

Support for Google Cloud Functions / Azure Functions #6

Closed rochdev closed 7 months ago

rochdev commented 7 years ago

I think it would be great as by supporting all providers this project has the potential to become the one serverless framework to rule them all. I don't know if this would fit the current scope of the project though.

Otherwise I am thinking maybe of making another project using this one as its "lambda" adapter.

dougmoscrop commented 7 years ago

Interesting - I am up for it! I also know that the Serverless people are looking at making a generic function handler type interface: (I think the discussion is here: https://github.com/serverless/stdlib-nodejs/issues/14)

So I was thinking I might eventually move to 'that' interface -- thoughts?

cometta commented 7 years ago

how soon will you add support for GCF?

dougmoscrop commented 7 years ago

Google Cloud functions look almost like they have their own version of this module anyway "internally" because they give you a req and res object in their handler.

Have you tried just

app = koa() ... app.callback()(req, res)

Without any library help?

cometta commented 7 years ago

yup, it's working.

dougmoscrop commented 7 years ago

I'm always up for PRs that can help with any issues around GCF or Azure

unixfox commented 6 years ago

Do you have an idea/quick fix to make my function working on Azure? Here is my code:

const express = require('express')
const sls = require('serverless-http')
const app = express()
app.get('/', function (req, res) {
  res.send('Hello World!')
})
module.exports.server = sls(app)
dougmoscrop commented 6 years ago

I have never looked in to Azure. What does a basic "200 ok" look like in pure azure?

On Wed, Oct 17, 2018, 7:13 PM Emilien Devos notifications@github.com wrote:

Do you have an idea/quick fix to make my function working under Azure? Here is my code:

const express = require('express') const sls = require('serverless-http') const app = express() app.get('/', function (req, res) { res.send('Hello World!') }) module.exports.server = sls(app)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dougmoscrop/serverless-http/issues/6#issuecomment-430821209, or mute the thread https://github.com/notifications/unsubscribe-auth/AAjzFDPaXHZXJJADUpceMS0TYNJHjvHpks5ul7mjgaJpZM4LP9WC .

unixfox commented 6 years ago

Here is an example of serverless for Azure: https://github.com/serverless/serverless/blob/master/lib/plugins/create/templates/azure-nodejs/handler.js

And if you need a pure example, here is this code took from the official documentation:

module.exports = async function (context, req) {
    context.log('JavaScript HTTP trigger function processed a request.');
    // You can call and await an async method here
    return {
        body: "Hello, world!"
    };
}

Link of the documentation: https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-node

dougmoscrop commented 5 years ago

I refactored this library to support multiple providers, however I don't have any plans to implement them. PRs are welcome.

joshuaquek commented 4 years ago

Where can we find this refactored version? Would there be a branch for this?