Giter VIP home page Giter VIP logo

Comments (10)

expertcoder avatar expertcoder commented on July 16, 2024 1

I was just in the AWS console a moment ago. I created a new lambda function via the console. In the function configuration tab, the handler was set to index.handle (NO r) by default. However the boilerplate code provided for the lambda function had exports.handler (WITH r). This was a brief source of confusion for me

from alexa-app.

dblock avatar dblock commented on July 16, 2024

Found the problem, looks like module.exports = app; is causing this. What's the recommended way to combine alexa-app-server and lambda? I am trying to use alexa-app-server in development and use apex to deploy the function to lambda.

Can make it work with some ENV settings, but seems ugly.

if (process.env['LAMBDA_FUNCTION_NAME'] != null) {
    console.log("AWS lambda")
    exports.handle = app.lambda();
} else if (process.env['ENV'] == 'development') {
    console.log("Development Mode")
    module.exports = app;
} else {
    var fs = require('fs');
    fs.writeFileSync('schema.json', app.schema());
    fs.writeFileSync('utterances.txt', app.utterances());
    console.log('Schema and utterances exported!');
}

from alexa-app.

ajcrites avatar ajcrites commented on July 16, 2024

@dblock the module.exports = app will make a handler function available on the export automatically so you can do this in lambda as well. Your issue is probably that you're using handle instead of handler in your lambda function definition.

You can also do exports.handle = app.lambda() regardless of whether this is running in a lambda context or not.

from alexa-app.

dblock avatar dblock commented on July 16, 2024

@ajcrites Are you saying I can collapse my dev mode with lambda mode in https://github.com/artsy/elderfield/blob/master/functions/artsy/index.js#L123?

from alexa-app.

dblock avatar dblock commented on July 16, 2024

This needs more thorough README. I'm going to close this for now though.

from alexa-app.

thegregthomp avatar thegregthomp commented on July 16, 2024

I've notice that deploying with Apex changes the handler to "index.handle" where all the sdk examples uses handler. For this you'll want to modify Apex's project.json and add "handler":"index.handler"

from alexa-app.

dblock avatar dblock commented on July 16, 2024

@thegregthomp Can you please PR any doc changes?

from alexa-app.

thegregthomp avatar thegregthomp commented on July 16, 2024

@dblock for me this is kind of an edge case in that you'd need to be using Apex for lambda deployments. I'm not sure that's worthy of a note in the docs because I'm not sure how many people actually deploy this way. If you feel it's a lot of people, I can do that.

from alexa-app.

dblock avatar dblock commented on July 16, 2024

Not sure, your call. I think lots of people use Apex, we do - http://artsy.github.io/blog/2016/11/30/bringing-artsy-to-amazon-echo-alexa/

from alexa-app.

dblock avatar dblock commented on July 16, 2024

If something can be better documented, please PR!

from alexa-app.

Related Issues (20)

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.