重构:将 "lobster" 重命名为 "claw" 并添加国际化支持 (i18n)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { eq, sql } from "drizzle-orm";
|
||||
import { db } from "@/lib/db";
|
||||
import { lobsters, tasks } from "@/lib/db/schema";
|
||||
import { claws, tasks } from "@/lib/db/schema";
|
||||
import {
|
||||
incrementGlobalStat,
|
||||
incrementHourlyActivity,
|
||||
@@ -21,8 +21,8 @@ export async function POST(req: NextRequest) {
|
||||
}
|
||||
|
||||
const apiKey = authHeader.slice(7);
|
||||
const lobster = await validateApiKey(apiKey);
|
||||
if (!lobster) {
|
||||
const claw = await validateApiKey(apiKey);
|
||||
if (!claw) {
|
||||
return NextResponse.json({ error: "Invalid API key" }, { status: 401 });
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ export async function POST(req: NextRequest) {
|
||||
const now = new Date();
|
||||
|
||||
const insertResult = await db.insert(tasks).values({
|
||||
lobsterId: lobster.id,
|
||||
clawId: claw.id,
|
||||
summary,
|
||||
durationMs,
|
||||
model: model ?? null,
|
||||
@@ -48,9 +48,9 @@ export async function POST(req: NextRequest) {
|
||||
});
|
||||
|
||||
await db
|
||||
.update(lobsters)
|
||||
.set({ totalTasks: sql`${lobsters.totalTasks} + 1`, updatedAt: now })
|
||||
.where(eq(lobsters.id, lobster.id));
|
||||
.update(claws)
|
||||
.set({ totalTasks: sql`${claws.totalTasks} + 1`, updatedAt: now })
|
||||
.where(eq(claws.id, claw.id));
|
||||
|
||||
await incrementGlobalStat("total_tasks");
|
||||
await incrementGlobalStat("tasks_today");
|
||||
@@ -58,10 +58,10 @@ export async function POST(req: NextRequest) {
|
||||
|
||||
await publishEvent({
|
||||
type: "task",
|
||||
lobsterId: lobster.id,
|
||||
lobsterName: lobster.name,
|
||||
city: lobster.city,
|
||||
country: lobster.country,
|
||||
clawId: claw.id,
|
||||
clawName: claw.name,
|
||||
city: claw.city,
|
||||
country: claw.country,
|
||||
summary,
|
||||
durationMs,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user