Skip to content

Commit

Permalink
Merge branch 'BE/release' into BE/refactor/modify-journey-schema
Browse files Browse the repository at this point in the history
  • Loading branch information
twoo1999 authored Nov 23, 2023
2 parents 0eca0d1 + 2eb394b commit 89fb4d5
Show file tree
Hide file tree
Showing 7 changed files with 610 additions and 1 deletion.
46 changes: 46 additions & 0 deletions .github/workflows/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# name: musicspot github actions

# on:
# pull_request:
# branches: ["BE/release"]
# types: ["closed"]
# jobs:
# deploy:
# runs-on: ubuntu-latest

# steps:
# - name: Checkout repository
# uses: actions/checkout@v2

# - name: Set up Node.js
# uses: actions/setup-node@v2
# with:
# node-version: "20"

# - name: Install dependencies
# run: |
# cd BE
# cd musicspot
# npm install

# - name: Build Docker image
# run: docker build -t musicspot:latest ./BE/musicspot

# - name: Login to Docker Hub
# run: docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}

# - name: Push Docker image to Docker Hub
# run: docker push musicspot

# - name: SSH into Ubuntu server and pull the latest image
# uses: appleboy/ssh-action@master
# with:
# host: ${{ secrets.SERVER_IP }}
# username: ${{ secrets.SERVER_USERNAME }}
# password: ${{ secrets.PASSWORD }}
# script: |
# docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
# docker pull musicspot
# docker stop musicspot || true
# docker rm musicspot || true
# docker run -e SSH_HOST=${{ secrets.SSH_HOST }} -e SSH_PORT=${{ secrets.SSH_PORT }} -e SSH_USER=${{ secrets.SSH_USER }} -e SSH_PASSWORD=${{ secrets.SSH_PASSWORD }} -e DB_USERNAME=${{ secrets.DB_USERNAME }} -e DB_PASSWORD=${{ secrets.DB_PASSWORD }} -e DB_NAME=${{ secrets.DB_NAME }} -e DB_HOST=${{ secrets.DB_HOST }} -e SECRET_KEY=${{ secrets.SECRET_KEY }} -v /images:/images -v /images/profile:/images/profile -v /images/story:/images/story -d -p 3000:3000 --name heatpick-container geomgichoi/heatpick
1 change: 1 addition & 0 deletions BE/musicspot/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MONGODB_URI=mongodb://localhost:27017/musicspot
15 changes: 15 additions & 0 deletions BE/musicspot/src/journey/dto/journeyEnd.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {
ArrayMaxSize,
ArrayMinSize,
IsArray,
IsNumber,
IsString,
} from 'class-validator';

export class EndJourneyDTO {
@IsString()
readonly _id: string;

// @IsString()
// readonly timestamp: string;
}
15 changes: 14 additions & 1 deletion BE/musicspot/src/journey/journey.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { JourneyService } from './journey.service';
import { StartJourneyDTO } from './dto/journeyStart.dto';
import { ApiCreatedResponse, ApiOperation, ApiTags } from '@nestjs/swagger';
import { Journey } from './journey.schema';
import { EndJourneyDTO } from './dto/journeyEnd.dto';
@Controller('journey')
@ApiTags('journey ๊ด€๋ จ API')
export class JourneyController {
Expand All @@ -17,8 +18,20 @@ export class JourneyController {
description: '์ƒ์„ฑ๋œ ์—ฌ์ • ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐ˜ํ™˜',
type: Journey,
})
@Post()
@Post('start')
async create(@Body() startJourneyDTO: StartJourneyDTO) {
return await this.journeyService.create(startJourneyDTO);
}
@ApiOperation({
summary: '์—ฌ์ • ์ข…๋ฃŒ๋ฅผ ๋ˆŒ๋ €์„ ์‹œ ์‹คํ–‰๋˜๋Š” API',
description: 'request๋กœ id๊ฐ’์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค',
})
@ApiCreatedResponse({
description: 'ํ˜„์žฌ๋Š” ์ขŒํ‘œ ๋ฐ์ดํ„ฐ์˜ ๊ธธ์ด๋ฅผ ๋ฐ˜ํ™˜, ์ถ”ํ›„ ์ฐธ ๊ฑฐ์ง“์œผ๋กœ ๋ณ€๊ฒฝ ์˜ˆ์ •',
type: Journey,
})
@Post('end')
async end(@Body() endJourneyDTO: EndJourneyDTO) {
return await this.journeyService.end(endJourneyDTO);
}
}
9 changes: 9 additions & 0 deletions BE/musicspot/src/journey/journey.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { Injectable } from '@nestjs/common';
import { StartJourneyDTO } from './dto/journeyStart.dto';
import { Journey } from './journey.schema';
import { User } from '../user/user.schema';
import { UserService } from '../user/user.service';
import { EndJourneyDTO } from './dto/journeyEnd.dto';

@Injectable()
export class JourneyService {
Expand Down Expand Up @@ -34,4 +36,11 @@ export class JourneyService {
);
return createdJourneyData;
}

async end(endJourneyDTO: EndJourneyDTO) {
const journeyId = endJourneyDTO._id;
const journey = await this.journeyModel.findById(journeyId).exec();
//check ์ฐธ ์กฐ๊ฑด์ธ์ง€ ํ™•์ธ
return journey.coordinates.length;
}
}
Loading

0 comments on commit 89fb4d5

Please sign in to comment.