Replace the starter app with a public/local flasher that discovers sibling firmwares, supports en/zh, and documents HTTPS deploy. Co-authored-by: Cursor <cursoragent@cursor.com>
40 lines
1.0 KiB
TypeScript
40 lines
1.0 KiB
TypeScript
import { NextResponse } from "next/server";
|
|
import {
|
|
FLASH_PARTS,
|
|
readFirmwareMeta,
|
|
resolveFirmwareDir,
|
|
} from "@/lib/firmware";
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
type Params = { params: Promise<{ project: string; variant: string }> };
|
|
|
|
export async function GET(_req: Request, { params }: Params) {
|
|
const { project, variant } = await params;
|
|
const dir = resolveFirmwareDir(project, variant);
|
|
if (!dir) {
|
|
return NextResponse.json({ error: "firmware not found" }, { status: 404 });
|
|
}
|
|
|
|
const meta = readFirmwareMeta(dir);
|
|
const name = meta.name || `${project} (${variant})`;
|
|
const version =
|
|
[meta.date, meta.git].filter(Boolean).join(" / ") || "local";
|
|
|
|
const base = `/api/firmware/${encodeURIComponent(project)}/${encodeURIComponent(variant)}`;
|
|
return NextResponse.json({
|
|
name,
|
|
version,
|
|
new_install_prompt_erase: true,
|
|
builds: [
|
|
{
|
|
chipFamily: "ESP32",
|
|
parts: FLASH_PARTS.map((p) => ({
|
|
path: `${base}/${p.file}`,
|
|
offset: p.offset,
|
|
})),
|
|
},
|
|
],
|
|
});
|
|
}
|