import { Router } from "express";
import { ApiResponse } from '../utils/rest-api-answer';
import { NewsItem, getTestNews } from "../utils/news";
import authRequired from "../utils/auth-required";

const router = Router();

router.get('/isAuthenticated', (req, res) => {
    const response = new ApiResponse(req.isAuthenticated);
    return res.json(response.getAnswer());
});

router.get('/news', authRequired, (req, res) => {
    const newsList : NewsItem[] = getTestNews();
    const response = new ApiResponse(newsList);
    return res.json(response.getAnswer());
});

export default router;