feat: get endpoint for giveStartingGear (#2997)
Some checks failed
Build / build (push) Has been cancelled
Build Docker image / docker (push) Has been cancelled

Closes #2995

Reviewed-on: #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>
This commit was merged in pull request #2997.
This commit is contained in:
2025-11-06 00:17:21 -08:00
committed by Sainan
parent 4ab5794f61
commit 8ceab34f22
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";
@@ -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);

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