summaryrefslogtreecommitdiff
path: root/app/api/cron/projects/route.ts
blob: 12c89bdb130e865ac97b1d5614306056e32245a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// src/app/api/cron/projects/route.ts
import { syncProjects } from '@/lib/sedp/sync-projects';
import { NextRequest } from 'next/server';
import { revalidateTag } from 'next/cache';

export async function GET(request: NextRequest) {
  try {
    console.log('프로젝트 동기화 API 호출됨:', new Date().toISOString());
    
    // syncProjects 함수 호출
    const result = await syncProjects();

    revalidateTag('project-lists')

    // 성공 시 결과와 함께 200 OK 반환
    return Response.json({ success: true, result }, { status: 200 });
  } catch (error: any) {
    console.error('프로젝트 동기화 API 에러:', error);
    
    // 에러 시에는 message를 담아 500 반환
    const message = error.message || 'Something went wrong';
    return Response.json({ success: false, error: message }, { status: 500 });
  }
}