fix: 7 bug fixes + port config with auto-restart
- HTTPException import added (was causing 500 on missing dashboard) - game_manager.remove_plugin() restored (was AttributeError) - api.js checks HTTP status codes, fails fast on errors - sidebar game highlight only matches selected gameId - scene resize handler uses stored canvas dims (was NaN) - forwarder socket properly closed on listener stop - telemetry port: use_unified_port toggle, off = per-game port, auto-restart on switch
This commit is contained in:
+15
-24
@@ -1,33 +1,24 @@
|
||||
const API = {
|
||||
_base: '/api',
|
||||
|
||||
async get(path) {
|
||||
const res = await fetch(`${this._base}${path}`);
|
||||
async _req(method, path, body) {
|
||||
const opts = { method };
|
||||
if (body) {
|
||||
opts.headers = { 'Content-Type': 'application/json' };
|
||||
opts.body = JSON.stringify(body);
|
||||
}
|
||||
const res = await fetch(`${this._base}${path}`, opts);
|
||||
if (!res.ok) {
|
||||
const text = await res.text().catch(() => '');
|
||||
throw new Error(`${method} ${path} ${res.status}: ${text.slice(0, 200)}`);
|
||||
}
|
||||
return res.json();
|
||||
},
|
||||
|
||||
async post(path, data) {
|
||||
const res = await fetch(`${this._base}${path}`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
return res.json();
|
||||
},
|
||||
|
||||
async put(path, data) {
|
||||
const res = await fetch(`${this._base}${path}`, {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
return res.json();
|
||||
},
|
||||
|
||||
async del(path) {
|
||||
const res = await fetch(`${this._base}${path}`, { method: 'DELETE' });
|
||||
return res.json();
|
||||
},
|
||||
async get(path) { return this._req('GET', path); },
|
||||
async post(path, data) { return this._req('POST', path, data); },
|
||||
async put(path, data) { return this._req('PUT', path, data); },
|
||||
async del(path) { return this._req('DELETE', path); },
|
||||
|
||||
async getStatus() { return this.get('/status'); },
|
||||
async getConfig() { return this.get('/config'); },
|
||||
|
||||
Reference in New Issue
Block a user