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

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

Loading…
Cancel
Save