Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion nest-cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"compilerOptions": {
"deleteOutDir": true
"deleteOutDir": true,
"assets": [
{
"include": "proto/**/*",
"watchAssets": true
}
]
}
}
196 changes: 196 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: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@
"test:e2e": "jest --passWithNoTests --config ./test/jest-e2e.json"
},
"dependencies": {
"@grpc/grpc-js": "^1.14.3",
"@grpc/proto-loader": "^0.8.0",
"@nestjs/common": "^11.0.1",
"@nestjs/config": "^4.0.2",
"@nestjs/core": "^11.0.1",
"@nestjs/mapped-types": "^2.1.0",
"@nestjs/microservices": "^11.1.16",
"@nestjs/platform-express": "^11.0.1",
"@nestjs/platform-socket.io": "^11.1.6",
"@nestjs/swagger": "^11.2.0",
Expand Down
30 changes: 16 additions & 14 deletions src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import { ConfigModule } from '@nestjs/config';
import { TypeOrmModule } from '@nestjs/typeorm';
import { AuthModule } from './auth/auth.module';
import { CardsetModule } from './cardset/cardset.module';
import { CardsetManagerModule } from './cardset-manager/cardset-manager.module';
import { Cardset as CardSet } from './cardset/entities/cardset.entity';
import { CardsetManager as CardSetManager } from './cardset-manager/entities/cardset-manager.entity';
import { CardModule } from './card/card.module';
import { Card as Card } from './card/entities/card.entity';
import { WebSocketModule } from './websocket/websocket.module';
import { CollaborationModule } from './collaboration/collaboration.module';

import { CardsetOrmEntity } from './cardset/infrastructure/persistence/orm/cardset.orm-entity';
import { CardOrmEntity } from './cardset/infrastructure/persistence/orm/card.orm-entity';
import { CardsetManagerOrmEntity } from './cardset/infrastructure/persistence/orm/cardset-manager.orm-entity';
import { YjsDocumentOrmEntity } from './collaboration/infrastructure/persistence/orm/yjs-document.orm-entity';

@Module({
imports: [
AuthModule,
ConfigModule.forRoot({ isGlobal: true }),
TypeOrmModule.forRoot({
type: 'mysql',
Expand All @@ -20,15 +20,17 @@ import { WebSocketModule } from './websocket/websocket.module';
username: process.env.DB_USERNAME,
password: process.env.DB_PASSWORD,
database: process.env.DB_DATABASE,
entities: [CardSet, CardSetManager, Card],
synchronize: false,
entities: [
CardsetOrmEntity,
CardOrmEntity,
CardsetManagerOrmEntity,
YjsDocumentOrmEntity,
],
synchronize: true,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

synchronize: true는 프로덕션 환경에서 데이터 손실을 유발할 수 있습니다.

synchronize: true는 애플리케이션 시작 시 데이터베이스 스키마를 자동으로 동기화하여 의도치 않은 테이블/컬럼 삭제가 발생할 수 있습니다. 개발 환경에서만 사용하고, 프로덕션에서는 마이그레이션을 사용하세요.

🛡️ 환경별 설정 분리 제안
     TypeOrmModule.forRoot({
       type: 'mysql',
       host: process.env.DB_HOST,
       port: Number(process.env.DB_PORT),
       username: process.env.DB_USERNAME,
       password: process.env.DB_PASSWORD,
       database: process.env.DB_DATABASE,
       entities: [
         CardsetOrmEntity,
         CardOrmEntity,
         CardsetManagerOrmEntity,
         YjsDocumentOrmEntity,
       ],
-      synchronize: true,
+      synchronize: process.env.NODE_ENV !== 'production',
     }),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
synchronize: true,
TypeOrmModule.forRoot({
type: 'mysql',
host: process.env.DB_HOST,
port: Number(process.env.DB_PORT),
username: process.env.DB_USERNAME,
password: process.env.DB_PASSWORD,
database: process.env.DB_DATABASE,
entities: [
CardsetOrmEntity,
CardOrmEntity,
CardsetManagerOrmEntity,
YjsDocumentOrmEntity,
],
synchronize: process.env.NODE_ENV !== 'production',
}),
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/app.module.ts` at line 29, The TypeORM configuration currently sets
synchronize: true which risks data loss in production; update the configuration
used by TypeOrmModule.forRoot (or the function creating the TypeORM options) to
make synchronize false in production and enable it only for development (e.g.,
read NODE_ENV or an env var like TYPEORM_SYNCHRONIZE), and ensure production DB
schema changes are applied via migrations (run migrations with TypeORM CLI or
programmatic migration runner) instead of automatic sync.

}),
AuthModule,
CardsetModule,
CardsetManagerModule,
CardModule,
WebSocketModule,
CollaborationModule,
],
controllers: [],
providers: [],
})
export class AppModule {}
32 changes: 0 additions & 32 deletions src/auth.guard.ts

This file was deleted.

13 changes: 0 additions & 13 deletions src/auth/auth.controller.ts

This file was deleted.

8 changes: 3 additions & 5 deletions src/auth/auth.module.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { Module } from '@nestjs/common';
import { AuthService } from './auth.service';
import { AuthController } from './auth.controller';
import { WsAuthGuard } from './ws-auth.guard';
import authConfig from '../config/authConfig';
import { ConfigModule } from '@nestjs/config';
import { AuthService } from './domain/auth.service';
import { WsAuthGuard } from './infrastructure/guard/ws-auth.guard';
import authConfig from '../shared/config/auth.config';

@Module({
imports: [ConfigModule.forFeature(authConfig)],
controllers: [AuthController],
providers: [AuthService, WsAuthGuard],
exports: [AuthService, WsAuthGuard],
})
Expand Down
Loading