Initial commit: Port Nimara CRM (Layers 0-4)
Full CRM rebuild with Next.js 15, TypeScript, Tailwind, Drizzle ORM,
PostgreSQL, Redis, BullMQ, MinIO, and Socket.io. Includes 461 source
files covering clients, berths, interests/pipeline, documents/EOI,
expenses/invoices, email, notifications, dashboard, admin, and
client portal. CI/CD via Gitea Actions with Docker builds.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 11:52:51 +01:00
|
|
|
import { NextResponse } from 'next/server';
|
|
|
|
|
|
|
|
|
|
import { withAuth, withPermission } from '@/lib/api/helpers';
|
2026-04-08 15:47:11 -04:00
|
|
|
import { parseBody } from '@/lib/api/route-helpers';
|
|
|
|
|
import { listRoles, createRole } from '@/lib/services/roles.service';
|
|
|
|
|
import { createRoleSchema } from '@/lib/validators/roles';
|
Initial commit: Port Nimara CRM (Layers 0-4)
Full CRM rebuild with Next.js 15, TypeScript, Tailwind, Drizzle ORM,
PostgreSQL, Redis, BullMQ, MinIO, and Socket.io. Includes 461 source
files covering clients, berths, interests/pipeline, documents/EOI,
expenses/invoices, email, notifications, dashboard, admin, and
client portal. CI/CD via Gitea Actions with Docker builds.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 11:52:51 +01:00
|
|
|
import { errorResponse } from '@/lib/errors';
|
|
|
|
|
|
|
|
|
|
export const GET = withAuth(
|
2026-04-08 15:47:11 -04:00
|
|
|
withPermission('admin', 'manage_users', async () => {
|
Initial commit: Port Nimara CRM (Layers 0-4)
Full CRM rebuild with Next.js 15, TypeScript, Tailwind, Drizzle ORM,
PostgreSQL, Redis, BullMQ, MinIO, and Socket.io. Includes 461 source
files covering clients, berths, interests/pipeline, documents/EOI,
expenses/invoices, email, notifications, dashboard, admin, and
client portal. CI/CD via Gitea Actions with Docker builds.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 11:52:51 +01:00
|
|
|
try {
|
2026-04-08 15:47:11 -04:00
|
|
|
const data = await listRoles();
|
Initial commit: Port Nimara CRM (Layers 0-4)
Full CRM rebuild with Next.js 15, TypeScript, Tailwind, Drizzle ORM,
PostgreSQL, Redis, BullMQ, MinIO, and Socket.io. Includes 461 source
files covering clients, berths, interests/pipeline, documents/EOI,
expenses/invoices, email, notifications, dashboard, admin, and
client portal. CI/CD via Gitea Actions with Docker builds.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 11:52:51 +01:00
|
|
|
return NextResponse.json({ data });
|
|
|
|
|
} catch (error) {
|
|
|
|
|
return errorResponse(error);
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
);
|
2026-04-08 15:47:11 -04:00
|
|
|
|
|
|
|
|
export const POST = withAuth(
|
|
|
|
|
withPermission('admin', 'manage_users', async (req, ctx) => {
|
|
|
|
|
try {
|
|
|
|
|
const body = await parseBody(req, createRoleSchema);
|
|
|
|
|
const data = await createRole(body, {
|
|
|
|
|
userId: ctx.userId,
|
|
|
|
|
portId: ctx.portId,
|
|
|
|
|
ipAddress: ctx.ipAddress,
|
|
|
|
|
userAgent: ctx.userAgent,
|
|
|
|
|
});
|
|
|
|
|
return NextResponse.json({ data }, { status: 201 });
|
|
|
|
|
} catch (error) {
|
|
|
|
|
return errorResponse(error);
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
);
|