Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Main branch update from Dev branch #432

Merged
merged 51 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
ef92153
Docs: auth.js
chlehdwon Apr 3, 2023
fa3c2c6
Docs: add format
chlehdwon Apr 4, 2023
3028de0
Docs: add /auth/spacssso/*
chlehdwon Sep 18, 2023
51fbd70
Merge branch 'main' into #135.5-docs-auth
chlehdwon Sep 18, 2023
065827e
Docs: auth.js basic format done
chlehdwon Sep 19, 2023
0ca21b6
Remove: auth.md
chlehdwon Sep 19, 2023
a8ea852
Merge branch 'dev' of https://github.com/sparcs-kaist/taxi-back into …
chlehdwon Sep 24, 2023
b936c65
Remove: error messages
chlehdwon Sep 24, 2023
33a1171
Docs: remove reports.js errors
chlehdwon Sep 24, 2023
77123ed
Fix: skip validation for trust proxy setting in rate-limit middleware
withSang Oct 7, 2023
73e3c00
Refactor: force node.js >= 18
withSang Oct 7, 2023
02d8127
Fix: specify strictQuery to Mongoose
withSang Oct 7, 2023
c505824
Refactor: update Node.js version of Dockerfile & Actions
withSang Oct 7, 2023
2b55880
Add: add pnpm cache for CI workflow
withSang Oct 7, 2023
bd26b54
Refactor: use pnpm fetch for better caching
withSang Oct 7, 2023
6816589
Refactor: cache github actions to build image
withSang Oct 7, 2023
a839177
Fix: bump dependencies
withSang Oct 7, 2023
8367363
Fix: remove FRONT_URL in CI workflow
withSang Oct 7, 2023
8da0013
Refactor: move test codes into /test/services
withSang Oct 7, 2023
660a232
Refactor: bump jsonwebtoken version to ^9.0.2
withSang Oct 7, 2023
b9fa443
Docs: add issue link to fixme
withSang Oct 7, 2023
8bda357
Fix: remove wrong step name in CI workflow
withSang Oct 7, 2023
e55481c
Docs: update Node.js version in README
withSang Oct 7, 2023
0a72cc9
Merge branch 'dev' into #404-update-nodejs-to-18
withSang Oct 9, 2023
2b772c4
Merge pull request #413 from sparcs-kaist/#404-update-nodejs-to-18
withSang Oct 9, 2023
7a59b03
Fix: specify push: true in Docker Action
withSang Oct 9, 2023
3ec2a9a
Merge branch 'main' of https://github.com/sparcs-kaist/taxi-back into…
chlehdwon Oct 11, 2023
d4ac34e
Merge pull request #420 from sparcs-kaist/#419-bug-github-actions-pus…
14KGun Oct 24, 2023
fd3c823
Remove: default eventConfig value
kmc7468 Oct 24, 2023
5197265
Merge pull request #422 from sparcs-kaist/#421-disable-chuseok-event
kmc7468 Oct 24, 2023
3f56ed0
Add: reset user nickname and reset user profile image
TaehyeonPark Oct 26, 2023
e1aefcb
Add: swagger docs users
TaehyeonPark Oct 26, 2023
7ba8676
Fix: auth nickname generation
TaehyeonPark Oct 26, 2023
c234823
Refactor: early return pattern
TaehyeonPark Oct 26, 2023
0a858ae
Merge pull request #425 from sparcs-kaist/#423-set-nickname-and-profi…
TaehyeonPark Oct 26, 2023
6a0ce8c
Merge branch 'dev' of https://github.com/sparcs-kaist/taxi-back into …
chlehdwon Oct 31, 2023
99440bf
Fix: add session cookie expiry
withSang Oct 31, 2023
dd6d4fe
Docs: add error examples in the auth document
chlehdwon Nov 2, 2023
b4fbb42
Docs: rollback name
chlehdwon Nov 2, 2023
e7d1e3c
Docs: align docs style with the recent documents
chlehdwon Nov 2, 2023
2301c54
Docs: update error message
chlehdwon Nov 2, 2023
d4e3d51
Merge branch 'main' of https://github.com/sparcs-kaist/taxi-back into…
chlehdwon Nov 2, 2023
28606c6
Fix: add server in the swagger option
chlehdwon Nov 2, 2023
aa330f4
Fix: change serverList to test all servers in local
chlehdwon Nov 2, 2023
319e38a
Merge pull request #262 from sparcs-kaist/#135.5-docs-auth
chlehdwon Nov 3, 2023
8fb4574
Merge remote-tracking branch 'origin/dev' into #188.3-set-session-expiry
withSang Nov 7, 2023
89d4791
Fix: remove rolling session
withSang Nov 7, 2023
f03e0a1
Merge pull request #427 from sparcs-kaist/#426-bug-swagger-api-test
chlehdwon Nov 7, 2023
e966ab4
Fix: retry connection to redis when lost
withSang Nov 7, 2023
6c1c9c6
Merge branch 'dev' into #188.3-set-session-expiry
withSang Nov 7, 2023
d4893b0
Merge pull request #429 from sparcs-kaist/#188.3-set-session-expiry
withSang Nov 9, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 26 additions & 7 deletions .github/workflows/push_image_ecr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ jobs:
with:
fetch-depth: 0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-

- name: Get previous tag-version
id: previous_tag
uses: WyriHaximus/github-action-get-previous-tag@v1
Expand All @@ -47,15 +58,23 @@ jobs:
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1

- name: Build and Push to AWS ECR
id: build_image
- name: Build Image and Push to AWS ECR
id: build_image_and_push
uses: docker/build-push-action@v5
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: ${{ steps.tag.outputs.tag }}
ECR_REPOSITORY: taxi-back
with:
push: true
tags: |
"${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}"
"${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:latest"
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new

- name: Remove old cache
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:latest .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
echo "Push iamge : $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG and latest"
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache

32 changes: 25 additions & 7 deletions .github/workflows/push_image_ecr_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,18 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 0


- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
Expand All @@ -31,13 +42,20 @@ jobs:
- name: Login to AWS ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1

- name: Build and Push to AWS ECR
id: build_image

- name: Build Image and Push to AWS ECR
id: build_image_and_push
uses: docker/build-push-action@v5
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: taxi-back
with:
push: true
tags: "${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:dev"
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new

- name: Remove old cache
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:dev .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:dev
echo "Push iamge : $ECR_REGISTRY/$ECR_REPOSITORY:dev"
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
20 changes: 9 additions & 11 deletions .github/workflows/test_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,23 @@ jobs:
strategy:
matrix:
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
node-version: [16.x]
node-version: ['18.x']
mongodb-version: ['5.0']
steps:
- name: Start MongoDB
run: sudo docker run --name mongodb -d -p 27017:27017 mongo:${{ matrix.mongodb-version }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/checkout@v3
- uses: actions/checkout@v3
with:
submodules: true
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16

- uses: pnpm/action-setup@v2
name: Install pnpm
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: Install Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- id: submodule-local
name: Save local version of submodule
run: echo "ver=`cd sampleGenerator && git log --pretty="%h" -1 && cd ..`" >> $GITHUB_OUTPUT
Expand All @@ -53,6 +52,5 @@ jobs:
AWS_S3_BUCKET_NAME: ${{ secrets.AWS_S3_BUCKET_NAME }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
DB_PATH: ${{ secrets.DB_PATH }}
FRONT_URL: ${{ secrets.FRONT_URL }}
PORT: ${{ secrets.PORT }}
SESSION_KEY: ${{ secrets.SESSION_KEY }}
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Force Node.js and pnpm versions according to package.json
engine-strict=true
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v18.17.0
21 changes: 12 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
FROM node:16-alpine
FROM node:18-alpine

# Copy repository
WORKDIR /usr/src/app
COPY . .

# Install curl (for taxi-docker)
RUN apk update && apk add curl
RUN npm install --global [email protected] [email protected]
# Install curl(for taxi-watchtower) and pnpm
RUN apk update && apk add curl && npm install --global [email protected]

# Install requirements
RUN pnpm i --force --frozen-lockfile
# pnpm fetch does require only lockfile
COPY pnpm-lock.yaml .

# Note: devDependencies are not fetched
RUN pnpm fetch --prod

# Copy repository and install dependencies
ADD . ./
RUN pnpm install --offline --prod

# Run container
EXPOSE 80
ENV PORT 80
CMD ["pnpm", "run", "serve"]

15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ Taxi는 KAIST 구성원들의 택시 동승 인원 모집을 위한 서비스입
- Notion : [Sparcs Notion Taxi page](https://www.notion.so/sparcs/Taxi-9d371e8ac5ac4f0c9b9c35869682a0eb) (Only SPARCS members can access it)
- Slack : #taxi-main, #taxi-notice, #taxi-bug-report, #taxi-github-bot, #taxi-notion-bot (Only SPARCS members can access it)

## Prerequisites
- Recommended npm version : 8.5.5 (with node v.16.15.0)
- Recommended mognoDB version : 5.0.8
- [Issue with node version](https://github.com/sparcs-kaist/taxi-front/issues/76)
## Prerequisite

- Recommended node version : >=18.0.0 (Node v18.18.0, for example)
- Recommended pnpm version : >=8.0.0 (pmpm v8.8.0, for example)
- Recommended mongoDB version : 5.0.8

## Project Setup

Expand All @@ -24,15 +25,17 @@ $ git clone https://github.com/sparcs-kaist/taxi-back

### Install Requirements
```bash
$ npm install --save
$ pnpm install
```

### 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`.

## Backend Route Information
See [Backend Route Documentation](src/routes/docs/README.md)
API specification is defined on Swagger.
Start development server and visit `/docs` to see the specification of each endpoint.
Some endpoints are not documented in Swagger yet. For those endpoints, refer to [routes/docs/README.md](./src/routes/docs/README.md).

## License
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details
Expand Down
4 changes: 2 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// 모듈 require
const express = require("express");
const http = require("http");
const { port: httpPort, eventConfig } = require("./loadenv");
const { nodeEnv, port: httpPort, eventConfig } = require("./loadenv");
const logger = require("./src/modules/logger");
const { connectDatabase } = require("./src/modules/stores/mongo");
const { startSocketServer } = require("./src/modules/socket");
Expand All @@ -20,7 +20,7 @@ app.use(express.urlencoded({ extended: false }));
app.use(express.json());

// reverse proxy가 설정한 헤더를 신뢰합니다.
app.set("trust proxy", true);
if (nodeEnv === "production") app.set("trust proxy", 1);

// [Middleware] CORS 설정
app.use(require("./src/middlewares/cors"));
Expand Down
16 changes: 8 additions & 8 deletions loadenv.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
require("dotenv").config({ path: `./.env.${process.env.NODE_ENV}` });

module.exports = {
nodeEnv: process.env.NODE_ENV,
nodeEnv: process.env.NODE_ENV, // required
mongo: process.env.DB_PATH, // required
session: process.env.SESSION_KEY || "TAXI_SESSION_KEY", // optional
session: {
secret: process.env.SESSION_KEY || "TAXI_SESSION_KEY", // optional
expiry: 14 * 24 * 3600 * 1000, // 14일, ms 단위입니다.
},
redis: process.env.REDIS_PATH, // optional
sparcssso: {
id: process.env.SPARCSSSO_CLIENT_ID || "", // optional
Expand All @@ -25,6 +28,8 @@ module.exports = {
secretKey: process.env.JWT_SECRET_KEY || "TAXI_JWT_KEY",
option: {
algorithm: "HS256",
// FIXME: remove FRONT_URL from issuer. 단, issuer를 변경하면 이전에 발급했던 모든 JWT가 무효화됩니다.
// See https://github.com/sparcs-kaist/taxi-back/issues/415
issuer: process.env.FRONT_URL || "http://localhost:3000", // optional (default = "http://localhost:3000")
},
TOKEN_EXPIRED: -3,
Expand All @@ -38,10 +43,5 @@ module.exports = {
slackWebhookUrl: {
report: process.env.SLACK_REPORT_WEBHOOK_URL || "", // optional
},
eventConfig: (process.env.EVENT_CONFIG &&
JSON.parse(process.env.EVENT_CONFIG)) || {
mode: "2023fall",
startAt: "2023-09-25T00:00:00+09:00",
endAt: "2023-10-12T00:00:00+09:00",
},
eventConfig: process.env.EVENT_CONFIG && JSON.parse(process.env.EVENT_CONFIG),
};
40 changes: 22 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,22 @@
"name": "taxi-back",
"version": "1.0.0",
"description": "KAIST Taxi Party Matching Web Service",
"author": "sparcs/taxi",
"license": "MIT",
"main": "app.js",
"scripts": {
"preinstall": "npx only-allow pnpm",
"start": "cross-env TZ='Asia/Seoul' npx nodemon app.js",
"test": "npm run sample && cross-env TZ='Asia/Seoul' npm run mocha",
"mocha": "cross-env TZ='Asia/Seoul' NODE_ENV=test mocha --recursive --reporter spec --exit",
"serve": "cross-env TZ='Asia/Seoul' NODE_ENV=production node app.js",
"lint": "npx eslint --fix .",
"sample": "cd sampleGenerator && npm start && cd .."
},
"engines": {
"node": ">=18.0.0",
"pnpm": ">=8.0.0"
},
"dependencies": {
"@adminjs/express": "^5.1.0",
"@adminjs/mongoose": "^3.0.3",
Expand All @@ -22,12 +37,12 @@
"eslint-config-prettier": "^8.3.0",
"express": "^4.17.1",
"express-formidable": "^1.2.0",
"express-rate-limit": "^6.6.0",
"express-rate-limit": "^7.1.0",
"express-session": "^1.17.3",
"express-validator": "^6.14.0",
"firebase-admin": "^11.4.1",
"jsonwebtoken": "^8.5.1",
"mongoose": "^6.11.3",
"jsonwebtoken": "^9.0.2",
"mongoose": "^6.12.0",
"node-cron": "3.0.2",
"node-mocks-http": "^1.12.1",
"querystring": "^0.2.1",
Expand All @@ -40,22 +55,11 @@
"winston-daily-rotate-file": "^4.7.1"
},
"devDependencies": {
"chai": "*",
"chai": "^4.3.10",
"eslint": "^8.22.0",
"eslint-plugin-mocha": "^10.1.0",
"mocha": "*",
"nodemon": "^2.0.14",
"mocha": "^10.2.0",
"nodemon": "^3.0.1",
"supertest": "^6.2.4"
},
"scripts": {
"preinstall": "npx only-allow pnpm",
"start": "cross-env TZ='Asia/Seoul' npx nodemon app.js",
"test": "npm run sample && cross-env TZ='Asia/Seoul' npm run mocha",
"mocha": "cross-env TZ='Asia/Seoul' NODE_ENV=test mocha --recursive --reporter spec --exit",
"serve": "cross-env TZ='Asia/Seoul' NODE_ENV=production node app.js",
"lint": "npx eslint --fix .",
"sample": "cd sampleGenerator && npm start && cd .."
},
"author": "sparcs/taxi",
"license": "MIT"
}
}
Loading