ddd refactor - projects (#208)

This commit is contained in:
Ramnique Singh 2025-08-18 06:30:26 +05:30 committed by GitHub
parent 4b095d16cc
commit 580ecc7f98
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
72 changed files with 2460 additions and 624 deletions

View file

@ -1,6 +1,6 @@
import { NextRequest } from "next/server";
import { apiV1 } from "rowboat-shared";
import { projectsCollection, chatsCollection, chatMessagesCollection } from "../../../../../../lib/mongodb";
import { chatsCollection, chatMessagesCollection } from "../../../../../../lib/mongodb";
import { z } from "zod";
import { ObjectId, WithId } from "mongodb";
import { authCheck } from "../../../utils";
@ -112,6 +112,8 @@ export async function POST(
req: NextRequest,
{ params }: { params: Promise<{ chatId: string }> }
): Promise<Response> {
return new Response('Not implemented', { status: 501 });
/*
return await authCheck(req, async (session) => {
const { chatId } = await params;
const logger = new PrefixLogger(`widget-chat:${chatId}`);
@ -234,4 +236,5 @@ export async function POST(
_id: undefined,
});
});
*/
}

View file

@ -4,9 +4,10 @@ import { SignJWT, jwtVerify } from "jose";
import { z } from "zod";
import { Session } from "../../utils";
import { apiV1 } from "rowboat-shared";
import { projectsCollection } from "../../../../../lib/mongodb";
export async function POST(req: NextRequest): Promise<Response> {
return new Response('Not implemented', { status: 501 });
/*
return await clientIdCheck(req, async (projectId) => {
// decode and validate JWT
const json = await req.json();
@ -52,4 +53,5 @@ export async function POST(req: NextRequest): Promise<Response> {
return Response.json(response);
});
*/
}

View file

@ -1,7 +1,6 @@
import { NextRequest } from "next/server";
import { z } from "zod";
import { jwtVerify } from "jose";
import { projectsCollection } from "../../../lib/mongodb";
export const Session = z.object({
userId: z.string(),
@ -18,6 +17,8 @@ export const Session = z.object({
in the request headers and calls the provided handler function.
*/
export async function clientIdCheck(req: NextRequest, handler: (projectId: string) => Promise<Response>): Promise<Response> {
return new Response('Not implemented', { status: 501 });
/*
const clientId = req.headers.get('x-client-id')?.trim();
if (!clientId) {
return Response.json({ error: "Missing client ID in request" }, { status: 400 });
@ -31,6 +32,7 @@ export async function clientIdCheck(req: NextRequest, handler: (projectId: strin
// set the project id in the request headers
req.headers.set('x-project-id', project._id);
return await handler(project._id);
*/
}
/*
@ -42,6 +44,8 @@ export async function clientIdCheck(req: NextRequest, handler: (projectId: strin
provided handler function.
*/
export async function authCheck(req: NextRequest, handler: (session: z.infer<typeof Session>) => Promise<Response>): Promise<Response> {
return new Response('Not implemented', { status: 501 });
/*
const authHeader = req.headers.get('Authorization');
if (!authHeader?.startsWith('Bearer ')) {
return Response.json({ error: "Authorization header must be a Bearer token" }, { status: 400 });
@ -59,4 +63,5 @@ export async function authCheck(req: NextRequest, handler: (session: z.infer<typ
}
return await handler(session.payload as z.infer<typeof Session>);
*/
}