"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.pagesPublicRouter = void 0;
const express_1 = require("express");
const database_1 = require("../../config/database");
const pages_service_1 = require("./pages.service");
const router = (0, express_1.Router)();
exports.pagesPublicRouter = router;
// GET /api/pages/listed — get published + listed pages for public index (no auth)
router.get('/listed', async (_req, res, next) => {
    try {
        const pages = await database_1.prisma.landingPage.findMany({
            where: { published: true, listed: true },
            select: {
                slug: true,
                title: true,
                description: true,
                seoImage: true,
                updatedAt: true,
            },
            orderBy: { updatedAt: 'desc' },
        });
        res.json(pages);
    }
    catch (err) {
        next(err);
    }
});
// GET /api/pages/:slug/view — get published page by slug (public)
router.get('/:slug/view', async (req, res, next) => {
    try {
        const slug = req.params.slug;
        const page = await pages_service_1.pagesService.findBySlugPublic(slug);
        res.json(page);
    }
    catch (err) {
        next(err);
    }
});
//# sourceMappingURL=pages-public.routes.js.map