diff --git a/src/controllers/custom/getConfigDataController.ts b/src/controllers/custom/getConfigDataController.ts new file mode 100644 index 00000000..8d946384 --- /dev/null +++ b/src/controllers/custom/getConfigDataController.ts @@ -0,0 +1,8 @@ +import { RequestHandler } from "express"; +import configFile from "@/config.json"; + +const getConfigDataController: RequestHandler = (_req, res) => { + res.json(configFile); +}; + +export { getConfigDataController }; diff --git a/src/controllers/custom/updateConfigDataController.ts b/src/controllers/custom/updateConfigDataController.ts new file mode 100644 index 00000000..38d6ca35 --- /dev/null +++ b/src/controllers/custom/updateConfigDataController.ts @@ -0,0 +1,16 @@ +import { RequestHandler } from "express"; +import path from "path"; +import fs from "fs"; +const rootDir = path.join(__dirname, "../../.."); + +const updateConfigDataController: RequestHandler = (req) => { + const updateSettingsData = req.body; + + fs.writeFile(path.join(rootDir, "config.json"), updateSettingsData, function(err:any) { + if(err) { + return console.log(err); + } + }); +}; + +export { updateConfigDataController }; diff --git a/src/routes/custom.ts b/src/routes/custom.ts index 8a4218d7..6c0a7416 100644 --- a/src/routes/custom.ts +++ b/src/routes/custom.ts @@ -2,6 +2,8 @@ import express from "express"; import { getItemListsController } from "@/src/controllers/custom/getItemListsController"; import { createAccountController } from "@/src/controllers/custom/createAccountController"; import { addItemController } from "@/src/controllers/custom/addItemController"; +import { getConfigDataController } from "@/src/controllers/custom/getConfigDataController"; +import { updateConfigDataController } from "@/src/controllers/custom/updateConfigDataController"; const customRouter = express.Router(); @@ -10,4 +12,7 @@ customRouter.get("/getItemLists", getItemListsController); customRouter.post("/createAccount", createAccountController); customRouter.post("/addItem", addItemController); -export { customRouter }; +customRouter.get("/config", getConfigDataController); +customRouter.post("/config", updateConfigDataController); + +export { customRouter }; \ No newline at end of file diff --git a/src/routes/webui.ts b/src/routes/webui.ts index 677031c6..93005f34 100644 --- a/src/routes/webui.ts +++ b/src/routes/webui.ts @@ -19,6 +19,9 @@ webuiRouter.use("/webui", (req, res, next) => { }); // Serve virtual routes +webuiRouter.get("/webui/settings", (_req, res) => { + res.sendFile(path.join(rootDir, "static/webui/index.html")); +}); webuiRouter.get("/webui/inventory", (_req, res) => { res.sendFile(path.join(rootDir, "static/webui/index.html")); }); diff --git a/static/webui/index.html b/static/webui/index.html index a680fd33..6ab05bad 100644 --- a/static/webui/index.html +++ b/static/webui/index.html @@ -67,15 +67,21 @@ Mods +
- Note: Changes made here will only be reflected in-game when the game re-downloads your inventory. - Visiting the navigation should be the easiest way to trigger that. -
Login using your OpenWF account credentials.
+ Note: Changes made here will only be reflected in-game when the game re-downloads your inventory. + Visiting the navigation should be the easiest way to trigger that. +
+ Note: Changes made here will only be reflected in-game when the game re-downloads your inventory. + Visiting the navigation should be the easiest way to trigger that. +