<?php
include_once '../controllers/BlogController.php';

$blog = new BlogsController();

if (isset($_POST['action'])) {
    $action = $_POST['action'];
} else {
    throw new Exception('No se especificó ninguna acción');
}

switch ($action) {
    case 'getBlogs':
        $blog->getBlogs();
        break;
    case 'getBlog':
        $blog->getBlog();
        break;
    case 'getBlogsPublicos':
        $blog->getBlogsPublicos();
        break;
    case 'createBlog':
        $blog->createBlog();
        break;
    case 'updateBlog':
        $blog->updateBlog();
        break;
    case 'deleteBlog':
        $blog->deleteBlog();
        break;
    case 'activateBlog':
        $blog->activateBlog();
        break;
    default:
        echo json_encode(['status' => 'error', 'message' => 'Acción no válida']);
}
