pipedrive / src /app /api /pipelines /route.ts
ppEmiliano's picture
Add full CRM application with HF Spaces Docker deployment
ea8dde3
Raw
History Blame Contribute Delete
571 Bytes
import { NextRequest, NextResponse } from "next/server";
import { db } from "@/lib/db";
import { pipelines, pipelineStages } from "@/lib/db/schema";
import { auth } from "@/lib/auth";
import { eq } from "drizzle-orm";
export async function GET() {
const session = await auth();
if (!session?.user?.id) return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
const userId = parseInt(session.user.id);
const results = db
.select()
.from(pipelines)
.where(eq(pipelines.userId, userId))
.all();
return NextResponse.json(results);
}