summaryrefslogtreecommitdiff
path: root/app/api/nonsap-sync/health/route.ts
diff options
context:
space:
mode:
Diffstat (limited to 'app/api/nonsap-sync/health/route.ts')
-rw-r--r--app/api/nonsap-sync/health/route.ts63
1 files changed, 63 insertions, 0 deletions
diff --git a/app/api/nonsap-sync/health/route.ts b/app/api/nonsap-sync/health/route.ts
new file mode 100644
index 00000000..6bfa4ffb
--- /dev/null
+++ b/app/api/nonsap-sync/health/route.ts
@@ -0,0 +1,63 @@
+import { NextResponse } from 'next/server';
+
+export async function GET() {
+ try {
+ // Oracle DB 연결 테스트
+ let oracleStatus = 'unknown';
+ let oracleError = null;
+
+ try {
+ const { oracleKnex } = await import('@/lib/oracle-db/db');
+ const result = await oracleKnex.raw('SELECT 1 FROM DUAL');
+ oracleStatus = result ? 'connected' : 'disconnected';
+ } catch (error) {
+ oracleStatus = 'disconnected';
+ oracleError = error instanceof Error ? error.message : String(error);
+ }
+
+ // PostgreSQL 연결 테스트
+ let postgresStatus = 'unknown';
+ let postgresError = null;
+
+ try {
+ const db = await import('@/db/db');
+ await db.default.execute('SELECT 1');
+ postgresStatus = 'connected';
+ } catch (error) {
+ postgresStatus = 'disconnected';
+ postgresError = error instanceof Error ? error.message : String(error);
+ }
+
+ // 전체 상태 판단
+ const overallStatus = oracleStatus === 'connected' && postgresStatus === 'connected'
+ ? 'healthy'
+ : 'unhealthy';
+
+ return NextResponse.json({
+ status: overallStatus,
+ timestamp: new Date().toISOString(),
+ databases: {
+ oracle: {
+ status: oracleStatus,
+ error: oracleError
+ },
+ postgres: {
+ status: postgresStatus,
+ error: postgresError
+ }
+ },
+ environment: {
+ nodeEnv: process.env.NODE_ENV,
+ runtime: process.env.NEXT_RUNTIME || 'nodejs'
+ }
+ });
+ } catch (error) {
+ console.error('Health check error:', error);
+
+ return NextResponse.json({
+ status: 'error',
+ timestamp: new Date().toISOString(),
+ error: error instanceof Error ? error.message : String(error)
+ }, { status: 500 });
+ }
+} \ No newline at end of file