SpaceNinjaServer/src/controllers/custom/getItemListsController.ts

42 lines
1.3 KiB
TypeScript
Raw Normal View History

2024-05-04 14:44:23 +02:00
import { RequestHandler } from "express";
import { MinItem, warframes, weapons, items, getEnglishString } from "@/src/services/itemDataService";
2024-06-01 12:57:27 +02:00
import badItems from "@/static/json/exclude-mods.json";
import ExportArcanes from "@/node_modules/warframe-public-export-plus/ExportArcanes.json";
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 arcane of ExportArcanes) {
mods.push({
uniqueName: arcane.uniqueName,
name: getEnglishString(arcane.name)
});
}
2024-05-04 14:44:23 +02:00
res.json({
warframes: reduceItems(warframes),
weapons: reduceItems(weapons.filter(item => item.productCategory != "OperatorAmps")),
2024-06-01 12:57:27 +02:00
miscitems: reduceItems(
items.filter(item => item.category == "Misc" || item.category == "Resources" || item.category == "Fish")
),
mods,
2024-06-01 12:57:27 +02:00
badItems
2024-05-04 14:44:23 +02:00
});
};
export { getItemListsController };