optimise getItemLists request by only fetching dict once
This commit is contained in:
parent
c98c56c0ab
commit
71dfa789df
@ -1,5 +1,5 @@
|
||||
import { RequestHandler } from "express";
|
||||
import { getString } from "@/src/services/itemDataService";
|
||||
import { getDict, getString } from "@/src/services/itemDataService";
|
||||
import {
|
||||
ExportArcanes,
|
||||
ExportGear,
|
||||
@ -17,7 +17,7 @@ interface ListedItem {
|
||||
}
|
||||
|
||||
const getItemListsController: RequestHandler = (req, res) => {
|
||||
const lang = typeof req.query.lang == "string" ? req.query.lang : "en";
|
||||
const lang = getDict(typeof req.query.lang == "string" ? req.query.lang : "en");
|
||||
const weapons = [];
|
||||
const miscitems = [];
|
||||
for (const [uniqueName, item] of Object.entries(ExportWeapons)) {
|
||||
|
@ -118,7 +118,6 @@ export const getDict = (lang: string): Record<string, string> => {
|
||||
return dict_en;
|
||||
};
|
||||
|
||||
export const getString = (key: string, lang: string = "en"): string => {
|
||||
const dict = getDict(lang);
|
||||
export const getString = (key: string, dict: Record<string, string>): string => {
|
||||
return dict[key] ?? key;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user