refactor(striker-ui-api): rename session->expressSession, sessionHandler->session

main
Tsu-ba-me 2 years ago
parent 74175c538a
commit 46891f322b
  1. 4
      striker-ui-api/src/app.ts
  2. 8
      striker-ui-api/src/session.ts

@ -5,7 +5,7 @@ import { guardApi } from './lib/assertAuthentication';
import passport from './passport';
import routes from './routes';
import { rrouters } from './lib/rrouters';
import sessionHandler from './session';
import session from './session';
const app = express();
@ -15,7 +15,7 @@ app.use(cors());
// Add session handler to the chain **after** adding other handlers that do
// not depend on session(s).
app.use(sessionHandler);
app.use(session);
app.use(passport.initialize());
app.use(passport.authenticate('session'));

@ -1,4 +1,4 @@
import session, {
import expressSession, {
SessionData,
Store as BaseSessionStore,
} from 'express-session';
@ -13,7 +13,7 @@ import { getSessionSecret } from './lib/getSessionSecret';
import { isObject } from './lib/isObject';
import { stderr, stdout, stdoutVar, uuidgen } from './lib/shell';
const DEFAULT_COOKIE_ORIGINAL_MAX_AGE = 1000 * 60 * 60;
const DEFAULT_COOKIE_ORIGINAL_MAX_AGE = 3600000;
const getWriteCode = (obj: object) => {
let result: number | undefined;
@ -218,7 +218,7 @@ export class SessionStore extends BaseSessionStore {
}
}
const sessionHandler = session({
const session = expressSession({
cookie: { maxAge: DEFAULT_COOKIE_ORIGINAL_MAX_AGE },
genid: ({ path }) => {
const sid = uuidgen('--random').trim();
@ -233,4 +233,4 @@ const sessionHandler = session({
store: new SessionStore(),
});
export default sessionHandler;
export default session;

Loading…
Cancel
Save