const express = require('express');
const router = express.Router();
const multer = require('multer');
const dataConvertController = require('../controllers/dataConvertController');

// Configure multer for CSV upload
const upload = multer({
    storage: multer.memoryStorage(),
    fileFilter: (req, file, cb) => {
        if (file.mimetype === 'text/csv' || file.originalname.endsWith('.csv')) {
            cb(null, true);
        } else {
            cb(new Error('Only CSV files are allowed'));
        }
    },
    limits: {
        fileSize: 10 * 1024 * 1024 // 10MB limit
    }
});

// Process CSV file
router.post('/process-csv', upload.single('csvFile'), dataConvertController.processCSV);

// Save geocoded data
router.post('/save-geocoded', dataConvertController.saveGeocodedData);

module.exports = router;
