mongoose is great
This commit is contained in:
parent
8df3030953
commit
0a6a76c8f5
110
package-lock.json
generated
110
package-lock.json
generated
@ -11,7 +11,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"dotenv": "^16.1.3",
|
"dotenv": "^16.1.3",
|
||||||
"express": "^5.0.0-beta.1",
|
"express": "^5.0.0-beta.1",
|
||||||
"mongoose": "^7.4.1",
|
"mongoose": "^8.0.2",
|
||||||
"warframe-items": "1.1260.121"
|
"warframe-items": "1.1260.121"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@ -214,6 +214,14 @@
|
|||||||
"@jridgewell/sourcemap-codec": "^1.4.10"
|
"@jridgewell/sourcemap-codec": "^1.4.10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@mongodb-js/saslprep": {
|
||||||
|
"version": "1.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.1.1.tgz",
|
||||||
|
"integrity": "sha512-t7c5K033joZZMspnHg/gWPE4kandgc2OxE74aYOtGKfgB9VPuVJPix0H6fhmm2erj5PBJ21mqcx34lpIGtUCsQ==",
|
||||||
|
"dependencies": {
|
||||||
|
"sparse-bitfield": "^3.0.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@nodelib/fs.scandir": {
|
"node_modules/@nodelib/fs.scandir": {
|
||||||
"version": "2.1.5",
|
"version": "2.1.5",
|
||||||
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
|
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
|
||||||
@ -419,9 +427,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/@types/webidl-conversions": {
|
"node_modules/@types/webidl-conversions": {
|
||||||
"version": "7.0.0",
|
"version": "7.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/@types/webidl-conversions/-/webidl-conversions-7.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/@types/webidl-conversions/-/webidl-conversions-7.0.3.tgz",
|
||||||
"integrity": "sha512-xTE1E+YF4aWPJJeUzaZI5DRntlkY3+BCVJi0axFptnjGmAoWxkyREIh/XMrfxVLejwQxMCfDXdICo0VLxThrog=="
|
"integrity": "sha512-CiJJvcRtIgzadHCYXw7dqEnMNRjhGZlYK05Mj9OyktqV8uVT8fD2BFOB7S1uwBE3Kj2Z+4UyPmFw/Ixgw/LAlA=="
|
||||||
},
|
},
|
||||||
"node_modules/@types/whatwg-url": {
|
"node_modules/@types/whatwg-url": {
|
||||||
"version": "8.2.2",
|
"version": "8.2.2",
|
||||||
@ -1140,11 +1148,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/bson": {
|
"node_modules/bson": {
|
||||||
"version": "5.4.0",
|
"version": "6.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/bson/-/bson-5.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/bson/-/bson-6.2.0.tgz",
|
||||||
"integrity": "sha512-WRZ5SQI5GfUuKnPTNmAYPiKIof3ORXAF4IRU5UcgmivNIon01rWQlw5RUH954dpu8yGL8T59YShVddIPaU/gFA==",
|
"integrity": "sha512-ID1cI+7bazPDyL9wYy9GaQ8gEEohWvcUl/Yf0dIdutJxnmInEEyCsb4awy/OiBfall7zBA179Pahi3vCdFze3Q==",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=14.20.1"
|
"node": ">=16.20.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/buffer-from": {
|
"node_modules/buffer-from": {
|
||||||
@ -2136,11 +2144,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
|
||||||
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
|
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
|
||||||
},
|
},
|
||||||
"node_modules/ip": {
|
|
||||||
"version": "2.0.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/ip/-/ip-2.0.0.tgz",
|
|
||||||
"integrity": "sha512-WKa+XuLG1A1R0UWhl2+1XQSi+fZWMsYKffMZTTYsiZaUD8k2yDAj5atimTUD2TZkyCkNEeYE5NhFZmupOGtjYQ=="
|
|
||||||
},
|
|
||||||
"node_modules/ipaddr.js": {
|
"node_modules/ipaddr.js": {
|
||||||
"version": "1.9.1",
|
"version": "1.9.1",
|
||||||
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
|
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
|
||||||
@ -2397,8 +2400,7 @@
|
|||||||
"node_modules/memory-pager": {
|
"node_modules/memory-pager": {
|
||||||
"version": "1.5.0",
|
"version": "1.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/memory-pager/-/memory-pager-1.5.0.tgz",
|
"resolved": "https://registry.npmjs.org/memory-pager/-/memory-pager-1.5.0.tgz",
|
||||||
"integrity": "sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg==",
|
"integrity": "sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg=="
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"node_modules/merge-descriptors": {
|
"node_modules/merge-descriptors": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
@ -2506,26 +2508,25 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/mongodb": {
|
"node_modules/mongodb": {
|
||||||
"version": "5.7.0",
|
"version": "6.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-5.7.0.tgz",
|
"resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.2.0.tgz",
|
||||||
"integrity": "sha512-zm82Bq33QbqtxDf58fLWBwTjARK3NSvKYjyz997KSy6hpat0prjeX/kxjbPVyZY60XYPDNETaHkHJI2UCzSLuw==",
|
"integrity": "sha512-d7OSuGjGWDZ5usZPqfvb36laQ9CPhnWkAGHT61x5P95p/8nMVeH8asloMwW6GcYFeB0Vj4CB/1wOTDG2RA9BFA==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bson": "^5.4.0",
|
"@mongodb-js/saslprep": "^1.1.0",
|
||||||
"mongodb-connection-string-url": "^2.6.0",
|
"bson": "^6.2.0",
|
||||||
"socks": "^2.7.1"
|
"mongodb-connection-string-url": "^2.6.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=14.20.1"
|
"node": ">=16.20.1"
|
||||||
},
|
|
||||||
"optionalDependencies": {
|
|
||||||
"saslprep": "^1.0.3"
|
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@aws-sdk/credential-providers": "^3.201.0",
|
"@aws-sdk/credential-providers": "^3.188.0",
|
||||||
"@mongodb-js/zstd": "^1.1.0",
|
"@mongodb-js/zstd": "^1.1.0",
|
||||||
|
"gcp-metadata": "^5.2.0",
|
||||||
"kerberos": "^2.0.1",
|
"kerberos": "^2.0.1",
|
||||||
"mongodb-client-encryption": ">=2.3.0 <3",
|
"mongodb-client-encryption": ">=6.0.0 <7",
|
||||||
"snappy": "^7.2.2"
|
"snappy": "^7.2.2",
|
||||||
|
"socks": "^2.7.1"
|
||||||
},
|
},
|
||||||
"peerDependenciesMeta": {
|
"peerDependenciesMeta": {
|
||||||
"@aws-sdk/credential-providers": {
|
"@aws-sdk/credential-providers": {
|
||||||
@ -2534,6 +2535,9 @@
|
|||||||
"@mongodb-js/zstd": {
|
"@mongodb-js/zstd": {
|
||||||
"optional": true
|
"optional": true
|
||||||
},
|
},
|
||||||
|
"gcp-metadata": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
"kerberos": {
|
"kerberos": {
|
||||||
"optional": true
|
"optional": true
|
||||||
},
|
},
|
||||||
@ -2542,6 +2546,9 @@
|
|||||||
},
|
},
|
||||||
"snappy": {
|
"snappy": {
|
||||||
"optional": true
|
"optional": true
|
||||||
|
},
|
||||||
|
"socks": {
|
||||||
|
"optional": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -2555,20 +2562,20 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/mongoose": {
|
"node_modules/mongoose": {
|
||||||
"version": "7.4.1",
|
"version": "8.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/mongoose/-/mongoose-7.4.1.tgz",
|
"resolved": "https://registry.npmjs.org/mongoose/-/mongoose-8.0.2.tgz",
|
||||||
"integrity": "sha512-o3E5KHHiHdaiwCJG3+9r70sncRKki71Ktf/TfXdW6myu+53rtZ56uLl5ylkQiCf60V3COJuOeekcxXVsjQ7cBA==",
|
"integrity": "sha512-Vsi9GzTXjdBVzheT1HZOZ2jHNzzR9Xwb5OyLz/FvDEAhlwrRnXnuqJf0QHINUOQSm7aoyvnPks0q85HJkd6yDw==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bson": "^5.4.0",
|
"bson": "^6.2.0",
|
||||||
"kareem": "2.5.1",
|
"kareem": "2.5.1",
|
||||||
"mongodb": "5.7.0",
|
"mongodb": "6.2.0",
|
||||||
"mpath": "0.9.0",
|
"mpath": "0.9.0",
|
||||||
"mquery": "5.0.0",
|
"mquery": "5.0.0",
|
||||||
"ms": "2.1.3",
|
"ms": "2.1.3",
|
||||||
"sift": "16.0.1"
|
"sift": "16.0.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=14.20.1"
|
"node": ">=16.20.1"
|
||||||
},
|
},
|
||||||
"funding": {
|
"funding": {
|
||||||
"type": "opencollective",
|
"type": "opencollective",
|
||||||
@ -3223,18 +3230,6 @@
|
|||||||
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
||||||
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
|
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
|
||||||
},
|
},
|
||||||
"node_modules/saslprep": {
|
|
||||||
"version": "1.0.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/saslprep/-/saslprep-1.0.3.tgz",
|
|
||||||
"integrity": "sha512-/MY/PEMbk2SuY5sScONwhUDsV2p77Znkb/q3nSVstq/yQzYJOH/Azh29p9oJLsl3LnQwSvZDKagDGBsBwSooag==",
|
|
||||||
"optional": true,
|
|
||||||
"dependencies": {
|
|
||||||
"sparse-bitfield": "^3.0.3"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=6"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/semver": {
|
"node_modules/semver": {
|
||||||
"version": "7.5.4",
|
"version": "7.5.4",
|
||||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz",
|
"resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz",
|
||||||
@ -3350,28 +3345,6 @@
|
|||||||
"node": ">=8"
|
"node": ">=8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/smart-buffer": {
|
|
||||||
"version": "4.2.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz",
|
|
||||||
"integrity": "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==",
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 6.0.0",
|
|
||||||
"npm": ">= 3.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/socks": {
|
|
||||||
"version": "2.7.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/socks/-/socks-2.7.1.tgz",
|
|
||||||
"integrity": "sha512-7maUZy1N7uo6+WVEX6psASxtNlKaNVMlGQKkG/63nEDdLOWNbiUMoLK7X4uYoLhQstau72mLgfEWcXcwsaHbYQ==",
|
|
||||||
"dependencies": {
|
|
||||||
"ip": "^2.0.0",
|
|
||||||
"smart-buffer": "^4.2.0"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10.13.0",
|
|
||||||
"npm": ">= 3.0.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/source-map": {
|
"node_modules/source-map": {
|
||||||
"version": "0.6.1",
|
"version": "0.6.1",
|
||||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||||
@ -3395,7 +3368,6 @@
|
|||||||
"version": "3.0.3",
|
"version": "3.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz",
|
||||||
"integrity": "sha512-kvzhi7vqKTfkh0PZU+2D2PIllw2ymqJKujUcyPMd9Y75Nv4nPbGJZXNhxsgdQab2BmlDct1YnfQCguEvHr7VsQ==",
|
"integrity": "sha512-kvzhi7vqKTfkh0PZU+2D2PIllw2ymqJKujUcyPMd9Y75Nv4nPbGJZXNhxsgdQab2BmlDct1YnfQCguEvHr7VsQ==",
|
||||||
"optional": true,
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"memory-pager": "^1.0.2"
|
"memory-pager": "^1.0.2"
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"dotenv": "^16.1.3",
|
"dotenv": "^16.1.3",
|
||||||
"express": "^5.0.0-beta.1",
|
"express": "^5.0.0-beta.1",
|
||||||
"mongoose": "^7.4.1",
|
"mongoose": "^8.0.2",
|
||||||
"warframe-items": "1.1260.121"
|
"warframe-items": "1.1260.121"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
@ -14,6 +14,7 @@ import { customRouter } from "@/src/routes/custom";
|
|||||||
import { dynamicController } from "@/src/routes/dynamic";
|
import { dynamicController } from "@/src/routes/dynamic";
|
||||||
import { statsRouter } from "@/src/routes/stats";
|
import { statsRouter } from "@/src/routes/stats";
|
||||||
import { connectDatabase } from "@/src/services/mongoService";
|
import { connectDatabase } from "@/src/services/mongoService";
|
||||||
|
import { LoadoutModel as Loadout } from "@/src/models/inventoryModels/loadoutModel";
|
||||||
|
|
||||||
void connectDatabase();
|
void connectDatabase();
|
||||||
|
|
||||||
@ -34,6 +35,14 @@ app.use("/:id/dynamic", dynamicController);
|
|||||||
app.post("/pay/steamPacks.php", steamPacksController);
|
app.post("/pay/steamPacks.php", steamPacksController);
|
||||||
app.use("/stats", statsRouter);
|
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({});
|
||||||
|
await newLoadout.save();
|
||||||
|
_res.end();
|
||||||
|
});
|
||||||
|
|
||||||
app.use(unknownEndpointHandler);
|
app.use(unknownEndpointHandler);
|
||||||
|
|
||||||
//app.use(errorHandler)
|
//app.use(errorHandler)
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-misused-promises */
|
/* eslint-disable @typescript-eslint/no-misused-promises */
|
||||||
import { toInventoryResponse } from "@/src/helpers/inventoryHelpers";
|
import { toInventoryResponse } from "@/src/helpers/inventoryHelpers";
|
||||||
import { Inventory } from "@/src/models/inventoryModel";
|
import { Inventory } from "@/src/models/inventoryModels/inventoryModel";
|
||||||
import { Request, RequestHandler, Response } from "express";
|
import { Request, RequestHandler, Response } from "express";
|
||||||
import config from "@/config.json";
|
import config from "@/config.json";
|
||||||
import testMissions from "@/static/fixed_responses/testMissions.json";
|
import testMissions from "@/static/fixed_responses/testMissions.json";
|
||||||
import testQuestKeys from "@/static/fixed_responses/testQuestKeys.json";
|
import testQuestKeys from "@/static/fixed_responses/testQuestKeys.json";
|
||||||
|
import { ILoadoutDatabase } from "@/src/types/saveLoadoutTypes";
|
||||||
|
|
||||||
const inventoryController: RequestHandler = async (request: Request, response: Response) => {
|
const inventoryController: RequestHandler = async (request: Request, response: Response) => {
|
||||||
const accountId = request.query.accountId;
|
const accountId = request.query.accountId;
|
||||||
@ -14,7 +15,9 @@ const inventoryController: RequestHandler = async (request: Request, response: R
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const inventory = await Inventory.findOne({ accountOwnerId: accountId });
|
const inventory = await Inventory.findOne({ accountOwnerId: accountId }).populate<{
|
||||||
|
LoadOutPresets: ILoadoutDatabase;
|
||||||
|
}>("LoadOutPresets");
|
||||||
|
|
||||||
if (!inventory) {
|
if (!inventory) {
|
||||||
response.status(400).json({ error: "inventory was undefined" });
|
response.status(400).json({ error: "inventory was undefined" });
|
||||||
|
@ -1,26 +1,25 @@
|
|||||||
import { Inventory } from "@/src/models/inventoryModel";
|
import { Inventory } from "@/src/models/inventoryModels/inventoryModel";
|
||||||
import { RequestHandler } from "express";
|
import { RequestHandler } from "express";
|
||||||
import util from "util";
|
import util from "util";
|
||||||
import {
|
import {
|
||||||
EquipmentCategories,
|
EquipmentCategories,
|
||||||
IConfigEntry,
|
IConfigEntry,
|
||||||
ILoadout,
|
ILoadout,
|
||||||
|
ILoadoutKey,
|
||||||
ISaveLoadoutRequest,
|
ISaveLoadoutRequest,
|
||||||
ISaveLoadoutRequestNoUpgradeVer
|
ISaveLoadoutRequestNoUpgradeVer
|
||||||
} from "@/src/types/saveLoadoutTypes";
|
} from "@/src/types/saveLoadoutTypes";
|
||||||
|
|
||||||
export const isObjectEmpty = (obj: Record<string, unknown>) => {
|
export const isEmptyObject = (obj: unknown): boolean => {
|
||||||
return obj && Object.keys(obj).length === 0 && obj.constructor === Object;
|
return Boolean(obj && Object.keys(obj).length === 0 && obj.constructor === Object);
|
||||||
};
|
};
|
||||||
|
|
||||||
type EquipmentChangeEntry = IConfigEntry | ILoadout;
|
|
||||||
|
|
||||||
export const handleInventoryItemConfigChange = (equipmentChanges: ISaveLoadoutRequestNoUpgradeVer) => {
|
export const handleInventoryItemConfigChange = (equipmentChanges: ISaveLoadoutRequestNoUpgradeVer) => {
|
||||||
for (const [_equipmentName, _equipment] of Object.entries(equipmentChanges)) {
|
for (const [_equipmentName, _equipment] of Object.entries(equipmentChanges)) {
|
||||||
const equipment = _equipment as ISaveLoadoutRequestNoUpgradeVer[keyof ISaveLoadoutRequestNoUpgradeVer];
|
const equipment = _equipment as ISaveLoadoutRequestNoUpgradeVer[keyof ISaveLoadoutRequestNoUpgradeVer];
|
||||||
const equipmentName = _equipmentName as keyof ISaveLoadoutRequestNoUpgradeVer;
|
const equipmentName = _equipmentName as keyof ISaveLoadoutRequestNoUpgradeVer;
|
||||||
|
|
||||||
if (isObjectEmpty(equipment)) {
|
if (isEmptyObject(equipment)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// non-empty is a change in loadout(or suit...)
|
// non-empty is a change in loadout(or suit...)
|
||||||
@ -28,16 +27,20 @@ export const handleInventoryItemConfigChange = (equipmentChanges: ISaveLoadoutRe
|
|||||||
switch (equipmentName) {
|
switch (equipmentName) {
|
||||||
case "LoadOuts": {
|
case "LoadOuts": {
|
||||||
console.log("loadout received");
|
console.log("loadout received");
|
||||||
const _loadout = equipment as unknown as ILoadout;
|
|
||||||
|
|
||||||
for (const [loadoutName, loadout] of Object.entries(_loadout)) {
|
for (const [_loadoutName, _loadout] of Object.entries(equipment)) {
|
||||||
console.log(loadoutName, loadout);
|
const loadout = _loadout as ILoadoutKey;
|
||||||
//const loadout = _loadout as ILoadoutEntry;
|
const loadoutName = _loadoutName as keyof ILoadout;
|
||||||
|
|
||||||
// console.log(loadoutName, loadout);
|
console.log(_loadoutName, loadout);
|
||||||
// if (isObjectEmpty(loadout)) {
|
|
||||||
// continue;
|
if (isEmptyObject(loadout)) {
|
||||||
// }
|
continue;
|
||||||
|
}
|
||||||
|
// all non-empty entries are one loadout slot
|
||||||
|
for (const [_loadoutId, _loadoutConfig] of Object.entries(loadout)) {
|
||||||
|
console.log(loadout[_loadoutId].s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { parseString } from "@/src/helpers/general";
|
import { parseString } from "@/src/helpers/general";
|
||||||
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
import { getJSONfromString } from "@/src/helpers/stringHelpers";
|
||||||
import { Inventory } from "@/src/models/inventoryModel";
|
import { Inventory } from "@/src/models/inventoryModels/inventoryModel";
|
||||||
import { getInventory } from "@/src/services/inventoryService";
|
import { getInventory } from "@/src/services/inventoryService";
|
||||||
import { IMongoDate } from "@/src/types/commonTypes";
|
import { IMongoDate } from "@/src/types/commonTypes";
|
||||||
import { RequestHandler } from "express";
|
import { RequestHandler } from "express";
|
||||||
|
@ -8,8 +8,8 @@ import {
|
|||||||
IInventoryResponse,
|
IInventoryResponse,
|
||||||
IInventoryDatabaseDocument,
|
IInventoryDatabaseDocument,
|
||||||
IInventoryResponseDocument
|
IInventoryResponseDocument
|
||||||
} from "../types/inventoryTypes/inventoryTypes";
|
} from "../../types/inventoryTypes/inventoryTypes";
|
||||||
import { IMongoDate, IOid } from "../types/commonTypes";
|
import { IMongoDate, IOid } from "../../types/commonTypes";
|
||||||
import { ISuitDatabase, ISuitDocument } from "@/src/types/inventoryTypes/SuitTypes";
|
import { ISuitDatabase, ISuitDocument } from "@/src/types/inventoryTypes/SuitTypes";
|
||||||
import { IWeaponDatabase } from "@/src/types/inventoryTypes/weaponTypes";
|
import { IWeaponDatabase } from "@/src/types/inventoryTypes/weaponTypes";
|
||||||
|
|
||||||
@ -191,7 +191,7 @@ FlavourItemSchema.set("toJSON", {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const inventorySchema = new Schema<IInventoryDatabaseDocument, InventoryDocumentProps>({
|
const inventorySchema = new Schema<IInventoryDatabase, InventoryDocumentProps>({
|
||||||
accountOwnerId: Schema.Types.ObjectId,
|
accountOwnerId: Schema.Types.ObjectId,
|
||||||
SubscribedToEmails: Number,
|
SubscribedToEmails: Number,
|
||||||
Created: Schema.Types.Mixed,
|
Created: Schema.Types.Mixed,
|
||||||
@ -229,7 +229,7 @@ const inventorySchema = new Schema<IInventoryDatabaseDocument, InventoryDocument
|
|||||||
FlavourItems: [FlavourItemSchema],
|
FlavourItems: [FlavourItemSchema],
|
||||||
Scoops: [Schema.Types.Mixed],
|
Scoops: [Schema.Types.Mixed],
|
||||||
TrainingRetriesLeft: Number,
|
TrainingRetriesLeft: Number,
|
||||||
LoadOutPresets: Schema.Types.Mixed,
|
LoadOutPresets: { type: Schema.Types.ObjectId, ref: "Loadout" },
|
||||||
CurrentLoadOutIds: [Schema.Types.Mixed],
|
CurrentLoadOutIds: [Schema.Types.Mixed],
|
||||||
Missions: [Schema.Types.Mixed],
|
Missions: [Schema.Types.Mixed],
|
||||||
RandomUpgradesIdentified: Number,
|
RandomUpgradesIdentified: Number,
|
105
src/models/inventoryModels/loadoutModel.ts
Normal file
105
src/models/inventoryModels/loadoutModel.ts
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
import { IOid } from "@/src/types/commonTypes";
|
||||||
|
import { ILoadout, ILoadoutConfig, ILoadoutConfigDocument, ILoadoutDatabase, M } from "@/src/types/saveLoadoutTypes";
|
||||||
|
import { Model, Schema, Types, model } from "mongoose";
|
||||||
|
|
||||||
|
//create a schema for the $oid type
|
||||||
|
const oidSchema = new Schema<IOid>({
|
||||||
|
$oid: String
|
||||||
|
});
|
||||||
|
|
||||||
|
//create a mongoose schema based on interface M
|
||||||
|
const modSchema = new Schema<M>({
|
||||||
|
ItemId: {
|
||||||
|
type: oidSchema,
|
||||||
|
default: { $oid: "000000000000000000000000" }
|
||||||
|
},
|
||||||
|
mod: Number,
|
||||||
|
cus: Number
|
||||||
|
});
|
||||||
|
|
||||||
|
//default initialization for
|
||||||
|
const loadoutConfigSchema = new Schema<ILoadoutConfig>(
|
||||||
|
{
|
||||||
|
PresetIcon: String,
|
||||||
|
Favorite: Boolean,
|
||||||
|
s: {},
|
||||||
|
p: {},
|
||||||
|
l: {},
|
||||||
|
m: {}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
virtuals: {
|
||||||
|
ItemId: {
|
||||||
|
get() {
|
||||||
|
return this._id.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
interface User {
|
||||||
|
firstName: string;
|
||||||
|
lastName: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const UserSchema = new Schema(
|
||||||
|
{
|
||||||
|
firstName: String,
|
||||||
|
lastName: String
|
||||||
|
},
|
||||||
|
{
|
||||||
|
virtuals: {
|
||||||
|
fullname: {
|
||||||
|
get() {
|
||||||
|
return `${this.firstName} ${this.lastName}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// loadoutConfigSchema.virtual("ItemId").get(function (): string {
|
||||||
|
// return this._id
|
||||||
|
// });
|
||||||
|
|
||||||
|
loadoutConfigSchema.set("toJSON", {
|
||||||
|
virtuals: true,
|
||||||
|
transform(_doc, ret, _options) {
|
||||||
|
delete ret._id;
|
||||||
|
delete ret.__v;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const loadoutSchema = new Schema<ILoadoutDatabase, loadoutModelType>({
|
||||||
|
NORMAL: [loadoutConfigSchema],
|
||||||
|
SENTINEL: [loadoutConfigSchema],
|
||||||
|
ARCHWING: [loadoutConfigSchema],
|
||||||
|
NORMAL_PVP: [loadoutConfigSchema],
|
||||||
|
LUNARO: [loadoutConfigSchema],
|
||||||
|
OPERATOR: [loadoutConfigSchema],
|
||||||
|
KDRIVE: [loadoutConfigSchema],
|
||||||
|
DATAKNIFE: [loadoutConfigSchema],
|
||||||
|
MECH: [loadoutConfigSchema],
|
||||||
|
OPERATOR_ADULT: [loadoutConfigSchema],
|
||||||
|
DRIFTER: [loadoutConfigSchema]
|
||||||
|
});
|
||||||
|
|
||||||
|
//create database typefor ILoadoutConfig
|
||||||
|
type loadoutDocumentProps = {
|
||||||
|
NORMAL: Types.DocumentArray<ILoadoutConfig>;
|
||||||
|
SENTINEL: Types.DocumentArray<ILoadoutConfig>;
|
||||||
|
ARCHWING: Types.DocumentArray<ILoadoutConfig>;
|
||||||
|
NORMAL_PVP: Types.DocumentArray<ILoadoutConfig>;
|
||||||
|
LUNARO: Types.DocumentArray<ILoadoutConfig>;
|
||||||
|
OPERATOR: Types.DocumentArray<ILoadoutConfig>;
|
||||||
|
KDRIVE: Types.DocumentArray<ILoadoutConfig>;
|
||||||
|
DATAKNIFE: Types.DocumentArray<ILoadoutConfig>;
|
||||||
|
MECH: Types.DocumentArray<ILoadoutConfig>;
|
||||||
|
OPERATOR_ADULT: Types.DocumentArray<ILoadoutConfig>;
|
||||||
|
DRIFTER: Types.DocumentArray<ILoadoutConfig>;
|
||||||
|
};
|
||||||
|
|
||||||
|
type loadoutModelType = Model<ILoadoutDatabase, {}, loadoutDocumentProps>;
|
||||||
|
|
||||||
|
export const LoadoutModel = model<ILoadoutDatabase, loadoutModelType>("Loadout", loadoutSchema);
|
@ -1,4 +1,4 @@
|
|||||||
import { Inventory } from "@/src/models/inventoryModel";
|
import { Inventory } from "@/src/models/inventoryModels/inventoryModel";
|
||||||
import new_inventory from "@/static/fixed_responses/postTutorialInventory.json";
|
import new_inventory from "@/static/fixed_responses/postTutorialInventory.json";
|
||||||
import config from "@/config.json";
|
import config from "@/config.json";
|
||||||
import { Types } from "mongoose";
|
import { Types } from "mongoose";
|
||||||
|
0
src/services/saveLoadoutService.ts
Normal file
0
src/services/saveLoadoutService.ts
Normal file
@ -1,4 +1,5 @@
|
|||||||
import { IOid } from "@/src/types/commonTypes";
|
import { IOid } from "@/src/types/commonTypes";
|
||||||
|
import { Document, Mongoose } from "mongoose";
|
||||||
|
|
||||||
export interface ISaveLoadoutRequest {
|
export interface ISaveLoadoutRequest {
|
||||||
LoadOuts: ILoadout;
|
LoadOuts: ILoadout;
|
||||||
@ -49,11 +50,27 @@ export interface ILoadout {
|
|||||||
DRIFTER: ILoadoutKey;
|
DRIFTER: ILoadoutKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ILoadoutKey {
|
export interface ILoadoutDatabase {
|
||||||
[key: string]: ItemConfig;
|
NORMAL: ILoadoutConfig;
|
||||||
|
SENTINEL: ILoadoutConfig;
|
||||||
|
ARCHWING: ILoadoutConfig;
|
||||||
|
NORMAL_PVP: ILoadoutConfig;
|
||||||
|
LUNARO: ILoadoutConfig;
|
||||||
|
OPERATOR: ILoadoutConfig;
|
||||||
|
KDRIVE: ILoadoutConfig;
|
||||||
|
DATAKNIFE: ILoadoutConfig;
|
||||||
|
MECH: ILoadoutConfig;
|
||||||
|
OPERATOR_ADULT: ILoadoutConfig;
|
||||||
|
DRIFTER: ILoadoutConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ItemConfig {
|
export interface ILoadoutKey {
|
||||||
|
[key: string]: ILoadoutConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ILoadoutConfigDocument = ILoadoutConfig & Document;
|
||||||
|
|
||||||
|
export interface ILoadoutConfig {
|
||||||
ItemId: IOid;
|
ItemId: IOid;
|
||||||
PresetIcon: string;
|
PresetIcon: string;
|
||||||
Favorite: boolean;
|
Favorite: boolean;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user