Skip to content
This repository was archived by the owner on Jan 21, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"presets": [
"es2015"
],
"plugins": [
"add-module-exports"
]
}
42 changes: 39 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,41 @@
# Logs
logs
*.log
npm-debug.log*
node_modules/
/lib/
lerna-debug.log*

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
# https://docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git
node_modules

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history
*.patch


/reports/
/.eslintcache
/lib/
.eslintcache
5 changes: 0 additions & 5 deletions .npmignore

This file was deleted.

1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v5.10.1
8.4.0
File renamed without changes.
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

[DynamoDB](https://aws.amazon.com/dynamodb) session store for [Connect](https://github.com/senchalabs/connect) and [Express](http://expressjs.com/)

[![Circle CI](https://circleci.com/gh/packetloop/connect-dynamodb-session.svg?style=svg)](https://circleci.com/gh/packetloop/connect-dynamodb-session)
[![Circle CI](https://img.shields.io/circleci/project/github/packetloop/connect-dynamodb-session/master.svg)](https://circleci.com/gh/packetloop/connect-dynamodb-session)
[![npm](https://img.shields.io/npm/v/connect-dynamodb-session.svg)](https://www.npmjs.com/package/connect-dynamodb-session)
[![npm](https://img.shields.io/npm/dm/connect-dynamodb-session.svg)](https://www.npmjs.com/package/connect-dynamodb-session)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/79deb4056e1d419091c5a011089fb3ef)](https://www.codacy.com/app/andysprout/connect-dynamodb-session?utm_source=github.com&utm_medium=referral&utm_content=packetloop/connect-dynamodb-session&utm_campaign=Badge_Grade)
[![Codacy Badge](https://api.codacy.com/project/badge/Coverage/79deb4056e1d419091c5a011089fb3ef)](https://www.codacy.com/app/andysprout/connect-dynamodb-session?utm_source=github.com&utm_medium=referral&utm_content=packetloop/connect-dynamodb-session&utm_campaign=Badge_Coverage)
[![Dependency Status](https://david-dm.org/packetloop/connect-dynamodb-session.svg)](https://david-dm.org/packetloop/connect-dynamodb-session)
[![devDependency Status](https://david-dm.org/packetloop/connect-dynamodb-session/dev-status.svg)](https://david-dm.org/packetloop/connect-dynamodb-session#info=devDependencies)

Expand Down Expand Up @@ -88,10 +86,11 @@ app.use(session({

## Tests

```
npm run lint
npm run test
npm run coverage
Docker and docker-compose are required to run tests, since we are using local DynamoDB image for End-to-end testing

```sh
yarn lint
yarn test
```

## License
Expand Down
56 changes: 37 additions & 19 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,37 @@
machine:
node:
version: 5.10.1

dependencies:
pre:
- npm set progress=false

test:
override:
- npm run lint -- --debug --output-file reports/lint.xml --format junit
- npm run test
- npm run coverage
- cp reports/*.xml ${CIRCLE_TEST_REPORTS}
- cat ./reports/coverage/lcov.info | ./node_modules/.bin/codacy-coverage

general:
artifacts:
- reports
version: 2


jobs:
build:
working_directory: ~/app
docker:
- image: circleci/node:8.4.0
- image: sudix/docker-dynamo-local


steps:
- checkout


- restore_cache:
key: deps-{{ checksum "yarn.lock" }}


- run: yarn install --pure-lockfile


- save_cache:
key: deps-{{ checksum "yarn.lock" }}
paths:
- node_modules


- run: yarn lint


- run:
name: Run tests
environment:
DYNAMO_ENDPOINT: http://localhost:8000
DYNAMO_REGION: us-west-2
command: yarn test
21 changes: 21 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: '2'

services:
test:
image: mhart/alpine-node:base-8.4.0
volumes:
- ./:/app
working_dir: /app
environment:
DYNAMO_ENDPOINT: http://dynamo:8000
DYNAMO_REGION: us-west-2
command: /app/node_modules/.bin/babel-node /app/node_modules/.bin/tape /app/test/src/*-test.js
links:
- dynamo


dynamo:
image: sudix/docker-dynamo-local
command: -port 8000 -sharedDb
# ports:
# - 8000:8000
10 changes: 9 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
module.exports = require('./lib');
'use strict';


const connectDynamodbSession = require('./lib').default;


connectDynamodbSession.default = connectDynamodbSession;
connectDynamodbSession.connectDynamodbSession = connectDynamodbSession;
module.exports = connectDynamodbSession;
61 changes: 39 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
"description": "Connect session store for AWS DynamoDB",
"main": "index.js",
"scripts": {
"lint": "eslint --cache .",
"lint": "eslint .",
"pretest": "mkdir -p reports",
"test": "babel-node ./test",
"coverage": "babel-node node_modules/.bin/babel-istanbul cover --report text --report html --report lcov --dir reports/coverage ./test",
"test": "babel-node node_modules/.bin/tape ./test/src/*-test.js",
"build": "babel src --out-dir lib",
"prepublish": "npm run build -s"
"prepublish": "yarn build"
},
"repository": {
"type": "git",
Expand All @@ -23,6 +22,24 @@
"express"
],
"author": "Andrew Stewart <[email protected]>",
"contributors": [
{
"name": "Andrew Stewart",
"email": "[email protected]"
},
{
"name": "Nik Butenko",
"email": "[email protected]"
},
{
"name": "Murtuz Chalabov",
"email": "[email protected]"
},
{
"name": "Hal Henke",
"email": "[email protected]"
}
],
"license": "MIT",
"bugs": {
"url": "https://github.com/packetloop/connect-dynamodb-session/issues"
Expand All @@ -31,22 +48,22 @@
"aws-sdk": "2"
},
"devDependencies": {
"aws-sdk": "2.3.6",
"babel-cli": "6.7.7",
"babel-core": "6.7.7",
"babel-istanbul": "0.8.0",
"babel-plugin-add-module-exports": "0.2.1",
"babel-preset-es2015": "6.6.0",
"blue-tape": "0.2.0",
"codacy-coverage": "1.1.3",
"eslint": "2.8.0",
"eslint-config-airbnb": "8.0.0",
"eslint-plugin-import": "1.6.0",
"glob": "7.0.3",
"local-dynamo": "0.2.0",
"sinon": "1.17.3",
"sinon-stub-promise": "2.0.0",
"tap-spec": "4.1.1",
"tap-xunit": "1.3.1"
}
"aws-sdk": "^2.103.0",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-preset-es2015": "^6.24.1",
"blue-tape": "^1.0.0",
"eslint": "^4.5.0",
"eslint-config-airbnb": "^15.1.0",
"eslint-plugin-import": "^2.7.0",
"sinon": "^3.2.1",
"sinon-stub-promise": "^4.0.0"
},
"files": [
"lib",
"src",
"index.js",
"LICENSE",
"README.md"
]
}
3 changes: 2 additions & 1 deletion src/dynamo.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ export default ({awsClient: aws, region, endpoint, tableName: TableName,

put: (id, expires, content) =>
awsClient.putItem({
TableName, Item: {
TableName,
Item: {
id: {S: id},
expires: {N: expires.toString()},
content: {S: JSON.stringify(content)}
Expand Down
14 changes: 0 additions & 14 deletions test/index.js

This file was deleted.

5 changes: 3 additions & 2 deletions test/src/dynamo-test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import test from 'blue-tape';
import sinon from 'sinon';
require('sinon-stub-promise')(sinon);

import stubPromise from 'sinon-stub-promise';
import dynamo from '../../src/dynamo';

stubPromise(sinon);

const tableName = 'foo';

test('Init should succeed when no errors', () => {
Expand Down
7 changes: 4 additions & 3 deletions test/src/index-test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import {withFakeTimers} from '../helpers';
import sinon from 'sinon';
require('sinon-stub-promise')(sinon);

import stubPromise from 'sinon-stub-promise';
import {withFakeTimers} from '../helpers';
import createStore from '../../src/index';

stubPromise(sinon);

const DynamoStore = createStore({Store: null});

const mockClient = overrides => Object.assign({
Expand Down
23 changes: 6 additions & 17 deletions test/src/local-dynamo-test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {sequence} from '../helpers';
import localDynamo from 'local-dynamo';
import AWS from 'aws-sdk';

import {sequence} from '../helpers';
import createStore from '../../src/index';


const DynamoStore = createStore({Store: null});
const region = 'us-west-2';
const endpoint = 'http://localhost:4567';
const region = process.env.DYNAMO_REGION || 'us-west-2';
const endpoint = process.env.DYNAMO_ENDPOINT;
const options = {
tableName: 'foo',
endpoint,
Expand All @@ -31,15 +31,8 @@ const getItem = (t, fn) => awsClient.getItem({TableName: 'foo', Key: {id: {S: id
});


let localdb;
let store;
sequence('Should be able to get and set a session', [
(t, next) => {
t.comment('Launching local dynamodb');
localdb = localDynamo.launch({dir: null, port: 4567, stdio: 'inherit'});
next(1000); // wait for the java process to start
},

(t, next) => {
t.comment('Creating dynamo store');
store = new DynamoStore(options);
Expand Down Expand Up @@ -244,8 +237,4 @@ sequence('Should be able to get and set a session', [
t.end();
next();
}
], start, 500)
.on('end', () => {
console.log('killing local dynamodb');
localdb.kill();
});
], start, 500);
Loading