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

22 lines
677 B
TypeScript
Raw Normal View History

import { NextResponse } from 'next/server';
import { withAuth, withPermission } from '@/lib/api/helpers';
import { errorResponse } from '@/lib/errors';
import { removeDocumentWatcher } from '@/lib/services/documents.service';
export const DELETE = withAuth(
withPermission('documents', 'edit', async (_req, ctx, params) => {
try {
await removeDocumentWatcher(params.id!, ctx.portId, params.userId!, {
userId: ctx.userId,
portId: ctx.portId,
ipAddress: ctx.ipAddress,
userAgent: ctx.userAgent,
});
return NextResponse.json({ data: { ok: true } });
} catch (error) {
return errorResponse(error);
}
}),
);