mirror of
https://github.com/profullstack/logicsrc.git
synced 2026-08-13 14:37:26 +00:00
Return 400 for invalid publish JSON (#20)
This commit is contained in:
parent
7cda686059
commit
301b4ed535
1 changed files with 8 additions and 1 deletions
|
|
@ -217,7 +217,14 @@ async function route(request: IncomingMessage, response: ServerResponse) {
|
|||
}
|
||||
|
||||
if (request.method === "POST" && url.pathname === "/api/plugins/sh1pt/actions/publish") {
|
||||
const body = await readJson(request);
|
||||
let body: unknown;
|
||||
try {
|
||||
body = await readJson(request);
|
||||
} catch {
|
||||
json(response, 400, { error: "Invalid JSON body" });
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isRecord(body) || typeof body.action_id !== "string") {
|
||||
json(response, 422, { error: "Expected action_id" });
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue