initial commit
This commit is contained in:
18
app/api/publish/route.ts
Normal file
18
app/api/publish/route.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { HttpError } from "@/lib/errors";
|
||||
import { gitStatus } from "@/lib/git";
|
||||
import { readJson, route } from "@/lib/http";
|
||||
import { publish } from "@/lib/publish";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export const GET = route(async () => Response.json(await gitStatus()));
|
||||
|
||||
/** Body: { message } -> commit managed paths, push, trigger deploy. A failed
|
||||
* step is reported in the body ({ ok: false, steps }), not as an HTTP error. */
|
||||
export const POST = route(async (req) => {
|
||||
const { message } = await readJson<{ message?: string }>(req);
|
||||
const msg = message?.trim();
|
||||
if (!msg) throw new HttpError(400, "commit message is required");
|
||||
const result = await publish(msg);
|
||||
return Response.json({ ...result, status: await gitStatus() });
|
||||
});
|
||||
Reference in New Issue
Block a user