Skip to content

Commit

Permalink
Merge branch 'back/main' of https://github.com/boostcampwm-2024/web16…
Browse files Browse the repository at this point in the history
…-JuGa into feature/api/login-#7
  • Loading branch information
jinddings committed Nov 12, 2024
2 parents e8969c7 + 392d289 commit f40807b
Show file tree
Hide file tree
Showing 31 changed files with 692 additions and 24 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches: [back/main, front/main]
pull_request:
branches: [main, back/main, dev]
branches: [back/main, front/main]

jobs:
BE-test-and-build:
Expand Down Expand Up @@ -49,7 +49,7 @@ jobs:
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: ./BE/package-lock.json
cache-dependency-path: ./FE/package-lock.json

- name: Install dependencies
working-directory: ./FE
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/deploy-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: deploy

on:
push:
branches: [main]
branches: [dev]
pull_request:
branches: [main]
branches: [dev]

env:
DOCKER_IMAGE: ${{ vars.DOCKERHUB_USERNAME }}/juga-docker
Expand All @@ -14,6 +14,7 @@ jobs:
build-and-deploy:
runs-on: ubuntu-latest
strategy:
max-parallel: 1
matrix:
app:
[
Expand All @@ -22,7 +23,7 @@ jobs:
]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
Expand All @@ -38,9 +39,11 @@ jobs:
- name: Install dependencies
working-directory: ./${{matrix.app.dir}}
continue-on-error: true
run: npm ci

- name: Run tests
if: ${{ matrix.app.name == 'be' }}
working-directory: ./${{matrix.app.dir}}
run: npm test
env:
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/deply-alpha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
build-and-deploy:
runs-on: ubuntu-latest
strategy:
max-parallel: 1
matrix:
app:
[
Expand All @@ -22,7 +23,7 @@ jobs:
]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
Expand All @@ -38,9 +39,11 @@ jobs:
- name: Install dependencies
working-directory: ./${{matrix.app.dir}}
continue-on-error: true
run: npm ci

- name: Run tests
if: ${{ matrix.app.name == 'be' }}
working-directory: ./${{matrix.app.dir}}
run: npm test
env:
Expand Down Expand Up @@ -97,7 +100,7 @@ jobs:
with:
host: ${{ secrets.NCP_ALPHA_SERVER_HOST }}
username: ${{ secrets.NCP_ALPHA_SERVER_USERNAME }}
key: ${{ secrets.NCP_ALPHA_SERVER_SSH_KEY }}
key: ${{ secrets.NCP_SERVER_SSH_KEY }}
port: 22
script: |
docker system prune -af
Expand Down
1 change: 1 addition & 0 deletions BE/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
Dockerfile
node_modules
dist
.env*
1 change: 1 addition & 0 deletions BE/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ module.exports = {
'class-methods-use-this': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/naming-convention': 'off',
},
};
19 changes: 14 additions & 5 deletions BE/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
FROM node:20
RUN mkdir -p /var/app
WORKDIR /var/app
COPY . .
# 빌드 스테이지
FROM node:20-slim as builder
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build

# 실행 스테이지
FROM node:20-slim
WORKDIR /var/app
COPY package*.json ./
RUN npm install --only=production
COPY --from=builder /app/dist ./dist

EXPOSE 3000
CMD [ "node", "dist/main.js" ]
CMD ["node", "dist/main.js"]
4 changes: 4 additions & 0 deletions BE/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { StockIndexModule } from './stock/index/stock-index.module';
import { StockTopfiveModule } from './stock/topfive/stock-topfive.module';
import { KoreaInvestmentModule } from './koreaInvestment/korea-investment.module';
import { SocketModule } from './websocket/socket.module';
import { StockOrderModule } from './stock/order/stock-order.module';
import { StockDetailModule } from './stock/detail/stock-detail.module';
import { typeOrmConfig } from './configs/typeorm.config';

@Module({
Expand All @@ -21,6 +23,8 @@ import { typeOrmConfig } from './configs/typeorm.config';
StockIndexModule,
StockTopfiveModule,
SocketModule,
StockDetailModule,
StockOrderModule,
],
controllers: [AppController],
providers: [AppService],
Expand Down
7 changes: 4 additions & 3 deletions BE/src/auth/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ export class AuthController {
) {
const { accessToken, refreshToken } =
await this.authService.kakaoLoginUser(authCredentialsDto);

res.cookie('accessToken', accessToken, { httpOnly: true });
res.cookie('refreshToken', refreshToken, { httpOnly: true });
res.cookie('isRefreshToken', true, { httpOnly: true });
return res.status(200).json({ accessToken });
return res.redirect(this.configService.get<string>('FRONTEND_URL'));
}

@ApiOperation({ summary: 'Refresh Token 요청 API' })
Expand All @@ -79,8 +79,9 @@ export class AuthController {

const newAccessToken = await this.authService.refreshToken(refreshToken);

res.cookie('accessToken', newAccessToken, { httpOnly: true });
res.cookie('refreshToken', refreshToken, { httpOnly: true });
res.cookie('isRefreshToken', true, { httpOnly: true });
return res.status(200).json({ accessToken: newAccessToken });
return res.redirect(this.configService.get<string>('FRONTEND_URL'));
}
}
5 changes: 5 additions & 0 deletions BE/src/auth/jwt-auth-guard.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { AuthGuard } from '@nestjs/passport';
import { Injectable } from '@nestjs/common';

@Injectable()
export class JwtAuthGuard extends AuthGuard('jwt') {}
6 changes: 5 additions & 1 deletion BE/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ async function bootstrap() {
setupSwagger(app);

app.enableCors({
origin: ['http://localhost:5173', 'http://223.130.151.42:3000'],
origin: [
'http://localhost:5173',
'http://223.130.151.42:5173',
'http://223.130.151.42:3000',
],
methods: 'GET, HEAD, PUT, PATH, POST, DELETE',
preflightContinue: false,
optionsSuccessStatus: 204,
Expand Down
27 changes: 27 additions & 0 deletions BE/src/stock/detail/dto/stock-detail-output1.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { ApiProperty } from '@nestjs/swagger';

export class InquirePriceOutput1Dto {
@ApiProperty({ description: 'HTS 한글 종목명' })
hts_kor_isnm: string;

@ApiProperty({ description: '종목코드' })
stck_shrn_iscd: string;

@ApiProperty({ description: '주식 현재가' })
stck_prpr: string;

@ApiProperty({ description: '전일 대비' })
prdy_vrss: string;

@ApiProperty({ description: '전일 대비 부호' })
prdy_vrss_sign: string;

@ApiProperty({ description: '전일 대비율' })
prdy_ctrt: string;

@ApiProperty({ description: 'HTS 시가총액' })
hts_avls: string;

@ApiProperty({ description: 'PER' })
per: string;
}
42 changes: 42 additions & 0 deletions BE/src/stock/detail/dto/stock-detail-output2.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { ApiProperty } from '@nestjs/swagger';

export class InquirePriceOutput2Dto {
@ApiProperty({ description: '주식 영업 일자' })
stck_bsop_date: string;

@ApiProperty({ description: '주식 종가' })
stck_clpr: string;

@ApiProperty({ description: '주식 시가' })
stck_oprc: string;

@ApiProperty({ description: '주식 최고가' })
stck_hgpr: string;

@ApiProperty({ description: '주식 최저가' })
stck_lwpr: string;

@ApiProperty({ description: '누적 거래량' })
acml_vol: string;

@ApiProperty({ description: '누적 거래 대금' })
acml_tr_pbmn: string;

@ApiProperty({ description: '락 구분 코드' })
flng_cls_code: string;

@ApiProperty({ description: '분할 비율' })
prtt_rate: string;

@ApiProperty({ description: '분할변경여부' })
mod_yn: string;

@ApiProperty({ description: '전일 대비 부호' })
prdy_vrss_sign: string;

@ApiProperty({ description: '전일 대비' })
prdy_vrss: string;

@ApiProperty({ description: '재평가사유코드' })
revl_issu_reas: string;
}
34 changes: 34 additions & 0 deletions BE/src/stock/detail/dto/stock-detail-query-parameter.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* 주식 현재가 시세 API를 사용할 때 쿼리 파라미터로 사용할 요청값 DTO
*/
export class StockDetailQueryParameterDto {
/**
* 조건 시장 분류 코드
* 'J' 주식
*/
fid_cond_mrkt_div_code: string;

/**
* 주식 종목 코드
* (ex) 005930
*/
fid_input_iscd: string;

/**
* 조회 시작일자
* (ex) 20220501
*/
fid_input_date_1: string;

/**
* 조회 종료일자
* (ex) 20220530
*/
fid_input_date_2: string;

/**
* 기간 분류 코드
* D:일봉, W:주봉, M:월봉, Y:년봉
*/
fid_period_div_code: string;
}
17 changes: 17 additions & 0 deletions BE/src/stock/detail/dto/stock-detail-request.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { ApiProperty } from '@nestjs/swagger';

/**
* 국내주식기간별시세(일/주/월/년) API를 이용할 때 필요한 요청 데이터를 담고 있는 DTO
*/
export class StockDetailRequestDto {
@ApiProperty({ description: '조회 시작일자 (ex) 20220501' })
fid_input_date_1: string;

@ApiProperty({ description: '조회 종료일자 (ex) 20220530' })
fid_input_date_2: string;

@ApiProperty({
description: '기간 분류 코드 (ex) D(일봉) W(주봉) M(월봉) Y(년봉)',
})
fid_period_div_code: string;
}
14 changes: 14 additions & 0 deletions BE/src/stock/detail/dto/stock-detail-response.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { ApiProperty } from '@nestjs/swagger';
import { InquirePriceOutput1Dto } from './stock-detail-output1.dto';
import { InquirePriceOutput2Dto } from './stock-detail-output2.dto';

/**
* 국내주식기간별시세(일/주/월/년) API 응답값 정제 후 FE에 보낼 DTO
*/
export class InquirePriceResponseDto {
@ApiProperty({ type: InquirePriceOutput1Dto, description: '상승률 순위' })
output1: InquirePriceOutput1Dto;

@ApiProperty({ type: [InquirePriceOutput2Dto], description: '하락률 순위' })
output2: InquirePriceOutput2Dto[];
}
56 changes: 56 additions & 0 deletions BE/src/stock/detail/interface/stock-detail.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
export interface InquirePriceOutput1Data {
prdy_vrss: string;
prdy_vrss_sign: string;
prdy_ctrt: string;
stck_prdy_clpr: string;
acml_vol: string;
acml_tr_pbmn: string;
hts_kor_isnm: string;
stck_prpr: string;
stck_shrn_iscd: string;
prdy_vol: string;
stck_mxpr: string;
stck_llam: string;
stck_oprc: string;
stck_hgpr: string;
stck_lwpr: string;
stck_prdy_oprc: string;
stck_prdy_hgpr: string;
stck_prdy_lwpr: string;
askp: string;
bidp: string;
prdy_vrss_vol: string;
vol_tnrt: string;
stck_fcam: string;
lstn_stcn: string;
cpfn: string;
hts_avls: string;
per: string;
eps: string;
pbr: string;
itewhol_loan_rmnd_ratem_name: string;
}

export interface InquirePriceOutput2Data {
stck_bsop_date: string;
stck_clpr: string;
stck_oprc: string;
stck_hgpr: string;
stck_lwpr: string;
acml_vol: string;
acml_tr_pbmn: string;
flng_cls_code: string;
prtt_rate: string;
mod_yn: string;
prdy_vrss_sign: string;
prdy_vrss: string;
revl_issu_reas: string;
}

export interface InquirePriceApiResponse {
output1: InquirePriceOutput1Data;
output2: InquirePriceOutput2Data[];
rt_cd: string;
msg_cd: string;
msg1: string;
}
Loading

0 comments on commit f40807b

Please sign in to comment.