diff --git a/src/app.ts b/src/app.ts index 03fa5bd2..3ca8bfc8 100644 --- a/src/app.ts +++ b/src/app.ts @@ -14,7 +14,6 @@ import { customRouter } from "@/src/routes/custom"; import { dynamicController } from "@/src/routes/dynamic"; import { statsRouter } from "@/src/routes/stats"; import { connectDatabase } from "@/src/services/mongoService"; -import { LoadoutModel as Loadout } from "@/src/models/inventoryModels/loadoutModel"; void connectDatabase(); @@ -35,23 +34,6 @@ app.use("/:id/dynamic", dynamicController); app.post("/pay/steamPacks.php", steamPacksController); app.use("/stats", statsRouter); -// eslint-disable-next-line @typescript-eslint/no-misused-promises -app.post("/test", async (req, _res) => { - console.log("test hit", req.body); - const newLoadout = new Loadout({}); - newLoadout.NORMAL.push({ - _id: "000000000000000000000000", - Favorite: false, - PresetIcon: "", - s: { ItemId: { $oid: "000000000000000000000000" }, mod: 0, cus: 0 }, - p: { ItemId: { $oid: "000000000000000000000000" }, mod: 0, cus: 0 }, - l: { ItemId: { $oid: "000000000000000000000000" }, mod: 0, cus: 0 }, - m: { ItemId: { $oid: "000000000000000000000000" }, mod: 0, cus: 0 } - }); - await newLoadout.save(); - _res.end(); -}); - app.use(unknownEndpointHandler); //app.use(errorHandler) diff --git a/src/controllers/api/saveLoadout.ts b/src/controllers/api/saveLoadout.ts index 9a973699..cd04f541 100644 --- a/src/controllers/api/saveLoadout.ts +++ b/src/controllers/api/saveLoadout.ts @@ -16,8 +16,10 @@ const saveLoadoutController: RequestHandler = async (req, res) => { // eslint-disable-next-line @typescript-eslint/no-unused-vars const { UpgradeVer, ...equipmentChanges } = body; await handleInventoryItemConfigChange(equipmentChanges, accountId); - } catch (error) { - res.status(400).json({ error: error.message }); + } catch (error: unknown) { + if (error instanceof Error) { + res.status(400).json({ error: error.message }); + } } }; diff --git a/src/helpers/inventoryHelpers.ts b/src/helpers/inventoryHelpers.ts index 517fcfd4..92c1726f 100644 --- a/src/helpers/inventoryHelpers.ts +++ b/src/helpers/inventoryHelpers.ts @@ -2,7 +2,7 @@ import { IOid } from "@/src/types/commonTypes"; import { IInventoryDatabase, IInventoryResponse } from "@/src/types/inventoryTypes/inventoryTypes"; import { Types } from "mongoose"; -// a schema's toJSON is responsible for changing Oid and Date to their corresponding Response versions __id to "ItemId":{"$oid":"6450f720bc562ebf030222d4"}, and a Date to "date":{"$date":{"$numberLong":"unix timestamp"}) +//TODO: this needs to be addressed: a schema's toJSON is responsible for changing Oid and Date to their corresponding Response versions __id to "ItemId":{"$oid":"6450f720bc562ebf030222d4"}, and a Date to "date":{"$date":{"$numberLong":"unix timestamp"}) export const toInventoryResponse = (inventoryDatabase: IInventoryDatabase): IInventoryResponse => { // eslint-disable-next-line @typescript-eslint/no-unused-vars const { accountOwnerId, ...inventoryResponse } = inventoryDatabase;