From 6ca887fc7b085b8630920b0c299067f836d9b63a Mon Sep 17 00:00:00 2001 From: Sainan Date: Fri, 7 Jun 2024 14:27:50 +0200 Subject: [PATCH] chore: update warframe-public-export-plus to 0.2.0 --- package-lock.json | 8 ++++---- package.json | 2 +- .../custom/getItemListsController.ts | 4 ++-- src/services/itemDataService.ts | 19 ++++++++++++++----- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/package-lock.json b/package-lock.json index efb09dce..46a8b08a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "express": "^5.0.0-beta.3", "mongoose": "^8.1.1", "warframe-items": "^1.1262.74", - "warframe-public-export-plus": "^0.1.0", + "warframe-public-export-plus": "^0.2.0", "warframe-riven-info": "^0.1.0", "winston": "^3.11.0", "winston-daily-rotate-file": "^4.7.1" @@ -3895,9 +3895,9 @@ } }, "node_modules/warframe-public-export-plus": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.1.0.tgz", - "integrity": "sha512-a76Be2pwPjKrin67zMux5L9U6zt9bhEtyy723tM2czGGcOZYWp1XdCZY684q3zPytWS0SmEia0C/h/4EiadBnQ==" + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/warframe-public-export-plus/-/warframe-public-export-plus-0.2.0.tgz", + "integrity": "sha512-JkTpkOzFWmjaK10H3CphGz4f6IAdH5higF9jyyTBbBD97U21C+3u9OGAoWav5CO8ydR2hLezcyOyRaqBAf4Abg==" }, "node_modules/warframe-riven-info": { "version": "0.1.0", diff --git a/package.json b/package.json index 50b38ba7..adcec54a 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "express": "^5.0.0-beta.3", "mongoose": "^8.1.1", "warframe-items": "^1.1262.74", - "warframe-public-export-plus": "^0.1.0", + "warframe-public-export-plus": "^0.2.0", "warframe-riven-info": "^0.1.0", "winston": "^3.11.0", "winston-daily-rotate-file": "^4.7.1" diff --git a/src/controllers/custom/getItemListsController.ts b/src/controllers/custom/getItemListsController.ts index 2efde908..ac987565 100644 --- a/src/controllers/custom/getItemListsController.ts +++ b/src/controllers/custom/getItemListsController.ts @@ -21,9 +21,9 @@ function reduceItems(items: MinItem[]): ListedItem[] { const getItemListsController: RequestHandler = (_req, res) => { const mods = reduceItems(items.filter(item => item.category == "Mods")); - for (const arcane of ExportArcanes) { + for (const [uniqueName, arcane] of Object.entries(ExportArcanes)) { mods.push({ - uniqueName: arcane.uniqueName, + uniqueName: uniqueName, name: getEnglishString(arcane.name) }); } diff --git a/src/services/itemDataService.ts b/src/services/itemDataService.ts index 0b33302c..55ebf31c 100644 --- a/src/services/itemDataService.ts +++ b/src/services/itemDataService.ts @@ -3,7 +3,7 @@ import { logger } from "@/src/utils/logger"; import Items, { Buildable, Category, MinimalItem, Warframe, Weapon } from "warframe-items"; import badItems from "@/static/json/exclude-mods.json"; import dict_en from "@/node_modules/warframe-public-export-plus/dict.en.json"; -import exportSuits from "@/node_modules/warframe-public-export-plus/ExportWarframes.json"; +import ExportWarframes from "@/node_modules/warframe-public-export-plus/ExportWarframes.json"; export type MinWarframe = Omit; export type MinWeapon = Omit; @@ -136,9 +136,18 @@ export const getItemCategoryByUniqueName = (uniqueName: string) => { return category; }; +namespace PublicExportPlus { + export interface IGenericExport { + [key: string]: any; + } + + export interface IDict { + [key: string]: string | undefined; + } +} + export const getSuitByUniqueName = (uniqueName: string) => { - const suit = exportSuits.find(suit => suit.uniqueName === uniqueName); - return suit; + return (ExportWarframes as PublicExportPlus.IGenericExport)[uniqueName]; }; export const getItemByUniqueName = (uniqueName: string) => { @@ -151,6 +160,6 @@ export const getItemByName = (name: string) => { return item; }; -export const getEnglishString = (key: string) => { - return dict_en[key as keyof typeof dict_en] ?? key; +export const getEnglishString = (key: string): string => { + return (dict_en as PublicExportPlus.IDict)[key] ?? key; };