mirror of
https://github.com/profullstack/logicsrc.git
synced 2026-08-14 06:47:28 +00:00
Return 400 for invalid publish JSON
This commit is contained in:
parent
850cf5ea44
commit
4c9c80d7e6
1 changed files with 8 additions and 1 deletions
|
|
@ -206,7 +206,14 @@ async function route(request: IncomingMessage, response: ServerResponse) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.method === "POST" && url.pathname === "/api/plugins/sh1pt/actions/publish") {
|
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") {
|
if (!isRecord(body) || typeof body.action_id !== "string") {
|
||||||
json(response, 422, { error: "Expected action_id" });
|
json(response, 422, { error: "Expected action_id" });
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue