-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
135 changed files
with
9,266 additions
and
88 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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Close Related Issue on Merge | ||
|
||
on: | ||
pull_request: | ||
types: [closed] | ||
branches: [dev-be, dev-fe] | ||
|
||
jobs: | ||
close-issues: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Close related issue | ||
if: ${{ github.event.pull_request.merged == true }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
ISSUE_NUMBERS=$(echo "${{ github.event.pull_request.body }}" | grep -o -E '([cC]lose #[0-9]+)' | grep -o '[0-9]\+') | ||
for ISSUE_NUMBER in $ISSUE_NUMBERS; do | ||
echo "Closing issue #$ISSUE_NUMBER" | ||
curl -X PATCH -H "Authorization: token $GITHUB_TOKEN" \ | ||
-H "Accept: application/vnd.github.v3+json" \ | ||
https://api.github.com/repos/${{ github.repository }}/issues/$ISSUE_NUMBER \ | ||
-d '{"state": "closed"}' | ||
done |
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,65 @@ | ||
name: Deploy Backend in Monorepo | ||
|
||
on: | ||
push: | ||
branches: | ||
- dev-be | ||
|
||
jobs: | ||
build-and-deploy: | ||
runs-on: ubuntu-latest | ||
|
||
services: | ||
docker: | ||
image: docker:20.10.7 | ||
options: --privileged | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Cache Yarn dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
**/node_modules | ||
~/.yarn-cache | ||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-yarn- | ||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
cache: 'yarn' | ||
|
||
- name: Install dependencies | ||
run: yarn install --frozen-lockfile | ||
|
||
- name: Build backend | ||
run: | | ||
yarn workspace backend build | ||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Build and push backend Docker image | ||
run: | | ||
docker build -t ${{ secrets.DOCKER_USERNAME }}/backend:latest -f packages/backend/Dockerfile . | ||
docker push ${{ secrets.DOCKER_USERNAME }}/backend:latest | ||
- name: Deploy to server | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.SERVER_HOST }} | ||
username: ${{ secrets.SERVER_USER }} | ||
key: ${{ secrets.SERVER_SSH_KEY}} | ||
port: ${{ secrets.SERVER_PORT }} | ||
script: | | ||
docker pull ${{ secrets.DOCKER_USERNAME }}/backend:latest | ||
docker-compose down | ||
docker-compose up -d |
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
Empty file.
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,4 +1,4 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
npx eslint --fix | ||
npx eslint --fix |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM node:20-alpine | ||
WORKDIR /packages | ||
COPY . . | ||
RUN yarn install --frozen-lockfile | ||
RUN yarn workspace backend build | ||
|
||
# 한국 시간에 맞춰 변경 | ||
RUN apk add --no-cache tzdata | ||
RUN cp /usr/share/zoneinfo/Asia/Seoul /etc/localtime && echo "Asia/Seoul" > /etc/timezone | ||
|
||
EXPOSE 3000 | ||
CMD ["yarn", "workspace", "backend", "start:prod"] |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,10 +1,39 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { AppController } from './app.controller'; | ||
import { AppService } from './app.service'; | ||
import { ConfigModule } from '@nestjs/config'; | ||
import { ScheduleModule } from '@nestjs/schedule'; | ||
import { TypeOrmModule } from '@nestjs/typeorm'; | ||
import { WinstonModule } from 'nest-winston'; | ||
import { ScraperModule } from './scraper/scraper.module'; | ||
import { AuthModule } from '@/auth/auth.module'; | ||
import { SessionModule } from '@/auth/session.module'; | ||
import { ChatModule } from '@/chat/chat.module'; | ||
import { | ||
typeormDevelopConfig, | ||
typeormProductConfig, | ||
} from '@/configs/typeormConfig'; | ||
import { logger } from '@/configs/logger.config'; | ||
import { StockModule } from '@/stock/stock.module'; | ||
import { UserModule } from '@/user/user.module'; | ||
|
||
@Module({ | ||
imports: [], | ||
controllers: [AppController], | ||
providers: [AppService], | ||
imports: [ | ||
ConfigModule.forRoot({ cache: true, isGlobal: true }), | ||
ScheduleModule.forRoot(), | ||
ScraperModule, | ||
StockModule, | ||
UserModule, | ||
TypeOrmModule.forRoot( | ||
process.env.NODE_ENV === 'production' | ||
? typeormProductConfig | ||
: typeormDevelopConfig, | ||
), | ||
WinstonModule.forRoot(logger), | ||
AuthModule, | ||
ChatModule, | ||
SessionModule, | ||
ScraperModule, | ||
], | ||
controllers: [], | ||
providers: [], | ||
}) | ||
export class AppModule {} |
This file was deleted.
Oops, something went wrong.
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,54 @@ | ||
import { Controller, Get, Post, Req, Res } from '@nestjs/common'; | ||
import { ApiOkResponse, ApiOperation, ApiTags } from '@nestjs/swagger'; | ||
import { Request, Response } from 'express'; | ||
import { sessionConfig } from '@/configs/session.config'; | ||
import { User } from '@/user/domain/user.entity'; | ||
|
||
@ApiTags('Auth') | ||
@Controller('auth') | ||
export class AuthController { | ||
@ApiOperation({ | ||
summary: '로그아웃', | ||
description: '로그아웃을 진행한다.', | ||
}) | ||
@Post('/logout') | ||
logout(@Req() req: Request, @Res() res: Response) { | ||
req.logout((err) => { | ||
if (err) { | ||
return res | ||
.status(500) | ||
.send({ message: 'Failed to logout', error: err }); | ||
} | ||
req.session.destroy((destroyErr) => { | ||
if (destroyErr) { | ||
return res | ||
.status(500) | ||
.send({ message: 'Failed to destroy session', error: destroyErr }); | ||
} | ||
res.clearCookie(sessionConfig.name || 'connect.sid'); | ||
return res.status(200).send({ message: 'Logged out successfully' }); | ||
}); | ||
}); | ||
} | ||
|
||
@ApiOperation({ | ||
summary: '로그인 상태 확인', | ||
description: '로그인 상태를 확인합니다.', | ||
}) | ||
@ApiOkResponse({ | ||
description: '로그인된 상태', | ||
example: { message: 'Authenticated' }, | ||
}) | ||
@Get('/status') | ||
async user(@Req() request: Request) { | ||
if (request.user) { | ||
const user = request.user as User; | ||
return { | ||
message: 'Authenticated', | ||
nickname: user.nickname, | ||
subName: user.subName, | ||
}; | ||
} | ||
return { message: 'Not Authenticated', nickname: null, subName: null }; | ||
} | ||
} |
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,24 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { PassportModule } from '@nestjs/passport'; | ||
import { GoogleAuthController } from '@/auth/google/googleAuth.controller'; | ||
import { GoogleAuthService } from '@/auth/google/googleAuth.service'; | ||
import { GoogleStrategy } from '@/auth/google/strategy/google.strategy'; | ||
import { AuthController } from '@/auth/auth.controller'; | ||
import { SessionSerializer } from '@/auth/session/session.serializer'; | ||
import { TesterStrategy } from '@/auth/tester/strategy/tester.strategy'; | ||
import { TesterAuthController } from '@/auth/tester/testerAuth.controller'; | ||
import { TesterAuthService } from '@/auth/tester/testerAuth.service'; | ||
import { UserModule } from '@/user/user.module'; | ||
|
||
@Module({ | ||
imports: [UserModule, PassportModule.register({ session: true })], | ||
controllers: [GoogleAuthController, TesterAuthController, AuthController], | ||
providers: [ | ||
GoogleStrategy, | ||
GoogleAuthService, | ||
SessionSerializer, | ||
TesterAuthService, | ||
TesterStrategy, | ||
], | ||
}) | ||
export class AuthModule {} |
Oops, something went wrong.