feat: Implement OpenAPI with API Key authentication and role-based access control

This commit is contained in:
beilunyang
2025-02-10 11:25:25 +08:00
parent 1bc0369b83
commit 9ad3115833
28 changed files with 2339 additions and 144 deletions
+4 -3
View File
@@ -1,16 +1,17 @@
import { auth } from "@/lib/auth"
import { createDb } from "@/lib/db"
import { and, eq, gt, lt, or, sql } from "drizzle-orm"
import { NextResponse } from "next/server"
import { emails } from "@/lib/schema"
import { encodeCursor, decodeCursor } from "@/lib/cursor"
import { getUserId } from "@/lib/apiKey"
export const runtime = "edge"
const PAGE_SIZE = 20
export async function GET(request: Request) {
const session = await auth()
const userId = await getUserId()
const { searchParams } = new URL(request.url)
const cursor = searchParams.get('cursor')
@@ -18,7 +19,7 @@ export async function GET(request: Request) {
try {
const baseConditions = and(
eq(emails.userId, session!.user!.id!),
eq(emails.userId, userId!),
gt(emails.expiresAt, new Date())
)