import { getAllUsersForAssignment, updateProjectAssignment, } from "@/lib/queries/projects"; import initializeDatabase from "@/lib/init-db"; import { NextResponse } from "next/server"; import { withUserAuth } from "@/lib/middleware/auth"; // Make sure the DB is initialized before queries run initializeDatabase(); async function getUsersHandler(req) { const users = getAllUsersForAssignment(); return NextResponse.json(users); } async function updateAssignmentHandler(req) { const { projectId, assignedToUserId } = await req.json(); if (!projectId) { return NextResponse.json( { error: "Project ID is required" }, { status: 400 } ); } updateProjectAssignment(projectId, assignedToUserId); return NextResponse.json({ success: true }); } // Protected routes - require authentication export const GET = withUserAuth(getUsersHandler); export const POST = withUserAuth(updateAssignmentHandler);