forked from OpenWF/SpaceNinjaServer
Reviewed-on: OpenWF/SpaceNinjaServer#1555 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>
22 lines
934 B
TypeScript
22 lines
934 B
TypeScript
import { RequestHandler } from "express";
|
|
import { ISaveLoadoutRequest } from "@/src/types/saveLoadoutTypes";
|
|
import { handleInventoryItemConfigChange } from "@/src/services/saveLoadoutService";
|
|
import { getAccountIdForRequest } from "@/src/services/loginService";
|
|
|
|
export const saveLoadoutController: RequestHandler = async (req, res) => {
|
|
const accountId = await getAccountIdForRequest(req);
|
|
|
|
const body: ISaveLoadoutRequest = JSON.parse(req.body as string) as ISaveLoadoutRequest;
|
|
// console.log(util.inspect(body, { showHidden: false, depth: null, colors: true }));
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
const { UpgradeVer, ...equipmentChanges } = body;
|
|
const newLoadoutId = await handleInventoryItemConfigChange(equipmentChanges, accountId);
|
|
|
|
//send back new loadout id, if new loadout was added
|
|
if (newLoadoutId) {
|
|
res.send(newLoadoutId);
|
|
}
|
|
res.end();
|
|
};
|