Skip to content
Merged
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
20 changes: 0 additions & 20 deletions Dockerfile.dev

This file was deleted.

49 changes: 37 additions & 12 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,39 @@
x-defaults: &common-settings
image: dongho18/connect-gnu-node:latest
pull_policy: always
restart: always
networks:
- connect-gnu-network
environment:
TZ: 'Asia/Seoul'
SLACK_WEBHOOK: ${SLACK_WEBHOOK}
SENTRY_NODE_DSN: ${SENTRY_NODE_DSN}
DB_HOST: ${DB_HOST}
DB_PORT: ${DB_PORT}
DB_USERNAME: ${DB_USERNAME}
DB_PASSWORD: ${DB_PASSWORD}
DB_DATABASE: ${DB_DATABASE}
deploy:
resources:
limits:
memory: 256m
cpus: '0.25'
reservations:
memory: 128m
cpus: '0.1'
services:
backend_node_server:
build:
context: .
dockerfile: Dockerfile.dev
container_name: backend_node_server
restart: always
connect-gnu-node-blue:
<<: *common-settings
container_name: connect-gnu-node-blue
ports:
- '5000:5000'
volumes:
- .:/app
- /app/node_modules
environment:
TZ: 'Asia/Seoul'
- '5200:5200'

connect-gnu-node-green:
<<: *common-settings
container_name: connect-gnu-node-green
ports:
- '5201:5200'

networks:
connect-gnu-network:
external: true
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"@nestjs/platform-express": "^9.0.0",
"@nestjs/schedule": "^5.0.1",
"@nestjs/swagger": "^7.4.0",
"@nestjs/terminus": "^11.0.0",
"@nestjs/typeorm": "^10.0.2",
"@sentry/browser": "^8.54.0",
"@sentry/minimal": "^6.19.7",
Expand Down
106 changes: 106 additions & 0 deletions pnpm-lock.yaml

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

37 changes: 19 additions & 18 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import * as process from 'process';
import { NestFactory, HttpAdapterHost } from '@nestjs/core';
import { AppModule } from './modules/app/app.module';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import { KakaoInterceptor } from './modules/interceptors/kakao.interceptor';
import { KakaoInterceptor } from './modules/common/interceptors/kakao.interceptor';
import { ResponseDTO } from './modules/common/dtos/response.dto';
import { SentryInterceptor } from './modules/interceptors/sentry.interceptor.js';
import { SentryInterceptor } from './modules/common/interceptors/sentry.interceptor.js';
import { SentryFilter } from './modules/common/filters/sentry.filter';
import { initializeTransactionalContext } from 'typeorm-transactional';
import { ValidationPipe } from '@nestjs/common';
Expand All @@ -26,15 +26,18 @@ async function bootstrap() {
} else {
app.useGlobalFilters(new HttpExceptionFilter());
}
app.useGlobalInterceptors(new KakaoInterceptor(ResponseDTO));

app.useGlobalPipes(new ValidationPipe({
whitelist: false,
forbidNonWhitelisted: false,
transform: true,
//transformOptions: { enableImplicitConversion: true }
}))
app.useGlobalInterceptors(
new KakaoInterceptor(ResponseDTO, ['/api/node/health']),
);

app.useGlobalPipes(
new ValidationPipe({
whitelist: false,
forbidNonWhitelisted: false,
transform: true,
//transformOptions: { enableImplicitConversion: true }
}),
);

app.setGlobalPrefix('api/node');
const config = new DocumentBuilder()
Expand All @@ -54,14 +57,12 @@ async function bootstrap() {
.build();

const document = SwaggerModule.createDocument(app, config);
SwaggerModule.setup('api/node/docs', app, document,
{
swaggerOptions: {
persistAuthorization: true, // 새로고침해도 인증 정보 유지
defaultModelsExpandDepth: -1
}
}
);
SwaggerModule.setup('api/node/docs', app, document, {
swaggerOptions: {
persistAuthorization: true, // 새로고침해도 인증 정보 유지
defaultModelsExpandDepth: -1,
},
});
await app.listen(nodeEnv == 'production' ? 5200 : 5001);
}

Expand Down
9 changes: 4 additions & 5 deletions src/modules/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,24 @@ import { validationSchema } from 'src/modules/common/utils/enviornment';
import { APP_FILTER } from '@nestjs/core';
import { CommonModule } from '../common/common.module';
import { ReadingRoomsModule } from '../reading-rooms/reading-rooms.module';
import { ScheduleModule } from '@nestjs/schedule';
import { HttpModule } from '@nestjs/axios';
import { AuthModule } from 'src/modules/auth/auth.module';
import { DiscoveryModule } from '@nestjs/core';
import { HealthModule } from '../health/health.module';
@Module({
imports: [
SentryModule.forRoot(),
ScheduleModule.forRoot(),
HealthModule,
HttpModule,
SupabaseModule,
UtilsModule,
DiscoveryModule,
CommonModule,
UsersModule,
ReadingRoomsModule,
AuthModule,
ConfigModule.forRoot({
isGlobal: true,
envFilePath: process.env.NODE_ENV === 'production' ? '.env.prod' : '.env.dev',
envFilePath:
process.env.NODE_ENV === 'production' ? '.env.prod' : '.env.dev',
validationSchema,
}),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,17 @@ import { plainToInstance } from 'class-transformer';
import { Observable, map } from 'rxjs';

export class KakaoInterceptor implements NestInterceptor {
constructor(private dto: any) {}
constructor(private dto: any, private excludePaths: string[] = []) {}

intercept(context: ExecutionContext, next: CallHandler): Observable<any> {
const request = context.switchToHttp().getRequest();
const path = request.url;

// 제외 경로에 해당하는 경우 인터셉터를 건너뜁니다
if (this.excludePaths.some((excludePath) => path.includes(excludePath))) {
return next.handle();
}

return next.handle().pipe(
map((data: any) => {
return plainToInstance(this.dto, data, {
Expand Down
Loading