feat: Process generic updates

This commit is contained in:
Sainan 2024-05-03 14:54:15 +02:00
parent 3363762487
commit 03326754dc

View File

@ -1,28 +1,12 @@
import { updateGeneric } from "@/src/services/inventoryService"; import { updateGeneric } from "@/src/services/inventoryService";
import { IGenericUpdate } from "@/src/types/genericUpdate";
import { RequestHandler } from "express"; import { RequestHandler } from "express";
import { getJSONfromString } from "@/src/helpers/stringHelpers";
// TODO: Nightwave evidence submission support is the only thing missing.
// TODO: this was added by someone without testing. It may not work.
// eslint-disable-next-line @typescript-eslint/no-misused-promises // eslint-disable-next-line @typescript-eslint/no-misused-promises
const genericUpdateController: RequestHandler = async (_request, response) => { const genericUpdateController: RequestHandler = async (request, response) => {
// const accountId = request.query.accountId as string; const accountId = request.query.accountId as string;
const update = getJSONfromString(request.body.toString());
// const [body] = String(request.body).split("\n"); response.json(await updateGeneric(update, accountId));
// let reply = {};
// try {
// const update = JSON.parse(body) as IGenericUpdate;
// if (typeof update !== "object") {
// throw new Error("Invalid data format");
// }
// reply = await updateGeneric(update, accountId);
// } catch (err) {
// console.error("Error parsing JSON data:", err);
// }
response.json({});
}; };
export { genericUpdateController }; export { genericUpdateController };