saveLoadout and misc. #99
							
								
								
									
										18
									
								
								src/app.ts
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								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)
 | 
			
		||||
 | 
			
		||||
@ -16,9 +16,11 @@ 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) {
 | 
			
		||||
    } catch (error: unknown) {
 | 
			
		||||
        if (error instanceof Error) {
 | 
			
		||||
            res.status(400).json({ error: error.message });
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export { saveLoadoutController };
 | 
			
		||||
 | 
			
		||||
@ -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;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user