botmaster-session-ware
Advanced tools
Comparing version 0.0.2 to 0.0.3
/** | ||
* The most basic adapter ever for SessionWare | ||
* @class | ||
*/ | ||
@@ -22,3 +23,3 @@ class MemoryStore { | ||
* @param {Object} value the new value for the session | ||
* @return {Promise} | ||
* @return {Promise} resolves when the session has been saved | ||
*/ | ||
@@ -25,0 +26,0 @@ set(id, value) { |
11
index.js
@@ -6,8 +6,9 @@ const R = require('ramda'); | ||
* Create an object providing incoming and outgoing middleware | ||
* @param {Object} [options] | ||
* @param {Object} [adapter] an object implementing the adapter api. defaults to in memory. | ||
* @param {String} [sessionPath] dot denoted path to where to store the context in the update. defaults to 'session' | ||
* @param {Object} [options] options object for generated sessionWare | ||
* @param {Object} [options.adapter] an object implementing the adapter api. defaults to in memory. | ||
* @param {String} [options.sessionPath] dot denoted path to where to store the context in the update. defaults to 'session' | ||
* @return {Object} an object that contains two functions 'incoming' and 'outgoing'. The incoming should be placed before any middleware that requires it and the outgoing should be placed after all middleware have used it. | ||
*/ | ||
const SessionWare = ({adapter, sessionPath='session'} ={}) => { | ||
const SessionWare = (options) => { | ||
let {sessionPath = 'session', adapter} = options || {}; | ||
sessionPath = sessionPath.split('.'); | ||
@@ -17,3 +18,3 @@ let store; | ||
store = adapter; | ||
if (typeof store.get !== 'function' || typeof store.set !== 'function') | ||
if (typeof store.get !== 'function' || typeof store.set !== 'function') | ||
throw new Error('Adapter does not have required methods get and/or set'); | ||
@@ -20,0 +21,0 @@ } |
{ | ||
"name": "botmaster-session-ware", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "botmaster session ware for storing context", | ||
@@ -32,2 +32,3 @@ "main": "index.js", | ||
"istanbul": "^0.4.5", | ||
"mocha": "^3.2.0", | ||
"mocha-lcov-reporter": "^1.2.0", | ||
@@ -34,0 +35,0 @@ "should": "^11.2.0" |
@@ -51,3 +51,3 @@ [![Build Status](https://travis-ci.org/botmasterai/botmaster-session-ware.svg?branch=master)](https://travis-ci.org/botmasterai/botmaster-session-ware) | ||
Returns **Promise** | ||
Returns **Promise** resolves when the session has been saved | ||
@@ -60,9 +60,6 @@ ### SessionWare | ||
- `options` **[Object]** | ||
- `adapter` **[Object]** an object implementing the adapter api. defaults to in memory. | ||
- `sessionPath` **[String]** dot denoted path to where to store the context in the update. defaults to 'session' | ||
- `$0` | ||
- `$0.adapter` | ||
- `$0.sessionPath` | ||
- `options` **[Object]** options object for generated sessionWare | ||
- `options.adapter` **[Object]** an object implementing the adapter api. defaults to in memory. | ||
- `options.sessionPath` **[String]** dot denoted path to where to store the context in the update. defaults to 'session' | ||
Returns **Object** an object that contains two functions 'incoming' and 'outgoing'. The incoming should be placed before any middleware that requires it and the outgoing should be placed after all middleware have used it. |
9960
160
5
10
64