const modern = require('../../src/modern');
const server = require('../../server');
const session = require('express-session');
server.session = session;
const RedisStore = require('connect-redis')(server.session);
let sessionMiddleware;

module.exports = {
  name: 'session',
  options: {
    __root: 'secret',
    resave: {
      default: false
    },
    saveUninitialized: {
      default: true
    },
    cookie: {
      default: {}
    },
    secret: {
      type: String,
      inherit: 'secret',
      env: 'SESSION_SECRET'
    },
    store: {
      env: false
    },
    redis: {
      type: String,
      inherit: true,
      env: 'REDIS_URL'
    }
  },
  init: ctx => {
    if (!ctx.options.session.store && ctx.options.session.redis) {
      ctx.options.session.store = new RedisStore({ url: ctx.options.session.redis });
    }
    sessionMiddleware = session(ctx.options.session);
  },
  before: ctx => modern(sessionMiddleware)(ctx),
  launch: ctx => {
    ctx.io.use(function (socket, next) {
      sessionMiddleware(socket.request, socket.request.res, next);
    });
  }
};

@@ -12,25 +12,25 @@
 n = require(
-'
+%22
 ../../src/mo
@@ -33,17 +33,17 @@
 c/modern
-'
+%22
 );%0Aconst
@@ -60,17 +60,17 @@
 require(
-'
+%22
 ../../se
@@ -73,17 +73,17 @@
 ./server
-'
+%22
 );%0Aconst
@@ -101,17 +101,17 @@
 require(
-'
+%22
 express-
@@ -117,17 +117,17 @@
 -session
-'
+%22
 );%0Aserve
@@ -174,17 +174,17 @@
 require(
-'
+%22
 connect-
@@ -188,17 +188,17 @@
 ct-redis
-'
+%22
 )(server
@@ -263,17 +263,17 @@
 me: 
-'
+%22
 session
-'
+%22
 ,%0A  
@@ -295,24 +295,24 @@
 __root: 
-'
+%22
 secret
-'
+%22
 ,%0A    re
@@ -491,16 +491,16 @@
 it: 
-'
+%22
 secret
-'
+%22
 ,%0A  
@@ -508,17 +508,17 @@
    env: 
-'
+%22
 SESSION_
@@ -523,17 +523,17 @@
 N_SECRET
-'
+%22
 %0A    %7D,%0A
@@ -634,17 +634,17 @@
    env: 
-'
+%22
 REDIS_UR
@@ -648,9 +648,9 @@
 _URL
-'
+%22
 %0A   
@@ -791,16 +791,24 @@
 sStore(%7B
+%0A       
  url: ct
@@ -830,16 +830,22 @@
 on.redis
+%0A     
  %7D);%0A   
@@ -997,17 +997,16 @@
 function
- 
 (socket,
@@ -1072,16 +1072,22 @@
 uest.res
+ %7C%7C %7B%7D
 , next);

Add empty request fallback for socket.io. Fixes #122