Files
pn-new-crm/src/app/api/v1/reports/[id]/route.ts

18 lines
552 B
TypeScript
Raw Normal View History

import { NextResponse } from 'next/server';
import { withAuth, withPermission } from '@/lib/api/helpers';
import { getReport } from '@/lib/services/reports.service';
import { errorResponse } from '@/lib/errors';
export const GET = withAuth(
withPermission('reports', 'view_dashboard', async (_req, ctx, params) => {
try {
const reportId = params.id ?? '';
const report = await getReport(reportId, ctx.portId);
return NextResponse.json({ data: report });
} catch (error) {
return errorResponse(error);
}
}),
);