"use strict";
// SPDX-License-Identifier: AGPL-3.0-or-later
// Copyright (C) 2024-2026 Gracker (Chris)
// This file is part of SmartPerfetto. See LICENSE for details.
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const express_1 = require("express");
const multer_1 = __importDefault(require("multer"));
const traceController_1 = __importDefault(require("../controllers/traceController"));
const traceUploadLimit_1 = require("../services/traceUploadLimit");
// import { authenticate, checkUsage } from '../middleware/auth';
const router = (0, express_1.Router)();
const traceController = new traceController_1.default();
// Configure multer for file uploads
const storage = multer_1.default.diskStorage({
    destination: (req, file, cb) => {
        cb(null, process.env.UPLOAD_DIR || './uploads');
    },
    filename: (req, file, cb) => {
        // Keep the original filename
        cb(null, file.originalname);
    },
});
const fileFilter = (req, file, cb) => {
    // Accept all files
    cb(null, true);
};
const upload = (0, multer_1.default)({
    storage,
    fileFilter,
    limits: {
        fileSize: (0, traceUploadLimit_1.resolveTraceUploadLimitBytes)(),
    },
});
// POST /api/trace/upload - Upload a trace file (auth disabled for development)
router.post('/upload', upload.single('file'), traceController.uploadTrace);
// POST /api/trace/analyze - Deprecated. Returns migration guidance to /api/agent/v1/analyze.
router.post('/analyze', traceController.analyzeTrace);
// GET /api/trace/:fileId - Get trace file information (auth disabled for development)
router.get('/:fileId', traceController.getTraceInfo);
// DELETE /api/trace/:fileId - Delete a trace file (auth disabled for development)
router.delete('/:fileId', traceController.deleteTrace);
// GET /api/trace/:fileId/download - Download a trace file (auth disabled for development)
router.get('/:fileId/download', traceController.downloadTrace);
exports.default = router;
//# sourceMappingURL=trace.js.map