Skip to content

Commit

Permalink
add express-session
Browse files Browse the repository at this point in the history
  • Loading branch information
omnidan committed Apr 6, 2016
1 parent 33796d7 commit ec694df
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"eslint-config-airbnb": "^5.0.1",
"eslint-plugin-react": "3.16.1",
"express": "^4.13.4",
"express-session": "^1.13.0",
"fbjs": "^0.7.2",
"helmet": "^1.1.0",
"history": "^1.17.0",
Expand Down
1 change: 1 addition & 0 deletions src/server/api/posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const router = new Router();
import fakeDB from '../fakeDB.js';

router.get('/', (req, res) => {
req.session = 'test';
res.statusCode = 200;
res.json(fakeDB);
});
Expand Down
5 changes: 5 additions & 0 deletions src/server/server.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import path from 'path';
import express from 'express';
import session from 'express-session';
import webpack from 'webpack';
import webpackMiddleware from 'webpack-dev-middleware';
import webpackHotMiddleware from 'webpack-hot-middleware';
Expand Down Expand Up @@ -51,6 +52,10 @@ server.use(helmet.frameguard('deny'));
server.use(helmet.ieNoOpen());
server.use(helmet.noSniff());
server.use(cookieParser());
server.use(session({
secret: 'keyboard cat',
resave: true, saveUninitialized: true
}));
server.use(compression());

// API
Expand Down

0 comments on commit ec694df

Please sign in to comment.