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>
This commit is contained in:
16
src/app/api/v1/notifications/[notificationId]/route.ts
Normal file
16
src/app/api/v1/notifications/[notificationId]/route.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
|
||||
import { withAuth } from '@/lib/api/helpers';
|
||||
import { errorResponse, NotFoundError } from '@/lib/errors';
|
||||
import * as notificationsService from '@/lib/services/notifications.service';
|
||||
|
||||
export const PATCH = withAuth(async (_req, ctx, params) => {
|
||||
try {
|
||||
const { notificationId } = params;
|
||||
if (!notificationId) throw new NotFoundError('Notification');
|
||||
await notificationsService.markRead(notificationId, ctx.userId);
|
||||
return NextResponse.json({ success: true });
|
||||
} catch (error) {
|
||||
return errorResponse(error);
|
||||
}
|
||||
});
|
||||
26
src/app/api/v1/notifications/preferences/route.ts
Normal file
26
src/app/api/v1/notifications/preferences/route.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
|
||||
import { withAuth } from '@/lib/api/helpers';
|
||||
import { parseBody } from '@/lib/api/route-helpers';
|
||||
import { errorResponse } from '@/lib/errors';
|
||||
import { updatePreferencesSchema } from '@/lib/validators/notifications';
|
||||
import * as notificationsService from '@/lib/services/notifications.service';
|
||||
|
||||
export const GET = withAuth(async (_req, ctx) => {
|
||||
try {
|
||||
const prefs = await notificationsService.getPreferences(ctx.userId, ctx.portId);
|
||||
return NextResponse.json({ data: prefs });
|
||||
} catch (error) {
|
||||
return errorResponse(error);
|
||||
}
|
||||
});
|
||||
|
||||
export const PUT = withAuth(async (req, ctx) => {
|
||||
try {
|
||||
const body = await parseBody(req, updatePreferencesSchema);
|
||||
const prefs = await notificationsService.updatePreferences(ctx.userId, ctx.portId, body);
|
||||
return NextResponse.json({ data: prefs });
|
||||
} catch (error) {
|
||||
return errorResponse(error);
|
||||
}
|
||||
});
|
||||
14
src/app/api/v1/notifications/read-all/route.ts
Normal file
14
src/app/api/v1/notifications/read-all/route.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
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 POST = withAuth(async (_req, ctx) => {
|
||||
try {
|
||||
await notificationsService.markAllRead(ctx.userId, ctx.portId);
|
||||
return NextResponse.json({ success: true });
|
||||
} catch (error) {
|
||||
return errorResponse(error);
|
||||
}
|
||||
});
|
||||
17
src/app/api/v1/notifications/route.ts
Normal file
17
src/app/api/v1/notifications/route.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
|
||||
import { withAuth } from '@/lib/api/helpers';
|
||||
import { parseQuery } from '@/lib/api/route-helpers';
|
||||
import { errorResponse } from '@/lib/errors';
|
||||
import { listNotificationsSchema } from '@/lib/validators/notifications';
|
||||
import * as notificationsService from '@/lib/services/notifications.service';
|
||||
|
||||
export const GET = withAuth(async (req, ctx) => {
|
||||
try {
|
||||
const query = parseQuery(req, listNotificationsSchema);
|
||||
const result = await notificationsService.listNotifications(ctx.userId, ctx.portId, query);
|
||||
return NextResponse.json(result);
|
||||
} catch (error) {
|
||||
return errorResponse(error);
|
||||
}
|
||||
});
|
||||
14
src/app/api/v1/notifications/unread-count/route.ts
Normal file
14
src/app/api/v1/notifications/unread-count/route.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
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);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user