Instantly share code, notes, and snippets.

anonymous /app.ts Secret
Created Nov 16, 2017

Embed
What would you like to do?
express-session管理
import express = require('express');
import session = require('express-session');
import connectRedis = require('connect-redis');
const app = express();
var RedisStore = connectRedis(session);
class Main {
constructor() {
app.use(
session({
secret : 'secret'
, resave : true
, saveUninitialized : true
, store : new RedisStore ({
host : '127.0.0.1'
, port : 6379
, prefix:'dev.blog'
})
, cookie : {
path : '/'
}
})
);
app.get('/', (req, res, next) => {
res.send(req.session);
})
app.listen(8080);
}
}
let main = new Main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment