Skip to content

Commit

Permalink
Merge branch 'dev' into #159-add-typescript-support
Browse files Browse the repository at this point in the history
  • Loading branch information
kmc7468 committed Mar 20, 2024
2 parents 4af19ff + 2d01cfd commit 2fc3a0e
Show file tree
Hide file tree
Showing 67 changed files with 1,651 additions and 746 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
"@adminjs/express": "^5.1.0",
"@adminjs/mongoose": "^3.0.3",
"adminjs": "^6.8.7",
"ajv": "^8.12.0",
"ajv-errors": "^3.0.0",
"ajv-formats": "^2.1.1",
"aws-sdk": "^2.1386.0",
"axios": "^0.27.2",
"ci": "^2.2.0",
Expand All @@ -47,14 +44,17 @@
"mongoose": "^6.12.0",
"node-cron": "3.0.2",
"node-mocks-http": "^1.12.1",
"nodemailer": "^6.9.9",
"querystring": "^0.2.1",
"redis": "^4.2.0",
"response-time": "^2.3.2",
"socket.io": "^4.6.1",
"swagger-ui-express": "^4.6.0",
"validator": "^13.7.0",
"winston": "^3.8.1",
"winston-daily-rotate-file": "^4.7.1"
"winston-daily-rotate-file": "^4.7.1",
"zod": "^3.22.4",
"zod-to-json-schema": "^3.22.4"
},
"devDependencies": {
"@types/cookie-parser": "^1.4.6",
Expand Down
72 changes: 26 additions & 46 deletions pnpm-lock.yaml

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

2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ app.use(limitRateMiddleware);
// [Router] Swagger (API 문서)
app.use("/docs", docsRouter);

// 2023 추석 이벤트 전용 라우터입니다.
// [Router] 이벤트 전용 라우터입니다.
// eventConfig &&
// app.use(`/events/${eventConfig.mode}`, require("@/lottery").lotteryRouter);

Expand Down
12 changes: 7 additions & 5 deletions src/loadenv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if (process.env.DB_PATH === undefined) {
process.exit(1);
}

export const nodeEnv = process.env.NODE_ENV; // required
export const nodeEnv = process.env.NODE_ENV; // required ("production" or "development" or "test")
export const mongo = process.env.DB_PATH; // required
export const session = {
secret: process.env.SESSION_KEY || "TAXI_SESSION_KEY", // optional
Expand All @@ -31,7 +31,7 @@ export const sparcssso = {
};
export const port = process.env.PORT ? parseInt(process.env.PORT) : 80; // optional (default = 80)
export const corsWhiteList = (process.env.CORS_WHITELIST &&
JSON.parse(process.env.CORS_WHITELIST) as string[]) || [true]; // optional (default = [true])
(JSON.parse(process.env.CORS_WHITELIST) as string[])) || [true]; // optional (default = [true])
export const aws = {
accessKeyId: process.env.AWS_ACCESS_KEY_ID as string, // required
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY as string, // required
Expand All @@ -53,11 +53,13 @@ export const jwt = {
};
export const googleApplicationCredentials =
process.env.GOOGLE_APPLICATION_CREDENTIALS &&
JSON.parse(process.env.GOOGLE_APPLICATION_CREDENTIALS) as ServiceAccount; // optional
(JSON.parse(process.env.GOOGLE_APPLICATION_CREDENTIALS) as ServiceAccount); // optional
export const testAccounts =
(process.env.TEST_ACCOUNTS && JSON.parse(process.env.TEST_ACCOUNTS) as string[]) || []; // optional
(process.env.TEST_ACCOUNTS &&
(JSON.parse(process.env.TEST_ACCOUNTS) as string[])) ||
[]; // optional
export const slackWebhookUrl = {
report: process.env.SLACK_REPORT_WEBHOOK_URL || "", // optional
};
// export const eventConfig =
// process.env.EVENT_CONFIG && JSON.parse(process.env.EVENT_CONFIG);
// process.env.EVENT_CONFIG && JSON.parse(process.env.EVENT_CONFIG); // optional
30 changes: 17 additions & 13 deletions src/lottery/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,39 @@ const {
} = require("./modules/items");

const { eventConfig } = require("../../loadenv");
const contracts = eventConfig && require("./modules/contracts");

// [Routes] 기존 docs 라우터의 docs extend
eventConfig && require("./routes/docs")();

// [Schedule] 스케줄러 시작
eventConfig && require("./schedules")();

const lotteryRouter = express.Router();

// [Middleware] 모든 API 요청에 대하여 origin 검증
lotteryRouter.use(require("../middlewares/originValidator"));

// [Router] APIs
lotteryRouter.use("/global-state", require("./routes/globalState"));
lotteryRouter.use("/globalState", require("./routes/globalState"));
lotteryRouter.use("/invite", require("./routes/invite"));
lotteryRouter.use("/transactions", require("./routes/transactions"));
lotteryRouter.use("/items", require("./routes/items"));
lotteryRouter.use("/public-notice", require("./routes/publicNotice"));
lotteryRouter.use("/publicNotice", require("./routes/publicNotice"));
lotteryRouter.use("/quests", require("./routes/quests"));

const itemResource = buildResource([
addOneItemStockAction,
addFiveItemStockAction,
])(itemModel);
const otherResources = [eventStatusModel, questModel, transactionModel].map(
buildResource()
);

const contracts =
eventConfig && require(`./modules/contracts/${eventConfig.mode}`);
// [AdminJS] AdminJS에 표시할 Resource 생성
const resources =
(eventConfig && [
buildResource()(eventStatusModel),
buildResource()(questModel),
buildResource([addOneItemStockAction, addFiveItemStockAction])(itemModel),
buildResource()(transactionModel),
]) ||
[];

module.exports = {
lotteryRouter,
resources: [itemResource, ...otherResources],
contracts,
resources,
};
4 changes: 2 additions & 2 deletions src/lottery/middlewares/timestampValidator.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { eventConfig } = require("../../../loadenv");
const eventPeriod = eventConfig && {
startAt: new Date(eventConfig.startAt),
endAt: new Date(eventConfig.endAt),
startAt: new Date(eventConfig.period.startAt),
endAt: new Date(eventConfig.period.endAt),
};

const timestampValidator = (req, res, next) => {
Expand Down
Loading

0 comments on commit 2fc3a0e

Please sign in to comment.