-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from alexa-js/v2
v2 fixes #35
- Loading branch information
Showing
9 changed files
with
7,832 additions
and
2,196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
engine-strict=true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# 2.0.0 | ||
* BREAKING: publish as a pure ES module | ||
* BREAKING: only support node >= 12.17 | ||
* BREAKING: switch to es6 everywhere | ||
* update all dependencies |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,26 +3,29 @@ | |
[![NPM](https://nodei.co/npm/alexa-verifier-middleware.png)](https://www.npmjs.com/package/alexa-verifier-middleware/) | ||
|
||
![NPM Version](https://img.shields.io/npm/v/alexa-verifier-middleware.svg) | ||
[![Build Status](https://travis-ci.org/alexa-js/alexa-verifier-middleware.svg?branch=master)](https://travis-ci.org/alexa-js/alexa-verifier-middleware) | ||
|
||
![example workflow](https://github.com/alexa-js/alexa-verifier-middleware/actions/workflows/main.yml/badge.svg) | ||
|
||
[![dependencies Status](https://david-dm.org/alexa-js/alexa-verifier-middleware/status.svg)](https://david-dm.org/tejashah88/alexa-verifier-middleware) | ||
|
||
An [express](https://www.npmjs.com/package/express) middleware that verifies HTTP requests sent to an Alexa skill are sent from Amazon. | ||
|
||
|
||
This module should work on node v4 and up, though we don't test on those platforms anymore. We guarantee support node v8 and up. | ||
Version 2.x is now a pure es module, and requires node 12.17 or higher. If you want to run this via an older version of node, use [email protected] | ||
|
||
|
||
### Usage | ||
|
||
It is recommended that you attach all Alexa routes to an express Router. | ||
```javascript | ||
var express = require('express'); | ||
var verifier = require('alexa-verifier-middleware'); | ||
import express from 'express'; | ||
import verifier from 'alexa-verifier-middleware'; | ||
|
||
|
||
var app = express(); | ||
const app = express(); | ||
|
||
// create a router and attach to express before doing anything else | ||
var alexaRouter = express.Router(); | ||
const alexaRouter = express.Router(); | ||
app.use('/alexa', alexaRouter); | ||
|
||
// attach the verifier middleware first because it needs the entire | ||
|
@@ -32,7 +35,7 @@ alexaRouter.use(verifier); | |
// Routes that handle alexa traffic are now attached here. | ||
// Since this is attached to a router mounted at /alexa, | ||
// this endpoint will be accessible at /alexa/weather_info | ||
alexaRouter.get('/weather_info', function(req, res) { ... }); | ||
alexaRouter.get('/weather_info', function (req, res) { ... }); | ||
|
||
app.listen(3000); | ||
``` | ||
|
@@ -44,7 +47,7 @@ app.listen(3000); | |
|
||
Before: | ||
```javascript | ||
var alexaRouter = express.Router(); | ||
const alexaRouter = express.Router(); | ||
app.use('/alexa', alexaRouter); | ||
|
||
// INCORRECT | ||
|
@@ -54,7 +57,7 @@ alexaRouter.use(verifier); | |
|
||
After: | ||
```javascript | ||
var alexaRouter = express.Router(); | ||
const alexaRouter = express.Router(); | ||
app.use('/alexa', alexaRouter); | ||
|
||
// CORRECT | ||
|
@@ -63,4 +66,4 @@ alexaRouter.use(bodyParser.json()); | |
``` | ||
|
||
### Mentions | ||
* [mreinstein](https://github.com/mreinstein) for his [alexa-verifier](https://github.com/mreinstein/alexa-verifier) module, which allows you to verify any Amazon requests from any web service | ||
* [mreinstein](https://github.com/mreinstein) for his [alexa-verifier](https://github.com/mreinstein/alexa-verifier) module, which allows you to verify any Amazon requests from any web service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.