import { Request, Response, NextFunction } from 'express';
import axios from 'axios';

const getTodaysPips = async (req: Request, res: Response, next: NextFunction) => {
    try {
        const date = new Date().toISOString().split('T')[0];
        const url = `https://www.nytimes.com/svc/pips/v1/${date}.json`;
        const response = await axios.get(url);
        res.json(response.data);
    } catch (error) {
        console.error("Error fetching Pips data:", error);
        res.status(500).json({ error: 'Failed to fetch Pips data' });
    }
};

export { getTodaysPips };