Skip to content

Commit

Permalink
Refactor: migrate modules/stores/sessionStore to TS
Browse files Browse the repository at this point in the history
  • Loading branch information
kmc7468 committed Feb 2, 2024
1 parent db8ce7e commit b6cdd88
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"axios": "^0.27.2",
"ci": "^2.2.0",
"connect-mongo": "^4.6.0",
"connect-redis": "^6.1.3",
"connect-redis": "^7.1.1",
"cookie-parser": "^1.4.5",
"cors": "^2.8.5",
"cross-env": "^7.0.3",
Expand Down
14 changes: 9 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
const expressSession = require("express-session");
const redis = require("redis");
const MongoStore = require("connect-mongo");
const RedisStore = require("connect-redis")(expressSession);
const {
redis: redisUrl,
mongo: mongoUrl,
session: sessionConfig,
} = require("@/loadenv");
const logger = require("@/modules/logger");
import MongoStore from "connect-mongo";
import RedisStore from "connect-redis"
import redis from "redis";
import { redis as redisUrl, mongo as mongoUrl, session as sessionConfig } from "@/loadenv";
import logger from "@/modules/logger";

const getSessionStore = (redisUrl) => {
const getSessionStore = () => {
// 환경변수 REDIS_PATH 유무에 따라 session 저장 방식이 변경됩니다.
if (redisUrl) {
const client = redis.createClient({
url: redisUrl,
legacyMode: true,
});

// redis client 연결 성공 시 로그를 출력합니다.
Expand All @@ -34,4 +28,4 @@ const getSessionStore = (redisUrl) => {
}
};

module.exports = getSessionStore(redisUrl);
export default getSessionStore();

0 comments on commit b6cdd88

Please sign in to comment.