import { Router } from 'express';
import multer from 'multer';
import { requireAuth } from '../middleware/auth';
import { connect, oauthCallback, getStatus, disconnect, refresh, uploadFile, getBackupStatus, listBackupFiles, downloadFile } from '../controllers/googleDrive.controller';

const router = Router();
const upload = multer({ storage: multer.memoryStorage() });

// Google'ın doğrudan (Bearer token olmadan) yönlendirdiği tek public uç nokta.
router.get('/oauth/callback', oauthCallback);

router.get('/connect', requireAuth, connect);
router.get('/status', requireAuth, getStatus);
router.post('/disconnect', requireAuth, disconnect);
router.post('/refresh', requireAuth, refresh);
router.post('/upload', upload.single('file'), requireAuth, uploadFile);
router.get('/backup-status', requireAuth, getBackupStatus);
router.get('/backup-files', requireAuth, listBackupFiles);
router.get('/download', requireAuth, downloadFile);

export default router;
