Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nullsession

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nullsession - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

test/fixtures/serverUtil.js

16

CHANGELOG.md

@@ -0,5 +1,15 @@

### 0.2.0
- setting the express-session `genid` function to return undefined, to not set the cookie.
### 0.1.2 (current)
- devDependencies and travis ci update
### 0.1.1
- adding empty cookie object in get api
### 0.1.0
- /dev/null equivalent for connect-session
### 0.1.1
- adding empty cookie object in get api
- /dev/null equivalent for connect-session

2

index.js
'use strict';
exports = module.exports = require('./lib/nullstore');
module.exports = require('./lib/nullstore');
'use strict';
var util = require('util');
const util = require('util');

@@ -10,3 +10,3 @@ module.exports = function ConnectNullStore(app) {

*/
var Store = app.Store || app.session.Store;
const Store = app.Store || app.session.Store;

@@ -27,3 +27,3 @@ function NullStore(options) {

NullStore.prototype.get = function get(id, callback) {
var cookie = {
const cookie = {
path: '/',

@@ -63,2 +63,2 @@ httpOnly: true,

return NullStore;
};
};
'use strict';
var session = require('express-session'),
NullStore = require('./index')(session);
const session = require('express-session');
const NullStore = require('./index')(session);
module.exports = function (settings) {
settings = settings || {};
settings.resave = false;
settings.secret = 'cat';
settings.saveUninitialized = false;
settings.genid = function () {
return undefined;
};
settings.store = new NullStore(settings);
return session(settings);
};
};
{
"name": "nullsession",
"version": "0.1.1",
"version": "0.2.0",
"description": "/dev/null equivalent for connect-session",
"main": "index.js",
"scripts": {
"test": "make test"
"test": "mocha",
"lint": "jshint *.js lib test --config .jshintrc"
},

@@ -15,3 +16,4 @@ "homepage": "https://github.com/skoranga/node-nullsession",

"keywords": [
"curl",
"connect-session",
"null",
"nodejs"

@@ -22,10 +24,10 @@ ],

"readmeFilename": "README.md",
"dependencies": {
},
"dependencies": {},
"devDependencies": {
"chai": "^4",
"express-session": "^1.8",
"mocha": "^1",
"chai": "^1",
"jshint": "^2"
"jshint": "^2",
"mocha": "^7",
"supertest": "^4"
}
}
node-nullsession
================
/dev/null equivalent for connect-session. If app is not using session, disable session in express app by using `nullsession` module.
/dev/null equivalent for connect-session. For usecases where you are forced to have some session aware app but no session is required. Disable session in express app without worrying about other middlewares or session aware modules by using `nullsession`.
### How to use

@@ -11,3 +10,3 @@

```
```json
"express-session": "^1.9",

@@ -20,3 +19,3 @@ "nullsession": "~0.1.0",

```
```js
var session = require('express-session'),

@@ -29,2 +28,2 @@ NullStore = require('nullsession/middleware')(session);

}));
```
```
'use strict';
var path = require('path'),
assert = require('assert'),
session = require('express-session'),
NullStore = require('../index')(session);
const path = require('path');
const assert = require('assert');
const request = require('supertest');
const session = require('express-session');
const NullStore = require('../index')(session);
const serverUtil = require('./fixtures/serverUtil');
const emptySession = {
cookie: {
httpOnly: true,
maxAge: null,
path: "/"
}
};
describe('nullsession', function () {
var store = new NullStore();
const store = new NullStore();

@@ -25,3 +34,3 @@ it('should set a value', function (next) {

assert.ok(!err, '#get() got an error');
assert.deepEqual({}, data);
assert.deepEqual(emptySession, data);
next();

@@ -35,3 +44,3 @@ });

assert.ok(!err, '#get() got an error');
assert.deepEqual({}, data);
assert.deepEqual(emptySession, data);
next();

@@ -50,1 +59,17 @@ });

});
describe('no cookie nullsession on server', function () {
it('should not create a new cookie', function (done) {
var count = 0;
var server = serverUtil.createServer({}, function (req, res) {
req.session.num = req.session.num || ++count;
res.end('data');
});
request(server)
.get('/')
.expect(serverUtil.shouldHaveNoCookie())
.expect(200, 'data', done);
});
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc