SpaceNinjaServer/src/controllers/custom/getItemListsController.ts

55 lines
1.8 KiB
TypeScript
Raw Normal View History

2024-05-04 14:44:23 +02:00
import { RequestHandler } from "express";
import { MinItem, MinWeapon, warframes, items, getEnglishString } from "@/src/services/itemDataService";
2024-06-01 12:57:27 +02:00
import badItems from "@/static/json/exclude-mods.json";
import { ExportArcanes, ExportWeapons } from "warframe-public-export-plus";
2024-05-04 14:44:23 +02:00
interface ListedItem {
uniqueName: string;
name: string;
2024-06-01 12:57:27 +02:00
fusionLimit?: number;
2024-05-04 14:44:23 +02:00
}
function reduceItems(items: MinItem[]): ListedItem[] {
return items.map((item: MinItem): ListedItem => {
return {
uniqueName: item.uniqueName,
2024-06-01 12:57:27 +02:00
name: item.name,
fusionLimit: (item as any).fusionLimit
2024-05-04 14:44:23 +02:00
};
});
}
const getItemListsController: RequestHandler = (_req, res) => {
const mods = reduceItems(items.filter(item => item.category == "Mods"));
for (const [uniqueName, arcane] of Object.entries(ExportArcanes)) {
mods.push({
uniqueName: uniqueName,
name: getEnglishString(arcane.name)
});
}
2024-05-04 14:44:23 +02:00
res.json({
warframes: reduceItems(warframes),
weapons: Object.entries(ExportWeapons)
.filter(([_uniqueName, weapon]) => weapon.productCategory !== "OperatorAmps" && weapon.totalDamage !== 0)
.map(([uniqueName, weapon]) => {
return {
uniqueName,
name: getEnglishString(weapon.name)
};
}),
2024-06-01 12:57:27 +02:00
miscitems: reduceItems(
items.filter(
item =>
item.category == "Misc" ||
item.category == "Resources" ||
item.category == "Fish" ||
((item as any).productCategory == "Pistols" && (item as MinWeapon).totalDamage == 0)
)
2024-06-01 12:57:27 +02:00
),
mods,
2024-06-01 12:57:27 +02:00
badItems
2024-05-04 14:44:23 +02:00
});
};
export { getItemListsController };