redis 잔여 설정도 제거
This commit is contained in:
@@ -14,28 +14,23 @@ import { LoggingInterceptor } from './common/interceptors/logging.interceptor';
|
|||||||
import { TransformInterceptor } from './common/interceptors/transform.interceptor';
|
import { TransformInterceptor } from './common/interceptors/transform.interceptor';
|
||||||
import { types } from 'pg';
|
import { types } from 'pg';
|
||||||
|
|
||||||
// ========== 전역 에러 핸들러 (NestJS 도달 전 에러 캐치) ==========
|
// ========== 전역 에러 핸들러 ==========
|
||||||
process.on('uncaughtException', (error) => {
|
process.on('uncaughtException', (error) => {
|
||||||
console.error('╔══════════════════════════════════════════════════════════════╗');
|
console.error('╔═══════════ UNCAUGHT EXCEPTION ═══════════╗');
|
||||||
console.error('║ UNCAUGHT EXCEPTION ║');
|
|
||||||
console.error('╚══════════════════════════════════════════════════════════════╝');
|
|
||||||
console.error(`Timestamp: ${new Date().toISOString()}`);
|
console.error(`Timestamp: ${new Date().toISOString()}`);
|
||||||
console.error(`Error: ${error.message}`);
|
console.error(`Error: ${error.message}`);
|
||||||
console.error(`Stack: ${error.stack}`);
|
console.error(`Stack: ${error.stack}`);
|
||||||
process.stdout.write(`[FATAL] Uncaught Exception: ${error.message}\n`);
|
console.error('╚══════════════════════════════════════════╝');
|
||||||
process.stdout.write(`[FATAL] Stack: ${error.stack}\n`);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
process.on('unhandledRejection', (reason, promise) => {
|
process.on('unhandledRejection', (reason) => {
|
||||||
console.error('╔══════════════════════════════════════════════════════════════╗');
|
console.error('╔═══════════ UNHANDLED REJECTION ═══════════╗');
|
||||||
console.error('║ UNHANDLED REJECTION ║');
|
|
||||||
console.error('╚══════════════════════════════════════════════════════════════╝');
|
|
||||||
console.error(`Timestamp: ${new Date().toISOString()}`);
|
console.error(`Timestamp: ${new Date().toISOString()}`);
|
||||||
console.error(`Reason: ${reason}`);
|
console.error(`Reason: ${reason}`);
|
||||||
process.stdout.write(`[FATAL] Unhandled Rejection: ${reason}\n`);
|
console.error('╚═══════════════════════════════════════════╝');
|
||||||
});
|
});
|
||||||
|
|
||||||
// PostgreSQL numeric/decimal 타입을 JavaScript number로 자동 변환
|
// PostgreSQL numeric 타입 변환
|
||||||
types.setTypeParser(1700, parseFloat);
|
types.setTypeParser(1700, parseFloat);
|
||||||
|
|
||||||
async function bootstrap() {
|
async function bootstrap() {
|
||||||
@@ -44,13 +39,10 @@ async function bootstrap() {
|
|||||||
logger.log('========================================');
|
logger.log('========================================');
|
||||||
logger.log('Application starting...');
|
logger.log('Application starting...');
|
||||||
logger.log(`NODE_ENV: ${process.env.NODE_ENV}`);
|
logger.log(`NODE_ENV: ${process.env.NODE_ENV}`);
|
||||||
logger.log(`REDIS_URL: ${process.env.REDIS_URL}`);
|
|
||||||
logger.log(`POSTGRES_HOST: ${process.env.POSTGRES_HOST}`);
|
logger.log(`POSTGRES_HOST: ${process.env.POSTGRES_HOST}`);
|
||||||
logger.log('========================================');
|
logger.log('========================================');
|
||||||
process.stdout.write(`[BOOTSTRAP] Starting application...\n`);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// 로거 활성화 (Docker에서 모든 로그 출력)
|
|
||||||
const app = await NestFactory.create(AppModule, {
|
const app = await NestFactory.create(AppModule, {
|
||||||
logger: ['error', 'warn', 'log', 'debug', 'verbose'],
|
logger: ['error', 'warn', 'log', 'debug', 'verbose'],
|
||||||
bufferLogs: false,
|
bufferLogs: false,
|
||||||
@@ -58,7 +50,6 @@ async function bootstrap() {
|
|||||||
|
|
||||||
logger.log('NestFactory.create() 완료');
|
logger.log('NestFactory.create() 완료');
|
||||||
|
|
||||||
// CORS 추가
|
|
||||||
app.enableCors({
|
app.enableCors({
|
||||||
origin: (origin, callback) => {
|
origin: (origin, callback) => {
|
||||||
if (!origin) return callback(null, true);
|
if (!origin) return callback(null, true);
|
||||||
@@ -76,47 +67,29 @@ async function bootstrap() {
|
|||||||
credentials: true,
|
credentials: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
// ValidationPipe 추가
|
|
||||||
app.useGlobalPipes(
|
app.useGlobalPipes(
|
||||||
new ValidationPipe({
|
new ValidationPipe({
|
||||||
transform: true,
|
transform: true,
|
||||||
whitelist: false,
|
whitelist: false,
|
||||||
transformOptions: {
|
transformOptions: { enableImplicitConversion: true },
|
||||||
enableImplicitConversion: true,
|
|
||||||
},
|
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
// 전역 필터 적용
|
|
||||||
app.useGlobalFilters(new AllExceptionsFilter());
|
app.useGlobalFilters(new AllExceptionsFilter());
|
||||||
|
app.useGlobalInterceptors(new LoggingInterceptor(), new TransformInterceptor());
|
||||||
|
|
||||||
// 전역 인터셉터 적용
|
|
||||||
app.useGlobalInterceptors(
|
|
||||||
new LoggingInterceptor(),
|
|
||||||
new TransformInterceptor(),
|
|
||||||
);
|
|
||||||
|
|
||||||
// 전역 JWT 인증 가드 적용
|
|
||||||
const reflector = app.get(Reflector);
|
const reflector = app.get(Reflector);
|
||||||
app.useGlobalGuards(new JwtAuthGuard(reflector));
|
app.useGlobalGuards(new JwtAuthGuard(reflector));
|
||||||
|
|
||||||
const port = process.env.PORT ?? 4000;
|
const port = process.env.PORT ?? 4000;
|
||||||
await app.listen(port, '0.0.0.0');
|
await app.listen(port, '0.0.0.0');
|
||||||
|
|
||||||
logger.log('========================================');
|
logger.log(`✅ Server running on port ${port}`);
|
||||||
logger.log(`Application running on port ${port}`);
|
|
||||||
logger.log(`Environment: ${process.env.NODE_ENV || 'development'}`);
|
|
||||||
logger.log('========================================');
|
|
||||||
process.stdout.write(`[BOOTSTRAP] Server listening on port ${port}\n`);
|
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error('========================================');
|
logger.error('❌ Application failed to start!');
|
||||||
logger.error('Application failed to start!');
|
|
||||||
logger.error(`Error: ${error.message}`);
|
logger.error(`Error: ${error.message}`);
|
||||||
logger.error(`Stack: ${error.stack}`);
|
logger.error(`Stack: ${error.stack}`);
|
||||||
logger.error('========================================');
|
|
||||||
process.stdout.write(`[BOOTSTRAP] STARTUP FAILED: ${error.message}\n`);
|
|
||||||
process.stdout.write(`[BOOTSTRAP] STACK: ${error.stack}\n`);
|
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user