Giter VIP home page Giter VIP logo

Comments (4)

rmtuckerphx avatar rmtuckerphx commented on June 2, 2024

@jankoenig @aswetlow This is an issue on a big project I'm working on now.

from jovo-framework.

jankoenig avatar jankoenig commented on June 2, 2024

@rmtuckerphx we won't be able to deploy new v3 releases over the next 2 weeks. The fastest way to solve this is probably to patch this yourself

from jovo-framework.

rmtuckerphx avatar rmtuckerphx commented on June 2, 2024

@jankoenig I'm not sure what I would do to patch this.

Would that require me changing my code to not use whatever Jovo code calls server.ts?
What files would that be exactly?

I understand if this needs to wait. I'll do what I can to get a temporary exemption.

from jovo-framework.

jankoenig avatar jankoenig commented on June 2, 2024

Hi @rmtuckerphx,

Here is the code snippet provided by @aswetlow in Slack. It needs this workaround because alexa-verifier-middleware doesn't support require() at all.

'use strict';

const { ExpressJS, Lambda, Webhook } = require('jovo-framework');
const { app } = require('./app.js');
const fs = require('fs');

const bodyParser = require("body-parser");
const express = require("express");
const http = require("http");
const https = require("https");
// ------------------------------------------------------------------
// HOST CONFIGURATION
// ------------------------------------------------------------------


const verifiedServer = express();
verifiedServer.jovoApp = undefined;
verifiedServer.ssl = undefined;
verifiedServer.ssl = {
   key: fs.readFileSync('/etc/letsencrypt/live/<domain>/privkey.pem'),
   cert: fs.readFileSync('/etc/letsencrypt/live/<domain>/fullchain.pem'),
};
(async function() {
    const verifier = await ( await import('alexa-verifier-middleware')).default;
    
    verifiedServer.listen = function () {
        try {
        
        if (verifiedServer.jovoApp) {
            verifiedServer.jovoApp.initWebhook();
        }
        const router = express.Router();
        verifiedServer.use(router);
        router.use('/webhook_alexa', verifier);
        router.use('/webhook_alexa', bodyParser.json());
        router.use('/webhook', bodyParser.json());
    
        const httpServer = verifiedServer.ssl
            ? https.createServer(verifiedServer.ssl, this)
            : http.createServer(this);
        // @ts-ignore
        return httpServer.listen.apply(httpServer, arguments); // eslint-disable-line
        } catch (error) {
        console.log(error);
        }
    };

    
    // ExpressJS (Jovo Webhook)
    if (process.argv.indexOf('--webhook') > -1) {
      const port = process.env.JOVO_PORT || 443;
      verifiedServer.jovoApp = app;

      verifiedServer.listen(port, () => {
        console.info(`Local server listening on port ${port}.`);
      });
    // Use this
    verifiedServer.post(['/webhook','/webhook_alexa'], async (req, res) => {
        await app.handle(new ExpressJS(req, res));
      });
    }

  }());

from jovo-framework.

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.