fix(striker-ui-api): ignore empty body when create server

main
Tsu-ba-me 2 years ago
parent a65b82d9ee
commit 06c3b9bae4
  1. 9
      striker-ui-api/src/lib/request_handlers/server/createServer.ts

@ -9,8 +9,8 @@ import { dbQuery, sub } from '../../accessModule';
export const createServer: RequestHandler = ({ body }, response) => { export const createServer: RequestHandler = ({ body }, response) => {
console.log('Creating server.'); console.log('Creating server.');
console.dir(body, { depth: null });
if (body) {
const { const {
serverName, serverName,
cpuCores, cpuCores,
@ -22,9 +22,7 @@ export const createServer: RequestHandler = ({ body }, response) => {
driverISOFileUUID, driverISOFileUUID,
anvilUUID, anvilUUID,
optimizeForOS, optimizeForOS,
} = body; } = body || {};
console.dir(body, { depth: null });
const dataServerName = String(serverName); const dataServerName = String(serverName);
const dataOS = String(optimizeForOS); const dataOS = String(optimizeForOS);
@ -87,7 +85,7 @@ export const createServer: RequestHandler = ({ body }, response) => {
`Failed to assert value when trying to provision a server; CAUSE: ${assertError}.`, `Failed to assert value when trying to provision a server; CAUSE: ${assertError}.`,
); );
response.status(500).send(); response.status(400).send();
return; return;
} }
@ -151,7 +149,6 @@ driver_iso=${dataDriverISO}`;
job_host_uuid: provisionServerJobHostUUID, job_host_uuid: provisionServerJobHostUUID,
}, },
}); });
}
response.status(202).send(); response.status(202).send();
}; };

Loading…
Cancel
Save