Skip to content

Instantly share code, notes, and snippets.

/app.ts Secret

Created November 16, 2017 11:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/ac774ab0f277f04f633864c85372ba1b to your computer and use it in GitHub Desktop.
Save anonymous/ac774ab0f277f04f633864c85372ba1b to your computer and use it in GitHub Desktop.
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