-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into #156-move-rooms-to-the-past-room-list-and-cha…
…nge-settlestatus-automatically-when-the-participant-is-one
- Loading branch information
Showing
102 changed files
with
12,043 additions
and
17,876 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,18 @@ | ||
# required environment variables | ||
PORT=[back의 port(e.g. 80)] | ||
DB_PATH=[mongoDB path(e.g. mongodb://localhost:27017/local)] | ||
AWS_ACCESS_KEY_ID=[AWS Access key ID] | ||
AWS_SECRET_ACCESS_KEY=[AWS Secret access key] | ||
AWS_S3_BUCKET_NAME=[AWS S3 Bucket name] | ||
AWS_S3_URL=[AWS S3 url(e.g. https://<bucket-name>.s3.<region>.amazonaws.com)] | ||
|
||
# optional environment variables | ||
REDIS_PATH=[redis path(e.g. redis://127.0.0.1:6379)] | ||
SESSION_KEY=[세션 비밀번호(임의 값 아무거나 설정하면 된다)] | ||
SESSION_KEY=[세션 관리에 사용되는 키(임의 값 아무거나 설정하면 된다)] | ||
JWT_SECRET_KEY=[JWT 관리에 사용되는 키(임의 값 아무거나 설정하면 된다)] | ||
SPARCSSSO_CLIENT_ID=[스팍스SSO ID] | ||
SPARCSSSO_CLIENT_KEY=[스팍스SSO PW] | ||
FRONT_URL=[front url(e.g. http://localhost:3000)] | ||
AWS_ACCESS_KEY_ID=[AWS Access key ID] | ||
AWS_SECRET_ACCESS_KEY=[AWS Secret access key] | ||
AWS_S3_BUCKET_NAME=[AWS S3 Buck name] | ||
JWT_SECRET_KEY=[JWT SERCRET KEY] | ||
APP_URI_SCHEME=[APP_URI_SCHEME] | ||
CORS_WHITELIST=[CORS 정책에서 허용하는 도메인의 목록(e.g. ["http://localhost:3000"])] | ||
GOOGLE_APPLICATION_CREDENTIALS=[GOOGLE_APPLICATION_CREDENTIALS JSON] | ||
TEST_ACCOUNTS=[스팍스SSO로 로그인시 무조건 테스트로 로그인이 가능한 허용 아이디 목록] | ||
SLACK_REPORT_WEBHOOK_URL=[Slack 웹훅 URL들이 담긴 JSON] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,5 +10,6 @@ module.exports = { | |
}, | ||
rules: { | ||
"no-unused-vars": 1, | ||
"mocha/no-mocha-arrows": 0, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,4 @@ | |
/logs/*.log | ||
|
||
# AdminJS 관련 디렉토리 | ||
.adminjs | ||
.adminjs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
[submodule "sampleGenerator"] | ||
path = sampleGenerator | ||
url = https://github.com/sparcs-kaist/taxiSampleGenerator | ||
branch = main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,11 +6,13 @@ COPY . . | |
|
||
# Install curl (for taxi-docker) | ||
RUN apk update && apk add curl | ||
RUN npm install --global [email protected] [email protected] | ||
|
||
# Install requirements | ||
RUN npm ci | ||
RUN pnpm i --force --frozen-lockfile | ||
|
||
# Run container | ||
EXPOSE 80 | ||
ENV PORT 80 | ||
CMD ["npm", "run", "serve"] | ||
CMD ["pnpm", "run", "serve"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,68 @@ | ||
// 외부 모듈 require | ||
// 모듈 require | ||
const express = require("express"); | ||
const http = require("http"); | ||
|
||
const cookieParser = require("cookie-parser"); | ||
const cors = require("cors"); | ||
|
||
// 내부 모듈 | ||
const security = require("./security"); | ||
const { port: httpPort } = require("./loadenv"); | ||
const logger = require("./src/modules/logger"); | ||
const logAPIAccess = require("./src/modules/logAPIAccess"); | ||
const startSocketServer = require("./src/modules/socket"); | ||
const { startSocketServer } = require("./src/modules/socket"); | ||
|
||
// Firebase Admin 초기설정 | ||
require("./src/modules/fcm").initializeApp(); | ||
|
||
// 익스프레스 서버 생성 | ||
const app = express(); | ||
|
||
// [Middleware] request body 파싱 | ||
app.use(express.urlencoded({ extended: false })); | ||
app.use(express.json()); | ||
app.use(cors({ origin: true, credentials: true })); | ||
|
||
// 세션 및 쿠키 | ||
const session = require("./src/middleware/session"); | ||
// [Middleware] CORS 설정 | ||
app.use(require("./src/middlewares/cors")); | ||
|
||
// [Middleware] 세션 및 쿠키 | ||
const session = require("./src/middlewares/session"); | ||
app.use(session); | ||
app.use(cookieParser()); | ||
app.use(require("cookie-parser")()); | ||
|
||
// API 접근 기록 및 응답 시간을 http response의 헤더에 기록합니다. | ||
app.use(require("response-time")(logAPIAccess)); | ||
// [Middleware] Timestamp 및 clientIP 확인 | ||
app.use(require("./src/middlewares/information")); | ||
|
||
// admin 페이지는 rate limiting을 적용하지 않습니다. | ||
app.use("/admin", require("./src/route/admin")); | ||
// [Middleware] API 접근 기록 및 응답 시간을 http response의 헤더에 기록합니다. | ||
app.use(require("./src/middlewares/responseTime")); | ||
|
||
// Apply the rate limiting middleware to all requests | ||
app.use(require("./src/middleware/limitRate")); | ||
// [Router] admin 페이지는 rate limiting을 적용하지 않습니다. | ||
app.use("/admin", require("./src/routes/admin")); | ||
|
||
// 라우터 및 리액트 | ||
// /rooms/v2에 요청을 보내는 기존 클라이언트 코드 호환성 유지 | ||
app.use("/auth", require("./src/route/auth")); | ||
app.use("/json/logininfo", require("./src/route/logininfo")); | ||
app.use("/users", require("./src/route/users")); | ||
app.use(["/rooms/v2", "/rooms"], require("./src/route/rooms")); | ||
app.use("/chats", require("./src/route/chats")); | ||
app.use("/locations", require("./src/route/locations")); | ||
app.use("/reports", require("./src/route/reports")); | ||
// [Middleware] 모든 요청에 대하여 rate limiting 적용 | ||
app.use(require("./src/middlewares/limitRate")); | ||
|
||
// [Router] Swagger (API 문서) | ||
app.use("/docs", require("./src/routes/docs")); | ||
|
||
// [Middleware] 모든 API 요청에 대하여 origin 검증 | ||
app.use(require("./src/middlewares/originValidator")); | ||
|
||
// [Router] APIs | ||
app.use("/auth", require("./src/routes/auth")); | ||
app.use("/logininfo", require("./src/routes/logininfo")); | ||
app.use("/users", require("./src/routes/users")); | ||
app.use("/rooms", require("./src/routes/rooms")); | ||
app.use("/chats", require("./src/routes/chats")); | ||
app.use("/locations", require("./src/routes/locations")); | ||
app.use("/reports", require("./src/routes/reports")); | ||
app.use("/notifications", require("./src/routes/notifications")); | ||
|
||
// [Middleware] 전역 에러 핸들러. 에러 핸들러는 router들보다 아래에 등록되어야 합니다. | ||
app.use(require("./src/middlewares/errorHandler")); | ||
|
||
// express 서버 시작 | ||
const serverHttp = http.createServer(app).listen(security.port, () => { | ||
logger.info(`Express 서버가 ${security.port}번 포트에서 시작됨.`); | ||
}); | ||
const serverHttp = http | ||
.createServer(app) | ||
.listen(httpPort, () => | ||
logger.info(`Express 서버가 ${httpPort}번 포트에서 시작됨.`) | ||
); | ||
|
||
// socket.io 서버 시작 | ||
app.set("io", startSocketServer(serverHttp)); | ||
|
||
// socket.io 서버 시작 및 app 인스턴스에 저장 | ||
app.set("io", startSocketServer(serverHttp, session)); | ||
// [Schedule] 스케줄러 시작 | ||
require("./src/schedules")(app); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// 환경 변수에 따라 .env.production 또는 .env.development 파일을 읽어옴 | ||
require("dotenv").config({ path: `./.env.${process.env.NODE_ENV}` }); | ||
|
||
module.exports = { | ||
nodeEnv: process.env.NODE_ENV, | ||
mongo: process.env.DB_PATH, // required | ||
session: process.env.SESSION_KEY || "TAXI_SESSION_KEY", // optional | ||
redis: process.env.REDIS_PATH, // optional | ||
sparcssso: { | ||
id: process.env.SPARCSSSO_CLIENT_ID || "", // optional | ||
key: process.env.SPARCSSSO_CLIENT_KEY || "", // optional | ||
}, | ||
port: process.env.PORT || 80, // optional (default = 80) | ||
corsWhiteList: (process.env.CORS_WHITELIST && | ||
JSON.parse(process.env.CORS_WHITELIST)) || [true], // optional (default = [true]) | ||
aws: { | ||
accessKeyId: process.env.AWS_ACCESS_KEY_ID, // required | ||
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY, // required | ||
s3BucketName: process.env.AWS_S3_BUCKET_NAME, // required | ||
s3Url: | ||
process.env.AWS_S3_URL || | ||
`https://${process.env.AWS_S3_BUCKET_NAME}.s3.ap-northeast-2.amazonaws.com`, // optional | ||
}, | ||
jwt: { | ||
secretKey: process.env.JWT_SECRET_KEY || "TAXI_JWT_KEY", | ||
option: { | ||
algorithm: "HS256", | ||
issuer: process.env.FRONT_URL || "http://localhost:3000", // optional (default = "http://localhost:3000") | ||
}, | ||
TOKEN_EXPIRED: -3, | ||
TOKEN_INVALID: -2, | ||
}, | ||
googleApplicationCredentials: | ||
process.env.GOOGLE_APPLICATION_CREDENTIALS && | ||
JSON.parse(process.env.GOOGLE_APPLICATION_CREDENTIALS), // optional | ||
testAccounts: | ||
(process.env.TEST_ACCOUNTS && JSON.parse(process.env.TEST_ACCOUNTS)) || [], // optional | ||
slackWebhookUrl: { | ||
report: process.env.SLACK_REPORT_WEBHOOK_URL || "", // optional | ||
}, | ||
}; |
Oops, something went wrong.