REC_WebHub
Stracture
Installation, configuration, and usage for REC_WebHub.
- Added
- Updated
The following configuration files and manifest are taken from the current source.
config/sv_config.lua
---[[
--- REC_WebHub server config
--- What each setting does, and why the defaults are what they are:
--- https://docs.re-cord.dev/en/resources/rec_webhub
---]]
---@type REC_Library.Server.Class.Web.WebConfig
local webConfig = require "@REC_Library.server.class.web.sv_webConfig"
---@type REC_Library.Server.Class.Web.WebConfigStore
local WebConfigStore = require "@REC_Library.server.class.web.sv_webConfigStore"
---[[
--- Settings the admin panel owns
--- They are declared in server/sv_settings.lua (value, range and description) and
--- changed from the hub, so they are not repeated here.
---]]
---@type REC_WebHub.Server.Settings
local settings = require "@REC_WebHub.server.sv_settings"
---@class REC_WebHub.Server.Config
local config = {}
---[[
--- Debug Mode
---]]
---@type boolean
config.debugMode = true
---[[
--- Panels shown on the hub
--- Every entry needs a unique key. The card label and description come from
--- locales/web/<language>.json (PANEL_<KEY>_NAME / PANEL_<KEY>_DESC, key in
--- upper case), and fall back to `name` (or the resource name) when missing.
---]]
---@type REC_WebHub.Server.Config.Panel[]
config.panels = {
{
key = "rec_economy",
resource = "REC_Economy",
mock = true,
},
{
key = "rec_itemmanager",
resource = "REC_ItemManager",
mock = true,
},
{
key = "rec_playermanager",
resource = "REC_PlayerManager",
mock = true,
},
{
key = "rec_heistmanager",
resource = "REC_HeistManager",
mock = true,
},
-- ---[[
-- --- External URL example
-- ---]]
-- {
-- key = "txadmin",
-- name = "txAdmin",
-- url = "http://localhost:40120/",
-- probe = false,
-- },
}
---[[
--- Admin UI
--- The hub is browser only (no NUI), so http is the whole gate.
---
--- Tokens, dist dir and the address allowlist are shared defaults from
--- REC_Library. One convar covers every REC_* panel, so set these once:
--- set REC:adminToken "xxxxx"
--- set REC:supportToken "yyyyy"
--- set REC:allowedAddresses "192.168.1.0/24" # opens the LAN everywhere
---
--- Naming this resource narrows one of them to this panel alone:
--- set REC_WebHub:supportToken "zzzzz"
---]]
config.web = webConfig:build(config.debugMode, {
---[[
--- Permission areas this resource understands, as "<area>:read" / "<area>:write"
---]]
---@type string[]
areas = {
"panels", -- read the launcher list, write queues a rescan
"settings", -- the settings this hub owns (write changes them)
},
http = {
---@type boolean
enabled = true, -- RELEASE:false
-- named tokens beyond admin/support, each scoped on its own: https://docs.re-cord.dev/en/resources/rec_library/web-config
-- customTokens = {
-- { name = "panelsOnly", scopes = { "panels" }, },
-- { name = "fullAccess", scopes = { "*" }, },
-- },
-- replaces the convar-built address list entirely, keep loopback in it
-- allowedAddresses = {
-- "127.0.0.0/8",
-- "192.168.1.0/24",
-- },
-- trustedProxies = {
-- "10.0.0.5",
-- },
},
})
---@class REC_WebHub.Server.Config.Panel
---@field key string unique id, also the locale key suffix in upper case
---@field resource? string REC_* resource serving its own browser panel
---@field name? string fallback label when the locale has no PANEL_<KEY>_NAME
---@field url? string override, absolute for external targets
---@field mock? boolean nil detects the "?mock=1" support from the web build
---@field probe? boolean false skips the reachability check
-- put the panel owned defaults in place before anything reads them
WebConfigStore.seed(config, settings.list)
return config
