2024-05-28 13:45:06 +02:00
|
|
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
2023-09-05 07:37:30 -05:00
|
|
|
import { updateGeneric } from "@/src/services/inventoryService";
|
2023-06-01 17:08:05 -07:00
|
|
|
import { RequestHandler } from "express";
|
2024-05-03 15:37:43 +02:00
|
|
|
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
2024-06-24 12:37:28 +02:00
|
|
|
import { IGenericUpdate } from "@/src/types/genericUpdate";
|
2023-06-01 17:08:05 -07:00
|
|
|
|
2024-08-14 15:14:59 +02:00
|
|
|
// This endpoint used to be /api/genericUpdate.php, but sometime around the Jade Shadows update, it was changed to /api/updateNodeIntros.php.
|
|
|
|
// SpaceNinjaServer supports both endpoints right now.
|
|
|
|
|
2024-05-03 15:37:43 +02:00
|
|
|
const genericUpdateController: RequestHandler = async (request, response) => {
|
2024-05-28 13:45:06 +02:00
|
|
|
const accountId = await getAccountIdForRequest(request);
|
2024-06-24 12:37:28 +02:00
|
|
|
const update = getJSONfromString(String(request.body)) as IGenericUpdate;
|
2024-10-17 22:24:24 +02:00
|
|
|
await updateGeneric(update, accountId);
|
|
|
|
response.json(update);
|
2023-06-01 17:08:05 -07:00
|
|
|
};
|
|
|
|
|
2023-06-02 00:20:49 -03:00
|
|
|
export { genericUpdateController };
|