blob: cbed547d7214a280d0d90f3123e2d1d792dcb97d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
import { db } from "@/server/db";
import { sessions, space, users } from "@/server/db/schema";
import { eq } from "drizzle-orm";
import { NextRequest, NextResponse } from "next/server";
import { ensureAuth } from "../ensureAuth";
export const runtime = "edge";
export async function GET(req: NextRequest) {
const session = await ensureAuth(req);
if (!session) {
return new Response("Unauthorized", { status: 401 });
}
const spaces = await db
.select()
.from(space)
.where(eq(space.user, session.user.id))
.all();
return NextResponse.json(
{
message: "OK",
data: spaces,
},
{ status: 200 },
);
}
|