import { Router, Request, Response } from 'express';
import jwt from 'jsonwebtoken';

const router = Router();

// Development-only: Generate a test token
router.post('/test-token', async (req: Request, res: Response) => {
  const { userId = 'test-user-123', email = 'test@example.com', role = 'admin' } = req.body;

  const token = jwt.sign(
    { id: userId, email, role },
    process.env.JWT_SECRET || 'dev-secret',
    { expiresIn: '24h' }
  );

  res.json({ token, user: { id: userId, email, role } });
});

export default router;
