<?php
declare(strict_types=1);

require_once __DIR__ . '/../system/bootstrap.php';
require_once __DIR__ . '/../system/auth.php';

header('Content-Type: application/json');

$user = require_auth($pdo);

$stmt = $pdo->prepare("
    SELECT *
    FROM notifications
    WHERE user_id = :user
    ORDER BY created_at DESC
    LIMIT 50
");

$stmt->execute(['user' => $user['id']]);

echo json_encode($stmt->fetchAll(PDO::FETCH_ASSOC));
