No require any ENV_VAR
This commit is contained in:
@@ -1,21 +1,22 @@
|
||||
import {Store} from 'express-session';
|
||||
import {Redis, Config} from '.';
|
||||
import {Redis, DefaultConfig} from '.';
|
||||
import * as redisStore from "connect-redis";
|
||||
import * as session from 'express-session';
|
||||
import {RequestHandler} from 'express';
|
||||
|
||||
Config.requireEnv('SESSION_SECRET', true);
|
||||
|
||||
|
||||
let sessionStore: Store|undefined = undefined;
|
||||
|
||||
function getRouter(options?: Partial<session.SessionOptions>): RequestHandler {
|
||||
DefaultConfig.requireEnv('SESSION_SECRET', true);
|
||||
if (Redis.client && sessionStore !== undefined) {
|
||||
const RedisStore = redisStore(session);
|
||||
sessionStore = new RedisStore({client: Redis.client});
|
||||
}
|
||||
return session({
|
||||
store: sessionStore,
|
||||
secret: Config.SESSION_SECRET || 'keyboard cat',
|
||||
secret: DefaultConfig.SESSION_SECRET || 'keyboard cat',
|
||||
resave: false,
|
||||
saveUninitialized: true,
|
||||
cookie: {secure: false},
|
||||
|
||||
Reference in New Issue
Block a user