...
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
@@ -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) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { callZhipuAPI } from "@/utils";
|
||||
import { callZhipuAPI } from "@/lib/utils";
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
|
||||
async function getLocale(text: string) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user