chore: fix misc eslint warnings
This commit is contained in:
parent
ad6c24de71
commit
0facf666fe
@ -10,7 +10,7 @@ const artifactsController: RequestHandler = async (req, res) => {
|
||||
|
||||
try {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call
|
||||
const artifactsData = getJSONfromString(req.body.toString()) as IArtifactsRequest;
|
||||
const artifactsData = getJSONfromString(String(req.body)) as IArtifactsRequest;
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
||||
const upgradeModId = await upgradeMod(artifactsData, accountId);
|
||||
res.send(upgradeModId);
|
||||
|
@ -39,8 +39,8 @@ export const claimCompletedRecipeController: RequestHandler = async (req, res) =
|
||||
|
||||
const recipe = getRecipe(pendingRecipe.ItemType);
|
||||
if (!recipe) {
|
||||
logger.error(`no completed item found for recipe ${pendingRecipe._id}`);
|
||||
throw new Error(`no completed item found for recipe ${pendingRecipe._id}`);
|
||||
logger.error(`no completed item found for recipe ${pendingRecipe._id?.toString()}`);
|
||||
throw new Error(`no completed item found for recipe ${pendingRecipe._id?.toString()}`);
|
||||
}
|
||||
|
||||
if (req.query.cancel) {
|
||||
|
@ -10,8 +10,8 @@ export const focusController: RequestHandler = async (req, res) => {
|
||||
const accountId = await getAccountIdForRequest(req);
|
||||
switch (req.query.op) {
|
||||
default:
|
||||
logger.error("Unhandled focus op type: " + req.query.op);
|
||||
logger.debug(req.body.toString());
|
||||
logger.error("Unhandled focus op type: " + String(req.query.op));
|
||||
logger.debug(String(req.body));
|
||||
res.end();
|
||||
break;
|
||||
case FocusOperation.InstallLens: {
|
||||
|
@ -22,7 +22,7 @@ const parseFusionTreasure = (name: string, count: number): IFusionTreasure => {
|
||||
export const fusionTreasuresController: RequestHandler = async (req, res) => {
|
||||
const accountId = await getAccountIdForRequest(req);
|
||||
const inventory = await getInventory(accountId);
|
||||
const request = JSON.parse(req.body.toString() as string) as IFusionTreasureRequest;
|
||||
const request = JSON.parse(String(req.body)) as IFusionTreasureRequest;
|
||||
|
||||
const oldTreasure = parseFusionTreasure(request.oldTreasureName, -1);
|
||||
const newTreasure = parseFusionTreasure(request.newTreasureName, 1);
|
||||
|
@ -133,6 +133,6 @@ export const getVendorInfoController: RequestHandler = (req, res) => {
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Error(`Unknown vendor: ${req.query.vendor}`);
|
||||
throw new Error(`Unknown vendor: ${String(req.query.vendor)}`);
|
||||
}
|
||||
};
|
||||
|
@ -27,20 +27,20 @@ interface IGildWeaponRequest {
|
||||
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
||||
export const gildWeaponController: RequestHandler = async (req, res) => {
|
||||
const accountId = await getAccountIdForRequest(req);
|
||||
const data: IGildWeaponRequest = getJSONfromString(String(req.body));
|
||||
const data = getJSONfromString(String(req.body)) as IGildWeaponRequest;
|
||||
data.ItemId = String(req.query.ItemId);
|
||||
if (!modularWeaponCategory.includes(req.query.Category as WeaponTypeInternal | "Hoverboards")) {
|
||||
throw new Error(`Unknown modular weapon Category: ${req.query.Category}`);
|
||||
throw new Error(`Unknown modular weapon Category: ${String(req.query.Category)}`);
|
||||
}
|
||||
data.Category = req.query.Category as WeaponTypeInternal | "Hoverboards";
|
||||
|
||||
const inventory = await getInventory(accountId);
|
||||
if (!inventory[data.Category]) {
|
||||
throw new Error(`Category ${req.query.Category} not found in inventory`);
|
||||
throw new Error(`Category ${String(req.query.Category)} not found in inventory`);
|
||||
}
|
||||
const weaponIndex = inventory[data.Category].findIndex(x => String(x._id) === data.ItemId);
|
||||
if (weaponIndex === -1) {
|
||||
throw new Error(`Weapon with ${data.ItemId} not found in category ${req.query.Category}`);
|
||||
throw new Error(`Weapon with ${data.ItemId} not found in category ${String(req.query.Category)}`);
|
||||
}
|
||||
|
||||
const weapon = inventory[data.Category][weaponIndex];
|
||||
|
@ -59,7 +59,7 @@ export const infestedFoundryController: RequestHandler = async (req, res) => {
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Error(`unhandled infestedFoundry mode: ${req.query.mode}`);
|
||||
throw new Error(`unhandled infestedFoundry mode: ${String(req.query.mode)}`);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -51,7 +51,7 @@ const missionInventoryUpdateController: RequestHandler = async (req, res): Promi
|
||||
|
||||
try {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call
|
||||
const lootInventory = getJSONfromString(req.body.toString()) as IMissionInventoryUpdateRequest;
|
||||
const lootInventory = getJSONfromString(String(req.body)) as IMissionInventoryUpdateRequest;
|
||||
|
||||
logger.debug("missionInventoryUpdate with lootInventory =", lootInventory);
|
||||
|
||||
|
@ -4,6 +4,7 @@ import { getInventory } from "@/src/services/inventoryService";
|
||||
import { IMongoDate } from "@/src/types/commonTypes";
|
||||
import { RequestHandler } from "express";
|
||||
import { unixTimesInMs } from "@/src/constants/timeConstants";
|
||||
import { IInventoryChanges } from "@/src/types/purchaseTypes";
|
||||
|
||||
interface ITrainingResultsRequest {
|
||||
numLevelsGained: number;
|
||||
@ -12,7 +13,7 @@ interface ITrainingResultsRequest {
|
||||
interface ITrainingResultsResponse {
|
||||
NewTrainingDate: IMongoDate;
|
||||
NewLevel: number;
|
||||
InventoryChanges: any[];
|
||||
InventoryChanges: IInventoryChanges;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
||||
@ -36,7 +37,7 @@ const trainingResultController: RequestHandler = async (req, res): Promise<void>
|
||||
$date: { $numberLong: changedinventory.TrainingDate.getTime().toString() }
|
||||
},
|
||||
NewLevel: trainingResults.numLevelsGained == 1 ? changedinventory.PlayerLevel : inventory.PlayerLevel,
|
||||
InventoryChanges: []
|
||||
InventoryChanges: {}
|
||||
} satisfies ITrainingResultsResponse);
|
||||
};
|
||||
|
||||
|
@ -10,15 +10,17 @@ const addItemController: RequestHandler = async (req, res) => {
|
||||
const request = toAddItemRequest(req.body);
|
||||
|
||||
switch (request.type) {
|
||||
case ItemType.Powersuit:
|
||||
case ItemType.Powersuit: {
|
||||
const powersuit = await addPowerSuit(request.InternalName, accountId);
|
||||
res.json(powersuit);
|
||||
return;
|
||||
case ItemType.Weapon:
|
||||
}
|
||||
case ItemType.Weapon: {
|
||||
const weaponType = getWeaponType(request.InternalName);
|
||||
const weapon = await addEquipment(weaponType, request.InternalName, accountId);
|
||||
res.json(weapon);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
res.status(400).json({ error: "something went wrong" });
|
||||
break;
|
||||
|
@ -6,7 +6,7 @@ import { logger } from "@/src/utils/logger";
|
||||
const rootDir = path.join(__dirname, "../..");
|
||||
const repoDir = path.basename(rootDir) == "build" ? path.join(rootDir, "..") : rootDir;
|
||||
const configPath = path.join(repoDir, "config.json");
|
||||
export const config: IConfig = JSON.parse(fs.readFileSync(configPath, "utf-8"));
|
||||
export const config = JSON.parse(fs.readFileSync(configPath, "utf-8")) as IConfig;
|
||||
|
||||
let amnesia = false;
|
||||
fs.watchFile(configPath, () => {
|
||||
|
@ -218,7 +218,7 @@ export const addItem = async (
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "Weapons":
|
||||
case "Weapons": {
|
||||
const weaponType = getWeaponType(typeName);
|
||||
const weapon = await addEquipment(weaponType, typeName, accountId);
|
||||
await updateSlots(accountId, InventorySlot.WEAPONS, 0, 1);
|
||||
@ -228,6 +228,7 @@ export const addItem = async (
|
||||
[weaponType]: [weapon]
|
||||
}
|
||||
};
|
||||
}
|
||||
case "Upgrades": {
|
||||
const inventory = await getInventory(accountId);
|
||||
const changes = [
|
||||
@ -263,7 +264,7 @@ export const addItem = async (
|
||||
}
|
||||
case "Types":
|
||||
switch (typeName.substr(1).split("/")[2]) {
|
||||
case "Sentinels":
|
||||
case "Sentinels": {
|
||||
// TOOD: Sentinels should also grant their DefaultUpgrades & SentinelWeapon.
|
||||
const sentinel = await addSentinel(typeName, accountId);
|
||||
await updateSlots(accountId, InventorySlot.SENTINELS, 0, 1);
|
||||
@ -273,6 +274,7 @@ export const addItem = async (
|
||||
Sentinels: [sentinel]
|
||||
}
|
||||
};
|
||||
}
|
||||
case "Items": {
|
||||
switch (typeName.substr(1).split("/")[3]) {
|
||||
case "ShipDecos": {
|
||||
@ -328,7 +330,8 @@ export const addItem = async (
|
||||
};
|
||||
}
|
||||
break;
|
||||
case "Restoratives": // Codex Scanner, Remote Observer, Starburst
|
||||
case "Restoratives": {
|
||||
// Codex Scanner, Remote Observer, Starburst
|
||||
const inventory = await getInventory(accountId);
|
||||
const consumablesChanges = [
|
||||
{
|
||||
@ -343,6 +346,7 @@ export const addItem = async (
|
||||
Consumables: consumablesChanges
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -23,8 +23,8 @@ export const getShip = async (shipId: Types.ObjectId, fieldSelection: string = "
|
||||
const ship = await Ship.findOne({ _id: shipId }, fieldSelection);
|
||||
|
||||
if (!ship) {
|
||||
logger.error(`error finding a ship for account ${shipId}`);
|
||||
throw new Error(`error finding a ship for account ${shipId}`);
|
||||
logger.error(`error finding a ship for account ${String(shipId)}`);
|
||||
throw new Error(`error finding a ship for account ${String(shipId)}`);
|
||||
}
|
||||
|
||||
return ship;
|
||||
|
Loading…
x
Reference in New Issue
Block a user