Date: Mon, 24 Jun 2024 12:30:32 +0200
Subject: [PATCH 3/5] improve: purchasing of animation sets, colour plattes,
etc. (#394)
---
src/services/inventoryService.ts | 22 ++++++++--------------
static/webui/index.html | 2 +-
2 files changed, 9 insertions(+), 15 deletions(-)
diff --git a/src/services/inventoryService.ts b/src/services/inventoryService.ts
index 1b2a4ed2..d5a4edb9 100644
--- a/src/services/inventoryService.ts
+++ b/src/services/inventoryService.ts
@@ -27,7 +27,7 @@ import { logger } from "@/src/utils/logger";
import { WeaponTypeInternal, getWeaponType, getExalted } from "@/src/services/itemDataService";
import { ISyndicateSacrifice, ISyndicateSacrificeResponse } from "../types/syndicateTypes";
import { IEquipmentClient } from "../types/inventoryTypes/commonInventoryTypes";
-import { ExportCustoms, ExportRecipes, ExportResources } from "warframe-public-export-plus";
+import { ExportCustoms, ExportFlavour, ExportRecipes, ExportResources } from "warframe-public-export-plus";
export const createInventory = async (
accountOwnerId: Types.ObjectId,
@@ -112,6 +112,13 @@ export const addItem = async (
}
};
}
+ if (typeName in ExportFlavour) {
+ return {
+ InventoryChanges: {
+ FlavourItems: [await addCustomization(typeName, accountId)]
+ }
+ };
+ }
// Path-based duck typing
switch (typeName.substr(1).split("/")[1]) {
@@ -171,12 +178,6 @@ export const addItem = async (
[weaponType]: [weapon]
}
};
- case "Interface":
- return {
- InventoryChanges: {
- FlavourItems: [await addCustomization(typeName, accountId)]
- }
- };
case "Objects": {
// /Lotus/Objects/Tenno/Props/TnoLisetTextProjector (Note Beacon)
const inventory = await getInventory(accountId);
@@ -196,13 +197,6 @@ export const addItem = async (
}
case "Types":
switch (typeName.substr(1).split("/")[2]) {
- case "AvatarImages":
- case "SuitCustomizations":
- return {
- InventoryChanges: {
- FlavourItems: [await addCustomization(typeName, accountId)]
- }
- };
case "Sentinels":
// TOOD: Sentinels should also grant their DefaultUpgrades & SentinelWeapon.
const sentinel = await addSentinel(typeName, accountId);
diff --git a/static/webui/index.html b/static/webui/index.html
index 8d296f2a..037c5280 100644
--- a/static/webui/index.html
+++ b/static/webui/index.html
@@ -248,7 +248,7 @@
From d3004b19dda194a0de942825fb6c3348169eb261 Mon Sep 17 00:00:00 2001
From: Sainan
Date: Mon, 24 Jun 2024 12:31:29 +0200
Subject: [PATCH 4/5] improve: handle purchase quantity of gear items (#389)
Co-authored-by: Sainan
---
package-lock.json | 8 ++++----
package.json | 2 +-
src/services/purchaseService.ts | 15 +++++++++++----
3 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/package-lock.json b/package-lock.json
index a69058da..d2ca4c16 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -12,7 +12,7 @@
"copyfiles": "^2.4.1",
"express": "^5.0.0-beta.3",
"mongoose": "^8.1.1",
- "warframe-public-export-plus": "^0.3.2",
+ "warframe-public-export-plus": "^0.3.3",
"warframe-riven-info": "^0.1.0",
"winston": "^3.11.0",
"winston-daily-rotate-file": "^4.7.1"
@@ -3669,9 +3669,9 @@
}
},
"node_modules/warframe-public-export-plus": {
- "version": "0.3.2",
- "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.3.2.tgz",
- "integrity": "sha512-0jAStLLrMaz0zm7wfY1/3SWLPmMJcYNNErVTPo8YqBZlot1aikVuDNu+crVmN+LWDDLrn01T7f83EYaw7TYo6w=="
+ "version": "0.3.3",
+ "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.3.3.tgz",
+ "integrity": "sha512-35pSMqXxe9vG4kdA+SnCyZyWO8zRGuPQbNeOPgZm5886kiujR+Qd6iY7TH0fdQYgKCk1M+q8lXonATT9VB9bbQ=="
},
"node_modules/warframe-riven-info": {
"version": "0.1.0",
diff --git a/package.json b/package.json
index 3436b14a..f5b472df 100644
--- a/package.json
+++ b/package.json
@@ -16,7 +16,7 @@
"copyfiles": "^2.4.1",
"express": "^5.0.0-beta.3",
"mongoose": "^8.1.1",
- "warframe-public-export-plus": "^0.3.2",
+ "warframe-public-export-plus": "^0.3.3",
"warframe-riven-info": "^0.1.0",
"winston": "^3.11.0",
"winston-daily-rotate-file": "^4.7.1"
diff --git a/src/services/purchaseService.ts b/src/services/purchaseService.ts
index 6f55bad0..add4032c 100644
--- a/src/services/purchaseService.ts
+++ b/src/services/purchaseService.ts
@@ -3,7 +3,7 @@ import { getSubstringFromKeyword } from "@/src/helpers/stringHelpers";
import { addItem, addBooster, updateCurrency, updateSlots } from "@/src/services/inventoryService";
import { IPurchaseRequest, SlotPurchase, IInventoryChanges, IBinChanges } from "@/src/types/purchaseTypes";
import { logger } from "@/src/utils/logger";
-import { ExportBundles, TRarity } from "warframe-public-export-plus";
+import { ExportBundles, ExportGear, TRarity } from "warframe-public-export-plus";
export const getStoreItemCategory = (storeItem: string) => {
const storeItemString = getSubstringFromKeyword(storeItem, "StoreItems/");
@@ -75,7 +75,8 @@ const handleStoreItemAcquisition = async (
storeItemName: string,
accountId: string,
quantity: number,
- durability: TRarity
+ durability: TRarity,
+ ignorePurchaseQuantity: boolean = false
): Promise<{ InventoryChanges: IInventoryChanges }> => {
let purchaseResponse = {
InventoryChanges: {}
@@ -92,7 +93,8 @@ const handleStoreItemAcquisition = async (
component.typeName,
accountId,
component.purchaseQuantity * quantity,
- component.durability
+ component.durability,
+ true
)
).InventoryChanges
);
@@ -101,9 +103,14 @@ const handleStoreItemAcquisition = async (
const storeCategory = getStoreItemCategory(storeItemName);
const internalName = storeItemName.replace("/StoreItems", "");
logger.debug(`store category ${storeCategory}`);
+ if (!ignorePurchaseQuantity) {
+ if (internalName in ExportGear) {
+ quantity *= ExportGear[internalName].purchaseQuantity || 1;
+ }
+ }
switch (storeCategory) {
default:
- purchaseResponse = await addItem(accountId, internalName);
+ purchaseResponse = await addItem(accountId, internalName, quantity);
break;
case "Types":
purchaseResponse = await handleTypesPurchase(internalName, accountId, quantity);
From ac6eaa2f4efa696c8b5aec4859f0f5c3989e9965 Mon Sep 17 00:00:00 2001
From: Sainan
Date: Mon, 24 Jun 2024 12:37:28 +0200
Subject: [PATCH 5/5] fix: Convert all Body to String Before Use (#382)
---
.eslintrc | 2 +-
src/controllers/api/addFriendImageController.ts | 2 +-
.../api/claimCompletedRecipeController.ts | 2 +-
src/controllers/api/createGuildController.ts | 2 +-
src/controllers/api/evolveWeaponController.ts | 2 +-
src/controllers/api/findSessionsController.ts | 10 +++++-----
src/controllers/api/focusController.ts | 12 ++++++------
src/controllers/api/genericUpdateController.ts | 3 ++-
src/controllers/api/infestedFoundryController.ts | 10 +++++++---
src/controllers/api/joinSessionController.ts | 6 +++---
.../api/modularWeaponCraftingController.ts | 2 +-
src/controllers/api/nameWeaponController.ts | 2 +-
src/controllers/api/sellController.ts | 2 +-
src/controllers/api/setWeaponSkillTreeController.ts | 2 +-
src/controllers/api/startDojoRecipeController.ts | 2 +-
src/controllers/api/startRecipeController.ts | 2 +-
src/controllers/api/stepSequencersController.ts | 2 +-
src/controllers/api/syndicateSacrificeController.ts | 3 +--
src/controllers/api/trainingResultController.ts | 2 +-
.../api/updateChallengeProgressController.ts | 2 +-
src/controllers/api/updateSessionController.ts | 4 ++--
src/controllers/api/upgradesController.ts | 2 +-
src/controllers/custom/updateConfigDataController.ts | 2 +-
23 files changed, 42 insertions(+), 38 deletions(-)
diff --git a/.eslintrc b/.eslintrc
index 3b7c142a..70cbe0f1 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -19,7 +19,7 @@
"@typescript-eslint/no-unsafe-member-access": "warn",
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
"@typescript-eslint/no-misused-promises": "warn",
- "@typescript-eslint/no-unsafe-argument": "warn",
+ "@typescript-eslint/no-unsafe-argument": "error",
"@typescript-eslint/no-unsafe-call": "warn",
"@typescript-eslint/no-unsafe-assignment": "warn",
"@typescript-eslint/no-explicit-any": "warn",
diff --git a/src/controllers/api/addFriendImageController.ts b/src/controllers/api/addFriendImageController.ts
index 6c9a2370..3ca2e1bd 100644
--- a/src/controllers/api/addFriendImageController.ts
+++ b/src/controllers/api/addFriendImageController.ts
@@ -7,7 +7,7 @@ import { getInventory } from "@/src/services/inventoryService";
// eslint-disable-next-line @typescript-eslint/no-misused-promises
const addFriendImageController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
- const json = getJSONfromString(req.body.toString()) as IUpdateGlyphRequest;
+ const json = getJSONfromString(String(req.body)) as IUpdateGlyphRequest;
const inventory = await getInventory(accountId);
inventory.ActiveAvatarImageType = json.AvatarImageType;
await inventory.save();
diff --git a/src/controllers/api/claimCompletedRecipeController.ts b/src/controllers/api/claimCompletedRecipeController.ts
index cd8aa3c4..27267953 100644
--- a/src/controllers/api/claimCompletedRecipeController.ts
+++ b/src/controllers/api/claimCompletedRecipeController.ts
@@ -15,7 +15,7 @@ export interface IClaimCompletedRecipeRequest {
// eslint-disable-next-line @typescript-eslint/no-misused-promises
export const claimCompletedRecipeController: RequestHandler = async (req, res) => {
- const claimCompletedRecipeRequest = getJSONfromString(req.body.toString()) as IClaimCompletedRecipeRequest;
+ const claimCompletedRecipeRequest = getJSONfromString(String(req.body)) as IClaimCompletedRecipeRequest;
const accountId = await getAccountIdForRequest(req);
if (!accountId) throw new Error("no account id");
diff --git a/src/controllers/api/createGuildController.ts b/src/controllers/api/createGuildController.ts
index 9499e308..73597db2 100644
--- a/src/controllers/api/createGuildController.ts
+++ b/src/controllers/api/createGuildController.ts
@@ -8,7 +8,7 @@ import { ICreateGuildRequest } from "@/src/types/guildTypes";
// eslint-disable-next-line @typescript-eslint/no-misused-promises
const createGuildController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
- const payload: ICreateGuildRequest = getJSONfromString(req.body.toString());
+ const payload = getJSONfromString(String(req.body)) as ICreateGuildRequest;
// Create guild on database
const guild = new Guild({
diff --git a/src/controllers/api/evolveWeaponController.ts b/src/controllers/api/evolveWeaponController.ts
index fea82844..77e33239 100644
--- a/src/controllers/api/evolveWeaponController.ts
+++ b/src/controllers/api/evolveWeaponController.ts
@@ -9,7 +9,7 @@ import { EquipmentFeatures } from "@/src/types/inventoryTypes/commonInventoryTyp
export const evolveWeaponController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
const inventory = await getInventory(accountId);
- const payload = getJSONfromString(req.body.toString()) as IEvolveWeaponRequest;
+ const payload = getJSONfromString(String(req.body)) as IEvolveWeaponRequest;
console.assert(payload.Action == "EWA_INSTALL");
// TODO: We should remove the Genesis item & its resources, but currently we don't know these "recipes".
diff --git a/src/controllers/api/findSessionsController.ts b/src/controllers/api/findSessionsController.ts
index c35b9607..7b7d126a 100644
--- a/src/controllers/api/findSessionsController.ts
+++ b/src/controllers/api/findSessionsController.ts
@@ -4,25 +4,25 @@ import { logger } from "@/src/utils/logger";
//TODO: cleanup
const findSessionsController: RequestHandler = (_req, res) => {
- const reqBody = JSON.parse(_req.body);
+ const reqBody = JSON.parse(String(_req.body));
logger.debug("FindSession Request ", { reqBody });
- const req = JSON.parse(_req.body);
+ const req = JSON.parse(String(_req.body));
if (req.id != undefined) {
logger.debug("Found ID");
- const session = getSession(req.id);
+ const session = getSession(req.id as string);
if (session) res.json({ queryId: req.queryId, Sessions: session });
else res.json({});
} else if (req.originalSessionId != undefined) {
logger.debug("Found OriginalSessionID");
- const session = getSession(req.originalSessionId);
+ const session = getSession(req.originalSessionId as string);
if (session) res.json({ queryId: req.queryId, Sessions: session });
else res.json({});
} else {
logger.debug("Found SessionRequest");
- const session = getSession(_req.body);
+ const session = getSession(String(_req.body));
if (session) res.json({ queryId: req.queryId, Sessions: session });
else res.json({});
}
diff --git a/src/controllers/api/focusController.ts b/src/controllers/api/focusController.ts
index ff0a9616..2558e3c2 100644
--- a/src/controllers/api/focusController.ts
+++ b/src/controllers/api/focusController.ts
@@ -15,7 +15,7 @@ export const focusController: RequestHandler = async (req, res) => {
res.end();
break;
case FocusOperation.UnlockWay: {
- const focusType = (JSON.parse(req.body.toString()) as IWayRequest).FocusType;
+ const focusType = (JSON.parse(String(req.body)) as IWayRequest).FocusType;
const focusPolarity = focusTypeToPolarity(focusType);
const inventory = await getInventory(accountId);
const cost = inventory.FocusAbility ? 50_000 : 0;
@@ -32,7 +32,7 @@ export const focusController: RequestHandler = async (req, res) => {
break;
}
case FocusOperation.ActivateWay: {
- const focusType = (JSON.parse(req.body.toString()) as IWayRequest).FocusType;
+ const focusType = (JSON.parse(String(req.body)) as IWayRequest).FocusType;
const inventory = await getInventory(accountId);
inventory.FocusAbility = focusType;
await inventory.save();
@@ -40,7 +40,7 @@ export const focusController: RequestHandler = async (req, res) => {
break;
}
case FocusOperation.UnlockUpgrade: {
- const request = JSON.parse(req.body.toString()) as IUnlockUpgradeRequest;
+ const request = JSON.parse(String(req.body)) as IUnlockUpgradeRequest;
const focusPolarity = focusTypeToPolarity(request.FocusTypes[0]);
const inventory = await getInventory(accountId);
let cost = 0;
@@ -57,7 +57,7 @@ export const focusController: RequestHandler = async (req, res) => {
break;
}
case FocusOperation.LevelUpUpgrade: {
- const request = JSON.parse(req.body.toString()) as ILevelUpUpgradeRequest;
+ const request = JSON.parse(String(req.body)) as ILevelUpUpgradeRequest;
const focusPolarity = focusTypeToPolarity(request.FocusInfos[0].ItemType);
const inventory = await getInventory(accountId);
let cost = 0;
@@ -75,7 +75,7 @@ export const focusController: RequestHandler = async (req, res) => {
break;
}
case FocusOperation.UnbindUpgrade: {
- const request = JSON.parse(req.body.toString()) as IUnbindUpgradeRequest;
+ const request = JSON.parse(String(req.body)) as IUnbindUpgradeRequest;
const focusPolarity = focusTypeToPolarity(request.FocusTypes[0]);
const inventory = await getInventory(accountId);
inventory.FocusXP[focusPolarity] -= 750_000 * request.FocusTypes.length;
@@ -105,7 +105,7 @@ export const focusController: RequestHandler = async (req, res) => {
break;
}
case FocusOperation.ConvertShard: {
- const request = JSON.parse(req.body.toString()) as IConvertShardRequest;
+ const request = JSON.parse(String(req.body)) as IConvertShardRequest;
// Tally XP
let xp = 0;
for (const shard of request.Shards) {
diff --git a/src/controllers/api/genericUpdateController.ts b/src/controllers/api/genericUpdateController.ts
index f2d29fc1..cf769f3f 100644
--- a/src/controllers/api/genericUpdateController.ts
+++ b/src/controllers/api/genericUpdateController.ts
@@ -2,11 +2,12 @@ import { getAccountIdForRequest } from "@/src/services/loginService";
import { updateGeneric } from "@/src/services/inventoryService";
import { RequestHandler } from "express";
import { getJSONfromString } from "@/src/helpers/stringHelpers";
+import { IGenericUpdate } from "@/src/types/genericUpdate";
// eslint-disable-next-line @typescript-eslint/no-misused-promises
const genericUpdateController: RequestHandler = async (request, response) => {
const accountId = await getAccountIdForRequest(request);
- const update = getJSONfromString(request.body.toString());
+ const update = getJSONfromString(String(request.body)) as IGenericUpdate;
response.json(await updateGeneric(update, accountId));
};
diff --git a/src/controllers/api/infestedFoundryController.ts b/src/controllers/api/infestedFoundryController.ts
index 85c50921..ddf6925d 100644
--- a/src/controllers/api/infestedFoundryController.ts
+++ b/src/controllers/api/infestedFoundryController.ts
@@ -7,11 +7,10 @@ import { IOid } from "@/src/types/commonTypes";
// eslint-disable-next-line @typescript-eslint/no-misused-promises
export const infestedFoundryController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
- const payload = getJSONfromString(req.body.toString());
switch (req.query.mode) {
case "s": {
// shard installation
- const request = payload as IShardInstallRequest;
+ const request = getJSONfromString(String(req.body)) as IShardInstallRequest;
const inventory = await getInventory(accountId);
const suit = inventory.Suits.find(suit => suit._id.toString() == request.SuitId.$oid)!;
if (
@@ -42,9 +41,10 @@ export const infestedFoundryController: RequestHandler = async (req, res) => {
case "n": {
// name the beast
+ const request = getJSONfromString(String(req.body)) as IHelminthNameRequest;
const inventory = await getInventory(accountId);
inventory.InfestedFoundry ??= {};
- inventory.InfestedFoundry.Name = payload.newName as string;
+ inventory.InfestedFoundry.Name = request.newName;
await inventory.save();
res.json({
InventoryChanges: {
@@ -73,6 +73,10 @@ interface IShardInstallRequest {
Color: string;
}
+interface IHelminthNameRequest {
+ newName: string;
+}
+
const colorToShard: Record = {
ACC_RED: "/Lotus/Types/Gameplay/NarmerSorties/ArchonCrystalAmar",
ACC_RED_MYTHIC: "/Lotus/Types/Gameplay/NarmerSorties/ArchonCrystalAmarMythic",
diff --git a/src/controllers/api/joinSessionController.ts b/src/controllers/api/joinSessionController.ts
index 84837692..4212c90f 100644
--- a/src/controllers/api/joinSessionController.ts
+++ b/src/controllers/api/joinSessionController.ts
@@ -3,10 +3,10 @@ import { getSessionByID } from "@/src/managers/sessionManager";
import { logger } from "@/src/utils/logger";
const joinSessionController: RequestHandler = (_req, res) => {
- const reqBody = JSON.parse(_req.body);
+ const reqBody = JSON.parse(String(_req.body));
logger.debug(`JoinSession Request`, { reqBody });
- const req = JSON.parse(_req.body);
- const session = getSessionByID(req.sessionIds[0]);
+ const req = JSON.parse(String(_req.body));
+ const session = getSessionByID(req.sessionIds[0] as string);
res.json({ rewardSeed: session?.rewardSeed, sessionId: { $oid: session?.sessionId } });
};
diff --git a/src/controllers/api/modularWeaponCraftingController.ts b/src/controllers/api/modularWeaponCraftingController.ts
index 91768e3a..00a776d8 100644
--- a/src/controllers/api/modularWeaponCraftingController.ts
+++ b/src/controllers/api/modularWeaponCraftingController.ts
@@ -22,7 +22,7 @@ interface IModularCraftRequest {
// eslint-disable-next-line @typescript-eslint/no-misused-promises
export const modularWeaponCraftingController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
- const data: IModularCraftRequest = getJSONfromString(req.body.toString());
+ const data = getJSONfromString(String(req.body)) as IModularCraftRequest;
if (!(data.WeaponType in modularWeaponTypes)) {
throw new Error(`unknown modular weapon type: ${data.WeaponType}`);
}
diff --git a/src/controllers/api/nameWeaponController.ts b/src/controllers/api/nameWeaponController.ts
index c32f0fe8..26876766 100644
--- a/src/controllers/api/nameWeaponController.ts
+++ b/src/controllers/api/nameWeaponController.ts
@@ -12,7 +12,7 @@ interface INameWeaponRequest {
export const nameWeaponController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
const inventory = await getInventory(accountId);
- const body = getJSONfromString(req.body.toString()) as INameWeaponRequest;
+ const body = getJSONfromString(String(req.body)) as INameWeaponRequest;
const item = inventory[req.query.Category as string as TEquipmentKey].find(
item => item._id.toString() == (req.query.ItemId as string)
)!;
diff --git a/src/controllers/api/sellController.ts b/src/controllers/api/sellController.ts
index f242ccba..ff2ce6e0 100644
--- a/src/controllers/api/sellController.ts
+++ b/src/controllers/api/sellController.ts
@@ -5,7 +5,7 @@ import { getInventory, addMods, addRecipes } from "@/src/services/inventoryServi
// eslint-disable-next-line @typescript-eslint/no-misused-promises
export const sellController: RequestHandler = async (req, res) => {
- const payload: ISellRequest = JSON.parse(req.body.toString());
+ const payload = JSON.parse(String(req.body)) as ISellRequest;
const accountId = await getAccountIdForRequest(req);
const inventory = await getInventory(accountId);
diff --git a/src/controllers/api/setWeaponSkillTreeController.ts b/src/controllers/api/setWeaponSkillTreeController.ts
index b3b0be6f..dae03f03 100644
--- a/src/controllers/api/setWeaponSkillTreeController.ts
+++ b/src/controllers/api/setWeaponSkillTreeController.ts
@@ -8,7 +8,7 @@ import { WeaponTypeInternal } from "@/src/services/itemDataService";
export const setWeaponSkillTreeController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
const inventory = await getInventory(accountId);
- const payload = getJSONfromString(req.body.toString()) as ISetWeaponSkillTreeRequest;
+ const payload = getJSONfromString(String(req.body)) as ISetWeaponSkillTreeRequest;
const item = inventory[req.query.Category as WeaponTypeInternal].find(
item => item._id.toString() == (req.query.ItemId as string)
diff --git a/src/controllers/api/startDojoRecipeController.ts b/src/controllers/api/startDojoRecipeController.ts
index a278f31c..4ae4dd7d 100644
--- a/src/controllers/api/startDojoRecipeController.ts
+++ b/src/controllers/api/startDojoRecipeController.ts
@@ -12,7 +12,7 @@ interface IStartDojoRecipeRequest {
export const startDojoRecipeController: RequestHandler = async (req, res) => {
const guild = await getGuildForRequest(req);
// At this point, we know that a member of the guild is making this request. Assuming they are allowed to start a build.
- const request = JSON.parse(req.body.toString()) as IStartDojoRecipeRequest;
+ const request = JSON.parse(String(req.body)) as IStartDojoRecipeRequest;
guild.DojoComponents!.push({
_id: new Types.ObjectId(),
pf: request.PlacedComponent.pf,
diff --git a/src/controllers/api/startRecipeController.ts b/src/controllers/api/startRecipeController.ts
index 5f770476..0c516365 100644
--- a/src/controllers/api/startRecipeController.ts
+++ b/src/controllers/api/startRecipeController.ts
@@ -11,7 +11,7 @@ interface IStartRecipeRequest {
// eslint-disable-next-line @typescript-eslint/no-misused-promises
export const startRecipeController: RequestHandler = async (req, res) => {
- const startRecipeRequest = getJSONfromString(req.body.toString()) as IStartRecipeRequest;
+ const startRecipeRequest = getJSONfromString(String(req.body)) as IStartRecipeRequest;
logger.debug("StartRecipe Request", { startRecipeRequest });
const accountId = await getAccountIdForRequest(req);
diff --git a/src/controllers/api/stepSequencersController.ts b/src/controllers/api/stepSequencersController.ts
index bb963b92..06d72d5f 100644
--- a/src/controllers/api/stepSequencersController.ts
+++ b/src/controllers/api/stepSequencersController.ts
@@ -7,7 +7,7 @@ import { IStepSequencer } from "@/src/types/inventoryTypes/inventoryTypes";
export const stepSequencersController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
const inventory = await getInventory(accountId);
- const stepSequencer = JSON.parse(req.body.toString()) as IStepSequencer;
+ const stepSequencer = JSON.parse(String(req.body)) as IStepSequencer;
delete stepSequencer.ItemId;
const stepSequencerIndex = inventory.StepSequencers.push(stepSequencer);
const changedInventory = await inventory.save();
diff --git a/src/controllers/api/syndicateSacrificeController.ts b/src/controllers/api/syndicateSacrificeController.ts
index d67f68b5..9c7fff17 100644
--- a/src/controllers/api/syndicateSacrificeController.ts
+++ b/src/controllers/api/syndicateSacrificeController.ts
@@ -7,10 +7,9 @@ import { getAccountIdForRequest } from "@/src/services/loginService";
// eslint-disable-next-line @typescript-eslint/no-misused-promises
const syndicateSacrificeController: RequestHandler = async (request, response) => {
const accountId = await getAccountIdForRequest(request);
- const body = getJSONfromString(request.body);
+ const update = getJSONfromString(String(request.body)) as ISyndicateSacrifice;
let reply = {};
try {
- const update = JSON.parse(body) as ISyndicateSacrifice;
if (typeof update !== "object") {
throw new Error("Invalid data format");
}
diff --git a/src/controllers/api/trainingResultController.ts b/src/controllers/api/trainingResultController.ts
index fcfe6734..59ab9c4d 100644
--- a/src/controllers/api/trainingResultController.ts
+++ b/src/controllers/api/trainingResultController.ts
@@ -19,7 +19,7 @@ interface ITrainingResultsResponse {
const trainingResultController: RequestHandler = async (req, res): Promise => {
const accountId = await getAccountIdForRequest(req);
- const trainingResults = getJSONfromString(req.body.toString()) as ITrainingResultsRequest;
+ const trainingResults = getJSONfromString(String(req.body)) as ITrainingResultsRequest;
const inventory = await getInventory(accountId);
diff --git a/src/controllers/api/updateChallengeProgressController.ts b/src/controllers/api/updateChallengeProgressController.ts
index bc91f9d3..f6e496e8 100644
--- a/src/controllers/api/updateChallengeProgressController.ts
+++ b/src/controllers/api/updateChallengeProgressController.ts
@@ -6,7 +6,7 @@ import { IUpdateChallengeProgressRequest } from "@/src/types/requestTypes";
// eslint-disable-next-line @typescript-eslint/no-misused-promises
const updateChallengeProgressController: RequestHandler = async (req, res) => {
- const payload: IUpdateChallengeProgressRequest = getJSONfromString(req.body.toString());
+ const payload = getJSONfromString(String(req.body)) as IUpdateChallengeProgressRequest;
const accountId = await getAccountIdForRequest(req);
await updateChallengeProgress(payload, accountId);
diff --git a/src/controllers/api/updateSessionController.ts b/src/controllers/api/updateSessionController.ts
index e949d83e..b203a486 100644
--- a/src/controllers/api/updateSessionController.ts
+++ b/src/controllers/api/updateSessionController.ts
@@ -5,9 +5,9 @@ const updateSessionGetController: RequestHandler = (_req, res) => {
res.json({});
};
const updateSessionPostController: RequestHandler = (_req, res) => {
- console.log("UpdateSessions POST Request:", JSON.parse(_req.body));
+ console.log("UpdateSessions POST Request:", JSON.parse(String(_req.body)));
console.log("ReqID:", _req.query.sessionId as string);
- updateSession(_req.query.sessionId as string, _req.body);
+ updateSession(_req.query.sessionId as string, String(_req.body));
res.json({});
};
export { updateSessionGetController, updateSessionPostController };
diff --git a/src/controllers/api/upgradesController.ts b/src/controllers/api/upgradesController.ts
index e3a06d2d..8fdec7e7 100644
--- a/src/controllers/api/upgradesController.ts
+++ b/src/controllers/api/upgradesController.ts
@@ -12,7 +12,7 @@ import { addMiscItems, getInventory, updateCurrency } from "@/src/services/inven
// eslint-disable-next-line @typescript-eslint/no-misused-promises
export const upgradesController: RequestHandler = async (req, res) => {
const accountId = await getAccountIdForRequest(req);
- const payload = JSON.parse(req.body.toString()) as IUpgradesRequest;
+ const payload = JSON.parse(String(req.body)) as IUpgradesRequest;
const inventory = await getInventory(accountId);
const InventoryChanges: any = {};
for (const operation of payload.Operations) {
diff --git a/src/controllers/custom/updateConfigDataController.ts b/src/controllers/custom/updateConfigDataController.ts
index 8a23cd1b..6037cdce 100644
--- a/src/controllers/custom/updateConfigDataController.ts
+++ b/src/controllers/custom/updateConfigDataController.ts
@@ -3,7 +3,7 @@ import { updateConfig } from "@/src/services/configService";
// eslint-disable-next-line @typescript-eslint/no-misused-promises
const updateConfigDataController: RequestHandler = async (req, res) => {
- await updateConfig(req.body.toString());
+ await updateConfig(String(req.body));
res.end();
};