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';
|
|
|
|
|
import { errorResponse } from '@/lib/errors';
|
|
|
|
|
import { getPreviewUrl } from '@/lib/services/files';
|
|
|
|
|
|
|
|
|
|
export const GET = withAuth(
|
|
|
|
|
withPermission('files', 'view', async (req, ctx, params) => {
|
|
|
|
|
try {
|
|
|
|
|
const result = await getPreviewUrl(params.id!, ctx.portId);
|
2026-06-03 22:34:47 +02:00
|
|
|
// `?redirect=1` → 302 to the presigned (inline) URL so a plain
|
|
|
|
|
// <a href>/<Link> opens the file in the browser. Default returns the
|
|
|
|
|
// JSON envelope for programmatic consumers (e.g. FilePreviewDialog).
|
|
|
|
|
if (new URL(req.url).searchParams.has('redirect')) {
|
|
|
|
|
return NextResponse.redirect(result.url, 302);
|
|
|
|
|
}
|
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: result });
|
|
|
|
|
} catch (error) {
|
|
|
|
|
return errorResponse(error);
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
);
|