Skip to content

Commit

Permalink
refactor(#317) 경로수정
Browse files Browse the repository at this point in the history
  • Loading branch information
2swo committed Mar 13, 2024
2 parents 787a8ac + 7e1a366 commit e69697a
Show file tree
Hide file tree
Showing 221 changed files with 4,042 additions and 3,062 deletions.
139 changes: 138 additions & 1 deletion .github/workflows/ma6-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- develop
- main
paths-ignore:
- 'README.md'
- 'LICENSE'
Expand Down Expand Up @@ -34,7 +35,105 @@ jobs:
- name: Push Docker image
run: docker push ${{ secrets.DOCKER_IMAGE_NAME }}:latest

deploy:
build-notify-slack:
needs: build
runs-on: ubuntu-latest

steps:
- name: Slack Notification
id: slack-notification
uses: slackapi/[email protected]
with:
payload: |
{
"channel": "${{ secrets.SLACK_BACKEND_CHANNEL_ID }}",
"attachments": [
{
"color": "${{ job.status == 'success' && '#36a64f' || job.status == 'failure' && '#ff0000' || '#fffff' }}",
"title": "${{ github.repository }}",
"title_link": "https://github.com/${{ github.repository }}",
"text": "${{ job.status == 'success' && 'GitHub Action Build 성공' || job.status == 'failure' && 'GitHub Action Build 실패 :x:' || '' }}",
"fields": [
{
"title": "Repository",
"value": "${{ github.repository }}",
"short": true
},
{
"title": "Tag",
"value": "${{ github.ref_name }}",
"short": true
}
]
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.DEV_DEPLOY_SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK

deploy-develop:
if: github.ref == 'refs/heads/develop'
needs: build
runs-on: [self-hosted, development] # runner로 ec2 연결

steps:
- name: Login to Docker Hub #docker hub 로그인
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Docker run
run: |
docker stop ${{ secrets.DOCKER_CONTAINER_NAME }}
docker rm ${{ secrets.DOCKER_CONTAINER_NAME }}
docker rmi ${{ secrets.DOCKER_IMAGE_NAME }}:latest
docker pull ${{ secrets.DOCKER_IMAGE_NAME }}:latest
- name: Restart the specific service in Docker Compose
run: |
docker-compose up -d ${{ secrets.DOCKER_SERVICES_NAME }}
deploy-notify-slack-develop:
needs: deploy-develop
runs-on: ubuntu-latest

steps:
- name: Slack Notification
id: slack-notification
uses: slackapi/[email protected]
with:
payload: |
{
"channel": "${{ secrets.SLACK_BACKEND_CHANNEL_ID }}",
"attachments": [
{
"color": "${{ job.status == 'success' && '#36a64f' || job.status == 'failure' && '#ff0000' || '#fffff' }}",
"title": "${{ github.repository }}",
"title_link": "https://github.com/${{ github.repository }}",
"text": "${{ job.status == 'success' && 'GitHub Action Develop Deploy 성공' || job.status == 'failure' && 'GitHub Action Develop Deploy 실패 :x:' || '' }}",
"fields": [
{
"title": "Repository",
"value": "${{ github.repository }}",
"short": true
},
{
"title": "Tag",
"value": "${{ github.ref_name }}",
"short": true
}
]
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.DEV_DEPLOY_SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK

deploy-main:
if: github.ref == 'refs/heads/main'
needs: build
runs-on: self-hosted # runner로 ec2 연결

Expand All @@ -55,3 +154,41 @@ jobs:
- name: Restart the specific service in Docker Compose
run: |
docker-compose up -d ${{ secrets.DOCKER_SERVICES_NAME }}
deploy-notify-slack-main:
needs: deploy-main
runs-on: ubuntu-latest

steps:
- name: Slack Notification
id: slack-notification
uses: slackapi/[email protected]
with:
payload: |
{
"channel": "${{ secrets.SLACK_BACKEND_CHANNEL_ID }}",
"attachments": [
{
"color": "${{ job.status == 'success' && '#36a64f' || job.status == 'failure' && '#ff0000' || '#fffff' }}",
"title": "${{ github.repository }}",
"title_link": "https://github.com/${{ github.repository }}",
"text": "${{ job.status == 'success' && 'GitHub Action Main Deploy 성공' || job.status == 'failure' && 'GitHub Action Main Deploy 실패 :x:' || '' }}",
"fields": [
{
"title": "Repository",
"value": "${{ github.repository }}",
"short": true
},
{
"title": "Tag",
"value": "${{ github.ref_name }}",
"short": true
}
]
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.DEV_DEPLOY_SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK

44 changes: 44 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "NODE_ENV=production node dist/main.js",
"start:prod": "node dist/main.js",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest",
"test:watch": "jest --watch",
Expand Down Expand Up @@ -52,6 +52,7 @@
"config": "^3.3.9",
"cookie-parser": "^1.4.6",
"dotenv": "^16.3.1",
"joi": "^17.12.2",
"mongoose": "^7.5.0",
"mongoose-aggregate-paginate-v2": "^1.0.6",
"mongoose-paginate-v2": "^1.7.4",
Expand Down
2 changes: 1 addition & 1 deletion src/admins/banned-user/constants/banned-user.constant.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const BANNED_USER_REASON_LENGTH = {
MIN: 1,
MAX: 255,
MAX: 200,
} as const;
2 changes: 1 addition & 1 deletion src/admins/banned-user/dtos/banned-user.dto.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ApiProperty } from '@nestjs/swagger';
import { BANNED_USER_REASON_LENGTH } from '@src/admins/banned-user/constants/banned-user.constant';
import { BannedUser } from '@src/admins/banned-user/entities/banned-user.entity';
import { BannedUser } from '@src/entities/BannedUser';

export class BannedUserDto
implements Omit<BannedUser, 'banUser' | 'bannedUser'>
Expand Down
4 changes: 2 additions & 2 deletions src/admins/banned-user/dtos/create-banned-user-body.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export class CreateBannedUserBodyDto
{
@ApiProperty({
description: '정지 사유',
minLength: 1,
maxLength: 255,
minLength: BANNED_USER_REASON_LENGTH.MIN,
maxLength: BANNED_USER_REASON_LENGTH.MAX,
})
@Length(BANNED_USER_REASON_LENGTH.MIN, BANNED_USER_REASON_LENGTH.MAX)
reason: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@nestjs/common';
import { CreateBannedUserBodyDto } from '@src/admins/banned-user/dtos/create-banned-user-body.dto';
import { BannedUser } from '@src/admins/banned-user/entities/banned-user.entity';
import { BannedUser } from '@src/entities/BannedUser';
import { EntityManager, FindOneOptions } from 'typeorm';

@Injectable()
Expand Down
2 changes: 1 addition & 1 deletion src/admins/banned-user/services/banned-users.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ import { ADMIN_ERROR_CODE } from '@src/constants/error/admin/admin-error-code.co
import { HttpForbiddenException } from '@src/http-exceptions/exceptions/http-forbidden.exception';
import { UserRole } from '@src/users/constants/user-role.enum';
import { BannedUserPageQueryDto } from '@src/admins/banned-user/dtos/banned-user-page-query.dto';
import { BannedUser } from '@src/admins/banned-user/entities/banned-user.entity';
import { QueryHelper } from '@src/helpers/query.helper';
import { plainToInstance } from 'class-transformer';
import { BannedUsersItemDto } from '@src/admins/banned-user/dtos/banned-users-item.dto';
import { BannedUsersPaginationResponseDto } from '@src/admins/banned-user/dtos/banned-users-pagination-response.dto';
import { SortOrder } from '@src/common/constants/sort-order.enum';
import { BannedUser } from '@src/entities/BannedUser';

@Injectable()
export class BannedUsersService {
Expand Down
2 changes: 1 addition & 1 deletion src/admins/dtos/put-update-user-for-admin.dto.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsEnum } from 'class-validator';
import { UserStatus } from '@src/users/constants/user-status.enum';
import { User } from '@src/users/entities/user.entity';
import { User } from '@src/entities/User';

export class PutUpdateUserForAdminDto implements Pick<User, 'status'> {
@ApiProperty({
Expand Down
6 changes: 3 additions & 3 deletions src/admins/dtos/user-response-for-admin.dto.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ApiProperty, OmitType } from '@nestjs/swagger';
import { Provider } from '@src/auth/enums/provider.enum';
import { UserProvider } from '@src/auth/enums/user-provider.enum';
import { UserStatus } from '@src/users/constants/user-status.enum';
import { UserInfoDto } from '@src/users/dtos/user-info.dto';

Expand All @@ -17,9 +17,9 @@ export class UserResponseForAdminDto extends OmitType(UserInfoDto, [

@ApiProperty({
description: '유저 정보 제공자',
enum: Provider,
enum: UserProvider,
})
provider: Provider;
provider: UserProvider;

@ApiProperty({
description: '유저 상태',
Expand Down
31 changes: 9 additions & 22 deletions src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { MiddlewareConsumer, Module, NestModule } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { ConfigModule } from '@nestjs/config';
import { MongooseModule } from '@nestjs/mongoose';
import * as mongoose from 'mongoose';
import { ScheduleModule } from '@nestjs/schedule';
import { AdminsModule } from '@src/admins/admins.module';
import { ReportsModule } from '@src/reports/reports.module';
import { AuthModule } from '@src/auth/auth.module';
Expand All @@ -13,31 +9,22 @@ import { ChatModule } from '@src/chat/chat.module';
import { CommentModule } from '@src/comments/comment.module';
import { RedisModule } from '@src/common/redis/redis.module';
import { S3Module } from '@src/common/s3/s3.module';
import { S3Service } from '@src/common/s3/s3.service';
import { TypeORMconfig } from '@src/config/typeorm.config';
import { ExceptionsModule } from '@src/http-exceptions/exceptions.module';
import { MentorsModule } from '@src/mentors/mentors.module';
import { LoggerMiddleware } from '@src/middlewares/logger.middleware';
import { SearchModule } from '@src/search/search.module';
import { UserImageRepository } from '@src/users/repositories/user-image.repository';
import { UserImageService } from '@src/users/services/user-image.service';
import { UserModule } from '@src/users/user.module';
import { CoreModule } from '@src/core/core.module';
import { AppConfigService } from '@src/core/app-config/services/app-config.service';
import { BootstrapService } from '@src/bootstrap.service';

@Module({
imports: [
RedisModule,
AuthModule,
CommentModule,
UserModule,
TypeOrmModule.forRoot({
...TypeORMconfig, // TypeORM 설정 객체 확장
}),
ConfigModule.forRoot({
isGlobal: true,
envFilePath: '.env', // .env 파일 경로 설정
}),
MongooseModule.forRoot(process.env.MONGO_URI),
ScheduleModule.forRoot(),
CoreModule,
ChatModule,
S3Module,
BoardsModule,
Expand All @@ -47,14 +34,14 @@ import { UserModule } from '@src/users/user.module';
AdminsModule,
ReportsModule,
ExceptionsModule,
], //
providers: [UserImageService, UserImageRepository, S3Service],
],
providers: [BootstrapService],
})
export class AppModule implements NestModule {
private readonly isDev: boolean =
process.env.NODE_ENV === 'dev' ? true : false;
constructor(private readonly appConfigService: AppConfigService) {}

configure(consumer: MiddlewareConsumer) {
consumer.apply(LoggerMiddleware).forRoutes('*');
mongoose.set('debug', this.isDev);
mongoose.set('debug', !this.appConfigService.isProduction());
}
}
Loading

0 comments on commit e69697a

Please sign in to comment.