From b171a28c687ed00195f0bde2bf513cdc55f7bec2 Mon Sep 17 00:00:00 2001 From: Sainan Date: Sun, 15 Dec 2024 21:48:53 +0100 Subject: [PATCH] Fix inventoryController Made the inventoryJSON type more opaque since mongoose chains a lot of stuff together for it so it's hard to give a proper type. --- src/controllers/api/inventoryController.ts | 4 ++-- src/helpers/inventoryHelpers.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/controllers/api/inventoryController.ts b/src/controllers/api/inventoryController.ts index 9272869a..5cb4acd6 100644 --- a/src/controllers/api/inventoryController.ts +++ b/src/controllers/api/inventoryController.ts @@ -6,7 +6,7 @@ import { config } from "@/src/services/configService"; import allDialogue from "@/static/fixed_responses/allDialogue.json"; import allMissions from "@/static/fixed_responses/allMissions.json"; import { ILoadoutDatabase } from "@/src/types/saveLoadoutTypes"; -import { IInventoryDatabase, IShipInventory, equipmentKeys } from "@/src/types/inventoryTypes/inventoryTypes"; +import { IShipInventory, equipmentKeys } from "@/src/types/inventoryTypes/inventoryTypes"; import { IPolarity, ArtifactPolarity } from "@/src/types/inventoryTypes/commonInventoryTypes"; import { ExportCustoms, ExportFlavour, ExportKeys, ExportResources } from "warframe-public-export-plus"; @@ -30,7 +30,7 @@ const inventoryController: RequestHandler = async (request, response) => { } //TODO: make a function that converts from database representation to client - const inventoryJSON: IInventoryDatabase = inventory.toJSON(); + const inventoryJSON = inventory.toJSON(); const inventoryResponse = toInventoryResponse(inventoryJSON); diff --git a/src/helpers/inventoryHelpers.ts b/src/helpers/inventoryHelpers.ts index 0955ed39..9c254fbe 100644 --- a/src/helpers/inventoryHelpers.ts +++ b/src/helpers/inventoryHelpers.ts @@ -1,9 +1,9 @@ import { IOid } from "@/src/types/commonTypes"; -import { IInventoryDatabase, IInventoryResponse } from "@/src/types/inventoryTypes/inventoryTypes"; +import { IInventoryResponse } from "@/src/types/inventoryTypes/inventoryTypes"; import { Types } from "mongoose"; //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 => { +export const toInventoryResponse = (inventoryDatabase: { accountOwnerId: Types.ObjectId }): IInventoryResponse => { // eslint-disable-next-line @typescript-eslint/no-unused-vars const { accountOwnerId, ...inventoryResponse } = inventoryDatabase; return inventoryResponse as unknown as IInventoryResponse;