<?php
require_once __DIR__ . '/../includes/bootstrap.php';
require_once __DIR__ . '/../includes/entity.php';

if ($_SERVER['REQUEST_METHOD'] !== 'DELETE') json_error('Método no permitido.', 405);
require_admin($config);

$body = body_json();
$id = (int) ($body['id'] ?? 0);
if ($id <= 0) json_error('id es requerido.', 422);

entity_delete($pdo, 'posts', $id);

json_ok(['ok' => true]);
