Skip to content

Commit

Permalink
Merge pull request #104 from boostcampwm-2024/feat/#78/setting-typeorm
Browse files Browse the repository at this point in the history
[Feat] TypeORM 세팅
  • Loading branch information
begong313 authored Nov 5, 2024
2 parents 4860dd5 + 5969447 commit 732e2cf
Show file tree
Hide file tree
Showing 5 changed files with 279 additions and 17 deletions.
5 changes: 4 additions & 1 deletion apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@
"@nestjs/core": "^10.0.0",
"@nestjs/platform-express": "^10.0.0",
"@nestjs/swagger": "^8.0.1",
"@nestjs/typeorm": "^10.0.2",
"@repo/shards": "workspace:*",
"@repo/types": "workspace:*",
"mysql": "^2.18.1",
"reflect-metadata": "^0.2.0",
"rxjs": "^7.8.1"
"rxjs": "^7.8.1",
"typeorm": "^0.3.20"
},
"devDependencies": {
"@nestjs/cli": "^10.0.0",
Expand Down
4 changes: 3 additions & 1 deletion apps/api/src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';

import { AppController } from '@/app.controller';

import { AppService } from './app.service';
import { AuthModule } from './auth/auth.module';
import { dbConfig } from './config/dbConfig';
import { StreamModule } from './stream/stream.module';
import { TicleModule } from './ticle/ticle.module';
import { UserModule } from './user/user.module';

@Module({
imports: [AuthModule, TicleModule, StreamModule, UserModule],
imports: [AuthModule, TicleModule, StreamModule, UserModule, TypeOrmModule.forRoot(dbConfig)],
controllers: [AppController],
providers: [AppService],
})
Expand Down
12 changes: 12 additions & 0 deletions apps/api/src/config/dbConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { TypeOrmModuleOptions } from '@nestjs/typeorm';

export const dbConfig: TypeOrmModuleOptions = {
type: 'mysql',
host: 'localhost',
port: 3306,
username: 'root',
password: 'root',
database: 'test',
entities: [__dirname + '/../**/*.entity{.ts,.js}'], // 엔티티 경로 설정
synchronize: true, // 개발 중에만 사용
};
2 changes: 1 addition & 1 deletion apps/api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { AppModule } from '@/app.module';

async function bootstrap() {
const app = await NestFactory.create(AppModule);

//swagger setting
const config = new DocumentBuilder()
.setTitle('Ticle API server')
Expand Down
Loading

0 comments on commit 732e2cf

Please sign in to comment.