Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/sparcs-kaist/taxi-back into #…
Browse files Browse the repository at this point in the history
…273-안-읽은-메세지-확인
  • Loading branch information
chlehdwon committed Aug 28, 2023
2 parents 9186492 + 35f8210 commit 5369fe0
Show file tree
Hide file tree
Showing 22 changed files with 8,533 additions and 21,494 deletions.
22 changes: 13 additions & 9 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
# required environment variables
PORT=[back의 port(e.g. 80)]
DB_PATH=[mongoDB path(e.g. mongodb://localhost:27017/local)]
REDIS_PATH=[redis path(e.g. redis://127.0.0.1:6379)]
SESSION_KEY=[세션 비밀번호(임의 값 아무거나 설정하면 된다)]
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]
AWS_S3_BUCKET_NAME=[AWS S3 Bucket name]
AWS_S3_URL=[AWS S3 url(e.g. https://<bucket-name>.s3.<region>.amazonaws.com)]
JWT_SECRET_KEY=[JWT SERCRET KEY]
APP_URI_SCHEME=[APP_URI_SCHEME]
GOOGLE_APPLICATION_CREDENTIALS=[GOOGLE APPLICATION CREDENTIALS JSON]

# optional environment variables
REDIS_PATH=[redis path(e.g. redis://127.0.0.1:6379)]
SESSION_KEY=[세션 관리에 사용되는 키(임의 값 아무거나 설정하면 된다)]
JWT_SECRET_KEY=[JWT 관리에 사용되는 키(임의 값 아무거나 설정하면 된다)]
SPARCSSSO_CLIENT_ID=[스팍스SSO ID]
SPARCSSSO_CLIENT_KEY=[스팍스SSO PW]
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]
16 changes: 10 additions & 6 deletions .github/workflows/test_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@ jobs:
uses: actions/checkout@v3
with:
submodules: true
- name: Setup Node
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
node-version: 16

- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: 8
- id: submodule-local
name: Save local version of submodule
run: echo "ver=`cd sampleGenerator && git log --pretty="%h" -1 && cd ..`" >> $GITHUB_OUTPUT
Expand All @@ -39,11 +43,11 @@ jobs:
script: |
core.setFailed('Please update submodule to the latest version by using \"git submodule update --remote\"')
- name: Install sampleGenerator dependencies from package-lock.json
run: cd sampleGenerator && npm ci && cd ..
run: cd sampleGenerator && pnpm i --force --frozen-lockfile && cd ..
- name: Install taxi-back dependencies from package-lock.json
run: npm ci
run: pnpm i --force --frozen-lockfile
- name: Run unit tests
run: npm test
run: pnpm run test
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_S3_BUCKET_NAME: ${{ secrets.AWS_S3_BUCKET_NAME }}
Expand Down
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ $ npm install --save

### Set Environment Configuration
See [notion page](https://www.notion.so/sparcs/Environment-Variables-1b404bd385fa495bac6d5517b57d72bf).
Refer to [.env.example](.env.example) and write your own `.env.development` and `.env.test`.
Refer to [.env.example](.env.example) and write your own `.env`.

## Backend Route Information
See [Backend Route Documentation](src/routes/docs/README.md)
Expand Down
7 changes: 4 additions & 3 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ app.use(express.urlencoded({ extended: false }));
app.use(express.json());

// [Middleware] CORS 설정
app.use(
require("cors")({ origin: true, credentials: true, exposedHeaders: ["Date"] })
);
app.use(require("./src/middlewares/cors"));

// [Middleware] 세션 및 쿠키
const session = require("./src/middlewares/session");
Expand Down Expand Up @@ -50,6 +48,9 @@ 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)
Expand Down
8 changes: 4 additions & 4 deletions loadenv.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ module.exports = {
key: process.env.SPARCSSSO_CLIENT_KEY || "", // optional
},
port: process.env.PORT || 80, // optional (default = 80)
frontUrl: process.env.FRONT_URL || "http://localhost:3000", // optional (default = "http://localhost:3000")
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
Expand All @@ -29,12 +30,11 @@ module.exports = {
TOKEN_EXPIRED: -3,
TOKEN_INVALID: -2,
},
appUriScheme: process.env.APP_URI_SCHEME, // FIXME: 사용하지 않음
googleApplicationCredentials:
process.env.GOOGLE_APPLICATION_CREDENTIALS &&
JSON.parse(process.env.GOOGLE_APPLICATION_CREDENTIALS),
JSON.parse(process.env.GOOGLE_APPLICATION_CREDENTIALS), // optional
testAccounts:
process.env.TEST_ACCOUNTS && JSON.parse(process.env.TEST_ACCOUNTS),
(process.env.TEST_ACCOUNTS && JSON.parse(process.env.TEST_ACCOUNTS)) || [], // optional
slackWebhookUrl: {
report: process.env.SLACK_REPORT_WEBHOOK_URL || "", // optional
},
Expand Down
Loading

0 comments on commit 5369fe0

Please sign in to comment.