import { Router } from 'express';
import { ApiTokenController } from '../controllers/apiToken.controller';
import { authenticateToken } from '../middlewares/auth.middleware';
import { asyncHandler } from '../middlewares/errorHandler.middleware';

const router = Router();
const apiTokenController = new ApiTokenController();

// All routes require authentication
router.use(authenticateToken);

router.post('/', asyncHandler(apiTokenController.create.bind(apiTokenController)));
router.get('/', asyncHandler(apiTokenController.list.bind(apiTokenController)));
router.delete('/:id', asyncHandler(apiTokenController.revoke.bind(apiTokenController)));

export default router;
