import { Router } from "express";
import { authenticateToken } from "../middleware/authMiddleware";
import {
  getCrawlConfigs,
  getCrawlConfig,
  createCrawlConfig,
  updateCrawlConfig,
  deleteCrawlConfig,
  previewCrawl,
  analyzeUrl,
  executeCrawl,
  getCrawlLogs,
} from "../controllers/crawlController";

const router = Router();

// 설정 CRUD
router.get("/configs", authenticateToken, getCrawlConfigs);
router.get("/configs/:id", authenticateToken, getCrawlConfig);
router.post("/configs", authenticateToken, createCrawlConfig);
router.put("/configs/:id", authenticateToken, updateCrawlConfig);
router.delete("/configs/:id", authenticateToken, deleteCrawlConfig);

// 분석 & 미리보기 & 실행
router.post("/analyze", authenticateToken, analyzeUrl);
router.post("/preview", authenticateToken, previewCrawl);
router.post("/execute/:id", authenticateToken, executeCrawl);

// 실행 로그
router.get("/configs/:id/logs", authenticateToken, getCrawlLogs);

export default router;
