From 72487019b3f255cece40a8073bbad8bc9968a3b7 Mon Sep 17 00:00:00 2001 From: "Alex Pooley (@zuedev)" Date: Wed, 22 Jul 2026 15:32:57 +0100 Subject: major code refactor, add uex lookup --- 174bg/discord-bot/source/controllers/uex.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 174bg/discord-bot/source/controllers/uex.js (limited to '174bg/discord-bot/source/controllers/uex.js') diff --git a/174bg/discord-bot/source/controllers/uex.js b/174bg/discord-bot/source/controllers/uex.js new file mode 100644 index 0000000..615b517 --- /dev/null +++ b/174bg/discord-bot/source/controllers/uex.js @@ -0,0 +1,29 @@ +import { get } from "./http.js"; + +export async function categories() { + return await get("https://api.uexcorp.uk/2.0/categories"); +} + +export async function items(id_category) { + let items = []; + + if (!id_category) { + const { data: categories } = await get("https://api.uexcorp.uk/2.0/categories"); + + for (const category of categories) { + const { data: categoryItems } = await get(`https://api.uexcorp.uk/2.0/items?id_category=${category.id}`); + + if (!categoryItems) continue; + + items = items.concat(categoryItems); + } + } else { + const { data } = await get(`https://api.uexcorp.uk/2.0/items?category=${id_category}`); + + items = data; + } + + return items; +} + +export default { categories, items }; \ No newline at end of file -- cgit v1.2.3