+
Skip to content

Example for basic low level node server #163

Open
@geuis

Description

@geuis

It would be super helpful for others who don't want to use Lambda or Express if one of the examples demonstrated how to use alexa-app with a simple low-level server such as this:

const http = require('http');
const alexa = require('alexa-app');

const alexaApp = new alexa.app('testApp');

const server = (req, res) => {
  if (req.method === 'POST') {
    const body = [];

    req.on('data', (chunk) => body.push(chunk));
    req.on('end', () => {
      // do alexa-app integration magic in here
      console.log(body.join(''));
     
      res.writeHead(200);
      res.end('ok');
    });

  } else {
    res.writeHead(404);
    res.end('bye');
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载