From 8a69eb4b712ea6f165b364785da7310c343e9344 Mon Sep 17 00:00:00 2001 From: kim jong hwa Date: Fri, 3 Nov 2023 10:14:38 +0900 Subject: [PATCH] =?UTF-8?q?[=EC=9E=91=EC=97=85=EC=99=84=EB=A3=8C]:=20?= =?UTF-8?q?=EB=B0=B0=ED=8F=AC=20=EC=A0=84=20=EC=BD=98=EC=86=94=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/nest_lm copy 2.yml | 92 ---------------------------- src/events/dto/update-event.dto.ts | 2 + src/events/events.controller.ts | 24 ++++---- src/events/events.service.ts | 4 +- src/searches/searches.controller.ts | 6 +- 5 files changed, 18 insertions(+), 110 deletions(-) delete mode 100644 .github/workflows/nest_lm copy 2.yml diff --git a/.github/workflows/nest_lm copy 2.yml b/.github/workflows/nest_lm copy 2.yml deleted file mode 100644 index 835b431..0000000 --- a/.github/workflows/nest_lm copy 2.yml +++ /dev/null @@ -1,92 +0,0 @@ -# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs - -name: nest_lm CI - -on: - push: - branches: [ "main" ] - -env: - PROJECT_NAME: ${{ secrets.PROJECT_NAME }} - BUCKET_NAME: ${{ secrets.BUCKET_NAME }} - CODE_DEPLOY_APP_NAME: ${{ secrets.CODE_DEPLOY_APP_NAME }} - DEPLOYMENT_GROUP_NAME: ${{ secrets.DEPLOYMENT_GROUP_NAME }} - -jobs: - build: - - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [18.x] - - steps: - - name: Checkout Repository - uses: actions/checkout@v3 - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - cache: 'npm' - - - name: Install Dependencies - run: npm ci - - - name: Build (if present) - run: npm run build --if-present - - - name: Create .env file - run: | - echo "DATABASE_URL=${{ secrets.DATABASE_URL }}" > .env - echo "JWT_ACCESS_KEY=${{ secrets.JWT_ACCESS_KEY }}" >> .env - echo "JWT_REFRESH_KEY=${{ secrets.JWT_REFRESH_KEY }}" >> .env - echo "KAKAO_CLIENT_ID=${{ secrets.KAKAO_CLIENT_ID }}" >> .env - echo "KAKAO_CLIENT_SECRET=${{ secrets.KAKAO_CLIENT_SECRET }}" >> .env - echo "KAKAO_CALLBACK_URL=${{ secrets.KAKAO_CALLBACK_URL }}" >> .env - echo "EMAIL_USER=${{ secrets.EMAIL_USER }}" >> .env - echo "EMAIL_PASS=${{ secrets.EMAIL_PASS }}" >> .env - echo "AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }}" >> .env - echo "AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_PRIVATE_ACCESS_KEY }}" >> .env - echo "AWS_REGION=${{ secrets.AWS_REGION }}" >> .env - echo "AWS_BUCKET_NAME=${{ secrets.AWS_BUCKET_NAME }}" >> .env - echo "GOOGLE_CLIENT_ID=${{ secrets.GOOGLE_CLIENT_ID }}" >> .env - echo "GOOGLE_CLIENT_SECRET=${{ secrets.GOOGLE_CLIENT_SECRET }}" >> .env - echo "GOOGLE_CALLBACK_URL=${{ secrets.GOOGLE_CALLBACK_URL }}" >> .env - echo "NAVER_CLIENT_ID=${{ secrets.NAVER_CLIENT_ID }}" >> .env - echo "NAVER_CLIENT_SECRET=${{ secrets.NAVER_CLIENT_SECRET }}" >> .env - echo "NAVER_CALLBACK_URL=${{ secrets.NAVER_CALLBACK_URL }}" >> .env - working-directory: ./ - - # S3로 보낼 압축 파일 생성 - - name: zip file - run: | - # zip으로 압축파일 생성 - # CI.zip은 압축 파일 이름, 나머지는 압축할 코드 파일 또는 폴더를 지정합니다. - # workflow와 동일한 위치의 폴더와 파일을 압축합니다. - zip -qq -r ./$GITHUB_SHA.zip . - - # AWS 인증하기 - - name: AWS configure credentials - uses: aws-actions/configure-aws-credentials@v3 - with: - # 엑세스 키 입력 - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - # 엑세스 시크릿 키 입력 - aws-secret-access-key: ${{ secrets.AWS_PRIVATE_ACCESS_KEY }} - # 지역 설정: 서울 - aws-region: ${{ secrets.AWS_REGION }} - - # S3로 업로드하기 - - name: upload to S3 - run: aws s3 cp ./$GITHUB_SHA.zip s3://$BUCKET_NAME/$PROJECT_NAME/$GITHUB_SHA.zip - - # codeDeploy 실행 - - name: request deploy to codedeploy - run: aws deploy create-deployment - --application-name $CODE_DEPLOY_APP_NAME - --deployment-config-name CodeDeployDefault.AllAtOnce - --deployment-group-name $DEPLOYMENT_GROUP_NAME - --s3-location bucket=$BUCKET_NAME,bundleType=zip,key=$PROJECT_NAME/$GITHUB_SHA.zip diff --git a/src/events/dto/update-event.dto.ts b/src/events/dto/update-event.dto.ts index 9c0f7e2..d7e30fe 100644 --- a/src/events/dto/update-event.dto.ts +++ b/src/events/dto/update-event.dto.ts @@ -6,6 +6,7 @@ import { Min, MaxLength, IsNotEmpty, + Max, } from 'class-validator'; export class UpdateEventDto { @@ -18,6 +19,7 @@ export class UpdateEventDto { @IsNotEmpty() @ApiProperty() @Min(1) + @Max(50) maxSize: number; @IsNotEmpty() diff --git a/src/events/events.controller.ts b/src/events/events.controller.ts index 2253ab9..b50702b 100644 --- a/src/events/events.controller.ts +++ b/src/events/events.controller.ts @@ -64,7 +64,7 @@ export class EventsController { // 전체 조회 시 이벤트 호스트와 참가자 수 반환 const event = events.map((item) => { const { GuestEvents, HostEvents, ...rest } = item; - const hostUser = HostEvents[0]?.User?.UserDetail || null + const hostUser = HostEvents[0].User.UserDetail; return { event: rest, @@ -95,7 +95,7 @@ export class EventsController { const { GuestEvents, HostEvents, ...rest } = event; // 조회수 로그 생성 - await this.eventsService.createViewLog(eventId); + await this.eventsService.createViewLog(eventId, userId); return { event: rest, @@ -126,18 +126,18 @@ export class EventsController { return { message: `참가인원은 최대${event.maxSize}명 입니다`, }; - } - + } + this.eventsService.join(eventId, userId); this.eventsService.createRsvpLog(eventId, userId, 'applied'); // 참가 신청 로그 생성 return { message: `${eventId}번 모임 참가 신청`, - confirm: true - } + confirm: true, + }; } else { return { - message: '이미 참석한 이벤트입니다' - } + message: '이미 참석한 이벤트입니다', + }; } } // 4-1. 이벤트 참가 취소 @@ -158,13 +158,13 @@ export class EventsController { this.eventsService.createRsvpLog(eventId, userId, 'canceled'); } else { return { - message: '참석한 이벤트만 취소할 수 있습니다' - } + message: '참석한 이벤트만 취소할 수 있습니다', + }; } return { message: `${eventId}번 모임 참가 취소`, - confirm: false - } + confirm: false, + }; } // 5. 이벤트 수정 diff --git a/src/events/events.service.ts b/src/events/events.service.ts index 0c083a7..bf08cc2 100644 --- a/src/events/events.service.ts +++ b/src/events/events.service.ts @@ -104,11 +104,11 @@ export class EventsService { } // 3-1. 이벤트 조회수 로거 - async createViewLog(eventId: number) { + async createViewLog(eventId: number, userId: number) { await this.prisma.viewlog.create({ data: { EventId: eventId, - UserId: 1, + UserId: userId, }, }); } diff --git a/src/searches/searches.controller.ts b/src/searches/searches.controller.ts index daf313b..94ca6c5 100644 --- a/src/searches/searches.controller.ts +++ b/src/searches/searches.controller.ts @@ -11,13 +11,13 @@ export class SearchesController { @Get() @ApiOperation({ summary: '키워드 검색, 카테고리, 지역, 위치인증 필터링' }) - async searchByLocation(@Query() searchesDto: SearchesDto) { + async searchBy(@Query() searchesDto: SearchesDto) { const events = await this.searchesService.search(searchesDto); const event = events.map((item) => { const { GuestEvents, HostEvents, ...rest } = item; - const hostUser = HostEvents[0].User.UserDetail; + const hostUser = HostEvents[0]?.User?.UserDetail || null return { event: rest, @@ -26,7 +26,5 @@ export class SearchesController { }; }); return event; - } - }