"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = notificationRoutes;
async function notificationRoutes(app, opts) {
    const { notificationService } = opts;
    app.get('/notifications', async (request, reply) => {
        const { limit, unreadOnly } = request.query;
        try {
            const notifications = await notificationService.list({
                limit: limit ? parseInt(limit, 10) : undefined,
                unreadOnly: unreadOnly === 'true',
            });
            const unreadCount = await notificationService.getUnreadCount();
            return reply.send({ success: true, data: { notifications, unreadCount } });
        }
        catch (err) {
            return reply.status(500).send({ success: false, error: err.message });
        }
    });
    app.get('/notifications/unread-count', async (_request, reply) => {
        try {
            const count = await notificationService.getUnreadCount();
            return reply.send({ success: true, data: { unreadCount: count } });
        }
        catch (err) {
            return reply.status(500).send({ success: false, error: err.message });
        }
    });
    app.put('/notifications/:id/read', async (request, reply) => {
        const { id } = request.params;
        try {
            await notificationService.markAsRead(id);
            return reply.send({ success: true });
        }
        catch (err) {
            return reply.status(500).send({ success: false, error: err.message });
        }
    });
    app.put('/notifications/read-all', async (_request, reply) => {
        try {
            await notificationService.markAllAsRead();
            return reply.send({ success: true });
        }
        catch (err) {
            return reply.status(500).send({ success: false, error: err.message });
        }
    });
}
//# sourceMappingURL=notifications.js.map