mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
23 lines
489 B
TypeScript
23 lines
489 B
TypeScript
import session from 'express-session'
|
|
import MongoStore from 'connect-mongo'
|
|
|
|
import config from '../config.js'
|
|
|
|
export default session({
|
|
secret: config.secret,
|
|
resave: false,
|
|
saveUninitialized: false,
|
|
rolling: true,
|
|
cookie: {
|
|
domain: config.domain,
|
|
httpOnly: true,
|
|
secure: config.protocol === 'https:',
|
|
sameSite: 'strict',
|
|
maxAge: config.sessionMaxAge,
|
|
},
|
|
store: MongoStore.create({
|
|
mongoUrl: config.db,
|
|
collectionName: 'loginSessions',
|
|
}),
|
|
})
|