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 { RequestHandler } from "express";
|
||||||
import { getString } from "@/src/services/itemDataService";
|
import { getDict, getString } from "@/src/services/itemDataService";
|
||||||
import {
|
import {
|
||||||
ExportArcanes,
|
ExportArcanes,
|
||||||
ExportGear,
|
ExportGear,
|
||||||
@ -17,7 +17,7 @@ interface ListedItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const getItemListsController: RequestHandler = (req, res) => {
|
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 weapons = [];
|
||||||
const miscitems = [];
|
const miscitems = [];
|
||||||
for (const [uniqueName, item] of Object.entries(ExportWeapons)) {
|
for (const [uniqueName, item] of Object.entries(ExportWeapons)) {
|
||||||
|
@ -118,7 +118,6 @@ export const getDict = (lang: string): Record<string, string> => {
|
|||||||
return dict_en;
|
return dict_en;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getString = (key: string, lang: string = "en"): string => {
|
export const getString = (key: string, dict: Record<string, string>): string => {
|
||||||
const dict = getDict(lang);
|
|
||||||
return dict[key] ?? key;
|
return dict[key] ?? key;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user