mirror of
https://github.com/agentscope-ai/ReMe.git
synced 2026-10-05 02:41:43 +00:00
* refactor(packaging): reorganize published packages * fix(packaging): install AgentScope extra in wheel smoke * docs: align package guides and documentation site * ci(workflow): add core dependency verification step in Python package build - Add a workflow step to verify released core dependencies by installing the wheel with core extras - Assert the presence of the static index.html file to ensure proper package contents - Create and use a temporary virtual environment for isolation during verification - Keep existing artifacts upload step intact and conditional on inputs.upload_artifacts flag * fix(ci): update package installation dependencies in Windows workflow - Change pip install from editable reme_studio and core to only dev and as extras - Remove installation of reme_studio and core to streamline dependency setup - Ensure Windows CI uses the correct extras for testing environment * fix(tests): add missing commas in toml file reads in package version tests - Added trailing commas in the tomllib.loads calls for auto-fin and daily_paper configs - Ensured consistent syntax to prevent potential tuple misinterpretation - Improved readability and correctness of the test setup code * fix(packaging): protect qwenpaw releases and test Studio health
63 lines
1.7 KiB
TypeScript
63 lines
1.7 KiB
TypeScript
import { desc } from "drizzle-orm";
|
|
import { getDb } from "../../../../../db";
|
|
import { notes } from "../../../db/schema";
|
|
|
|
function toRouteErrorMessage(error: unknown) {
|
|
const message = error instanceof Error ? error.message : "Unexpected error";
|
|
const detail =
|
|
error instanceof Error && error.cause instanceof Error
|
|
? error.cause.message
|
|
: "";
|
|
const combined = `${message}\n${detail}`;
|
|
|
|
if (combined.includes("no such table") || combined.includes('from "notes"')) {
|
|
return "The notes table is unavailable. Generate the migration locally with `npm run db:generate`, then deploy so the platform can apply the generated SQL to the real D1 database.";
|
|
}
|
|
|
|
return message;
|
|
}
|
|
|
|
export async function GET() {
|
|
try {
|
|
const db = getDb();
|
|
const rows = await db
|
|
.select()
|
|
.from(notes)
|
|
.orderBy(desc(notes.createdAt), desc(notes.id))
|
|
.limit(20);
|
|
|
|
return Response.json({ notes: rows });
|
|
} catch (error) {
|
|
return Response.json(
|
|
{ error: toRouteErrorMessage(error) },
|
|
{ status: 500 },
|
|
);
|
|
}
|
|
}
|
|
|
|
export async function POST(request: Request) {
|
|
try {
|
|
const payload = (await request.json()) as {
|
|
title?: string;
|
|
content?: string;
|
|
};
|
|
const title = payload.title?.trim() ?? "";
|
|
const content = payload.content?.trim() ?? "";
|
|
|
|
if (!title) {
|
|
return Response.json({ error: "title is required" }, { status: 400 });
|
|
}
|
|
|
|
const db = getDb();
|
|
const [note] = await db
|
|
.insert(notes)
|
|
.values({ title, content })
|
|
.returning();
|
|
return Response.json({ note }, { status: 201 });
|
|
} catch (error) {
|
|
return Response.json(
|
|
{ error: toRouteErrorMessage(error) },
|
|
{ status: 500 },
|
|
);
|
|
}
|
|
}
|