This commit is contained in:
2025-11-14 15:30:44 +08:00
parent adcb7920bd
commit cf3cb916b7
42 changed files with 939 additions and 655 deletions

View File

@@ -1,18 +0,0 @@
import { getServerSession } from "next-auth";
import { NextResponse } from "next/server";
import { authOptions } from "../../auth/[...nextauth]/route";
import { WordPairController } from "@/lib/db";
export async function GET({ params }: { params: { slug: number } }) {
const session = await getServerSession(authOptions);
if (session) {
const id = params.slug;
return new NextResponse(
JSON.stringify(
await WordPairController.getWordPairsByFolderId(id),
),
);
} else {
return new NextResponse("Unauthorized");
}
}

View File

@@ -1,35 +0,0 @@
import { getServerSession } from "next-auth";
import { NextRequest, NextResponse } from "next/server";
import { authOptions } from "../auth/[...nextauth]/route";
import { FolderController } from "@/lib/db";
export async function GET() {
const session = await getServerSession(authOptions);
if (session) {
return new NextResponse(
JSON.stringify(
await FolderController.getFoldersByOwner(session.user!.name as string),
),
);
} else {
return new NextResponse("Unauthorized");
}
}
export async function POST(req: NextRequest) {
const session = await getServerSession(authOptions);
if (session) {
const body = await req.json();
return new NextResponse(
JSON.stringify(
await FolderController.createFolder(
body.name,
session.user!.name as string,
),
),
);
} else {
return new NextResponse("Unauthorized");
}
}

View File

@@ -1,4 +1,4 @@
import { callZhipuAPI, handleAPIError } from "@/utils";
import { callZhipuAPI, handleAPIError } from "@/lib/utils";
import { NextRequest, NextResponse } from "next/server";
async function getIPA(text: string) {

View File

@@ -1,4 +1,4 @@
import { callZhipuAPI } from "@/utils";
import { callZhipuAPI } from "@/lib/utils";
import { NextRequest, NextResponse } from "next/server";
async function getLocale(text: string) {

View File

@@ -1,4 +1,4 @@
import { callZhipuAPI } from "@/utils";
import { callZhipuAPI } from "@/lib/utils";
import { NextRequest, NextResponse } from "next/server";
async function translate(text: string, target_lang: string) {