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.
This commit is contained in:
parent
0a40d2612b
commit
b171a28c68
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user