feat: get endpoint for giveStartingGear
All checks were successful
Build / build (pull_request) Successful in 1m57s

Closes #2995
This commit is contained in:
2025-11-05 16:26:17 +01:00
parent be064fd249
commit 07df738898
3 changed files with 26 additions and 6 deletions

View File

@@ -4,7 +4,7 @@ import { getAccountIdForRequest } from "../../services/loginService.ts";
import type { TPartialStartingGear } from "../../types/inventoryTypes/inventoryTypes.ts";
import type { RequestHandler } from "express";
export const giveStartingGearController: RequestHandler = async (req, res) => {
export const giveStartingGearPostController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
const startingGear = getJSONfromString<TPartialStartingGear>(String(req.body));
const inventory = await getInventory(accountId);
@@ -14,3 +14,21 @@ export const giveStartingGearController: RequestHandler = async (req, res) => {
res.send(inventoryChanges);
};
export const giveStartingGearGetController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
const inventory = await getInventory(accountId);
const inventoryChanges = await addStartingGear(inventory, {
Suits: [
{
ItemType: String(req.query.warframeName),
ItemId: { $oid: "0" },
Configs: []
}
]
});
await inventory.save();
res.send(inventoryChanges); // Not sure if this is even needed
};

View File

@@ -80,7 +80,7 @@ import { giveKeyChainTriggeredItemsController } from "../controllers/api/giveKey
import { giveKeyChainTriggeredMessageController } from "../controllers/api/giveKeyChainTriggeredMessageController.ts";
import { giveQuestKeyRewardController } from "../controllers/api/giveQuestKeyRewardController.ts";
import { giveShipDecoAndLoreFragmentController } from "../controllers/api/giveShipDecoAndLoreFragmentController.ts";
import { giveStartingGearController } from "../controllers/api/giveStartingGearController.ts";
import { giveStartingGearGetController, giveStartingGearPostController } from "../controllers/api/giveStartingGearController.ts";
import { guildTechController } from "../controllers/api/guildTechController.ts";
import { hostSessionController } from "../controllers/api/hostSessionController.ts";
import { hubBlessingController } from "../controllers/api/hubBlessingController.ts";
@@ -297,7 +297,8 @@ apiRouter.post("/giveKeyChainTriggeredItems.php", giveKeyChainTriggeredItemsCont
apiRouter.post("/giveKeyChainTriggeredMessage.php", giveKeyChainTriggeredMessageController);
apiRouter.post("/giveQuestKeyReward.php", giveQuestKeyRewardController);
apiRouter.post("/giveShipDecoAndLoreFragment.php", giveShipDecoAndLoreFragmentController);
apiRouter.post("/giveStartingGear.php", giveStartingGearController);
apiRouter.post("/giveStartingGear.php", giveStartingGearPostController);
apiRouter.get("/giveStartingGear.php", giveStartingGearGetController);
apiRouter.post("/guildTech.php", guildTechController);
apiRouter.post("/hostSession.php", hostSessionController);
apiRouter.post("/hubBlessing.php", hubBlessingController);

View File

@@ -137,18 +137,19 @@ export const createInventory = async (
export const addStartingGear = async (
inventory: TInventoryDatabaseDocument,
startingGear?: TPartialStartingGear
startingGear?: Partial<TPartialStartingGear>
): Promise<IInventoryChanges> => {
if (inventory.ReceivedStartingGear) {
throw new Error(`account has already received starting gear`);
}
inventory.ReceivedStartingGear = true;
const { LongGuns, Pistols, Suits, Melee } = startingGear || {
const { LongGuns, Pistols, Suits, Melee } = {
LongGuns: [{ ItemType: "/Lotus/Weapons/Tenno/Rifle/Rifle" }],
Pistols: [{ ItemType: "/Lotus/Weapons/Tenno/Pistol/Pistol" }],
Suits: [{ ItemType: "/Lotus/Powersuits/Excalibur/Excalibur" }],
Melee: [{ ItemType: "/Lotus/Weapons/Tenno/Melee/LongSword/LongSword" }]
Melee: [{ ItemType: "/Lotus/Weapons/Tenno/Melee/LongSword/LongSword" }],
...startingGear
};
//TODO: properly merge weapon bin changes it is currently static here