alexa-ability
Advanced tools
Comparing version 0.9.0 to 0.9.1
@@ -30,2 +30,27 @@ # `Request` | ||
#### `handler` | ||
A string representing the event being handled. This can be useful for middleware | ||
that need to react differently when handling certain intents. | ||
If there was no handler for the given request, `req.handler` will equal `"unhandledEvent"`. | ||
##### example | ||
```js | ||
app.use(function(req, next) { | ||
// we don't want to log peoples secrets | ||
if (req.handler !== 'SaveSecretIntent') { | ||
logRequest(req); | ||
} | ||
next(); | ||
}); | ||
app.on('SaveSecretIntent', function(req) { | ||
saveToDatabase(req.slots.secret, function() { | ||
req.say('Saved!').end(); | ||
}); | ||
}); | ||
// other handlers | ||
``` | ||
#### `raw` | ||
@@ -32,0 +57,0 @@ The original event object passed to the ability. |
@@ -118,3 +118,3 @@ 'use strict'; | ||
this._handlers[event] = [].concat(_toConsumableArray(currentHandlers), _toConsumableArray(handlers)); | ||
oLog('current ' + this._handlers[event].length + ' handlers for ' + event + ' event'); | ||
oLog('currently ' + this._handlers[event].length + ' handlers for ' + event + ' event'); | ||
return this; | ||
@@ -147,2 +147,3 @@ } | ||
var req = new _Request.Request(event); | ||
req.handler = handler ? eventName : e.unhandledEvent; | ||
req.on('finished', function () { | ||
@@ -149,0 +150,0 @@ return setImmediate(callback, null, req); |
@@ -36,13 +36,17 @@ 'use strict'; | ||
// metadata | ||
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Request).call(this)); | ||
_this.raw = event; | ||
_this.handler = null; // set by ability | ||
_this.sent = false; | ||
_this.isNew = (0, _get2.default)(event, 'session.new', false); | ||
_this.isEnding = !!(0, _get2.default)(event, 'request.reason'); | ||
_this.reason = (0, _get2.default)(event, 'request.reason', null); | ||
// request data | ||
_this.version = (0, _get2.default)(event, 'version', '1.0'); | ||
_this.user = (0, _get2.default)(event, 'session.user', {}); | ||
_this.session = (0, _get2.default)(event, 'session.attributes', {}); | ||
_this.user = (0, _get2.default)(event, 'session.user', {}); | ||
_this.slots = _this.params = (0, _transform2.default)((0, _get2.default)(event, 'request.intent.slots'), function (obj, slot) { | ||
@@ -49,0 +53,0 @@ return obj[slot.name] = slot.value; |
{ | ||
"name": "alexa-ability", | ||
"version": "0.9.0", | ||
"version": "0.9.1", | ||
"description": "An Alexa skills framework for node", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
# alexa-ability [![Build Status](https://travis-ci.org/nickclaw/alexa-ability.svg?branch=master)](https://travis-ci.org/nickclaw/alexa-ability) | ||
An [Alexa Skills Kit](https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit) framework for node. | ||
- [Read the docs](api/) | ||
- [Read the docs](docs/) | ||
- [View the examples](examples/) | ||
@@ -6,0 +6,0 @@ - [Contribute!](CONTRIBUTING.md) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39144
523