app/session/index.js   A
last analyzed

Complexity

Total Complexity 2
Complexity/F 2

Size

Lines of Code 32
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
c 1
b 0
f 0
nc 1
dl 0
loc 32
rs 10
wmc 2
mnd 1
bc 3
fnc 1
bpm 3
cpm 2
noi 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A index.js ➔ init 0 18 2
1
'use strict';
2
3
var session 	= require('express-session');
4
var MongoStore	= require('connect-mongo')(session);
5
var db 		    = require('../database');
6
var config 		= require('../config');
7
8
/**
9
 * Initialize Session
10
 * Uses MongoDB-based session store
11
 *
12
 */
13
var init = function () {
14
	if(process.env.NODE_ENV === 'production') {
15
		return session({
16
			secret: config.sessionSecret,
17
			resave: false,
18
			saveUninitialized: false,
19
			unset: 'destroy',
20
			store: new MongoStore({ mongooseConnection: db.Mongoose.connection })
21
		});
22
	} else {
23
		return session({
24
			secret: config.sessionSecret,
25
			resave: false,
26
			unset: 'destroy',
27
			saveUninitialized: true
28
		});
29
	}
30
}
31
32
module.exports = init();