From 8ceab34f224567aacffa611aa3db846ce24cd5f5 Mon Sep 17 00:00:00 2001 From: AMelonInsideLemon <166175391+AMelonInsideLemon@users.noreply.github.com> Date: Thu, 6 Nov 2025 00:17:21 -0800 Subject: [PATCH] feat: get endpoint for giveStartingGear (#2997) Closes #2995 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/2997 Reviewed-by: Sainan <63328889+sainan@users.noreply.github.com> Co-authored-by: AMelonInsideLemon <166175391+AMelonInsideLemon@users.noreply.github.com> Co-committed-by: AMelonInsideLemon <166175391+AMelonInsideLemon@users.noreply.github.com> --- .../api/giveStartingGearController.ts | 20 ++++++++++++++++++- src/routes/api.ts | 5 +++-- src/services/inventoryService.ts | 7 ++++--- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/controllers/api/giveStartingGearController.ts b/src/controllers/api/giveStartingGearController.ts index cd964ef1..895ffec3 100644 --- a/src/controllers/api/giveStartingGearController.ts +++ b/src/controllers/api/giveStartingGearController.ts @@ -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(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 +}; diff --git a/src/routes/api.ts b/src/routes/api.ts index 6184c8f0..684a7285 100644 --- a/src/routes/api.ts +++ b/src/routes/api.ts @@ -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"; @@ -208,6 +208,7 @@ apiRouter.get("/getNewRewardSeed.php", getNewRewardSeedController); apiRouter.get("/getPastWeeklyChallenges.php", getPastWeeklyChallengesController) apiRouter.get("/getShip.php", getShipController); apiRouter.get("/getShipDecos.php", (_req, res) => { res.end(); }); // needed to log in on U22.8 +apiRouter.get("/giveStartingGear.php", giveStartingGearGetController); apiRouter.get("/getVendorInfo.php", getVendorInfoController); apiRouter.get("/hub", hubController); apiRouter.get("/hubInstances", hubInstancesController); @@ -297,7 +298,7 @@ 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.post("/guildTech.php", guildTechController); apiRouter.post("/hostSession.php", hostSessionController); apiRouter.post("/hubBlessing.php", hubBlessingController); diff --git a/src/services/inventoryService.ts b/src/services/inventoryService.ts index b8cbcc16..d01b42ff 100644 --- a/src/services/inventoryService.ts +++ b/src/services/inventoryService.ts @@ -137,18 +137,19 @@ export const createInventory = async ( export const addStartingGear = async ( inventory: TInventoryDatabaseDocument, - startingGear?: TPartialStartingGear + startingGear?: Partial ): Promise => { 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