import { NextResponse } from 'next/server';

import { withAuth } from '@/lib/api/helpers';
import { errorResponse } from '@/lib/errors';
import * as notificationsService from '@/lib/services/notifications.service';

export const GET = withAuth(async (_req, ctx) => {
  try {
    const result = await notificationsService.getUnreadCount(ctx.userId, ctx.portId);
    return NextResponse.json(result);
  } catch (error) {
    return errorResponse(error);
  }
});
