46 Commits

Author SHA1 Message Date
MayaTheShy
e59b6c1832 feat: upgrade Node.js version to 20-alpine in Dockerfiles and improve healthcheck command 2026-03-22 22:44:26 -04:00
MayaTheShy
96afe8dcb7 Fix silent Docker crash: recursive chown, db error handling
- Entrypoint: chown -R /data (not just the directory) so existing
  volume files owned by root become writable by node user
- Entrypoint: add echo logging so startup progress is visible
- db.js: verify /data is writable before opening SQLite
- db.js: wrap Database() constructor in try-catch with clear error
  message instead of crashing silently at ESM import time
2026-03-22 21:22:30 -04:00
MayaTheShy
1b0b1c570d Fix health check: use wget -qO instead of --spider, increase start_period to 30s 2026-03-22 21:15:43 -04:00
MayaTheShy
173a0a9f95 Persist config files across Opus package updates
The Opus package manager deletes the entire package directory on
update (fs.delete(packageDir)) before re-downloading files. This
wiped all config files (.manager_config, .client_config, etc.) that
were stored inside packages/inventory-manager/.

Fix: add _configPath() helper to every program that resolves config
file paths to usr/config/inventory-manager/ when running under Opus,
which lives outside the package directory and survives updates.
Falls back to the local _path() for standalone (non-Opus) use.

Updated files:
- inventoryManager.lua, manager/config.lua, inventoryClient.lua,
  inventoryWebBridge.lua, dropperController.lua, craftingTurtle.lua
- .package install script: saves configs to usr/config/inventory-manager/
- autorun/startup.lua: checks both persistent and package dirs
- startup/client.lua: uses persistent dir for .client_setup/.dropper_config
- web/server/Dockerfile: switch health check to wget (from prior fix)
2026-03-22 20:51:31 -04:00
MayaTheShy
01eef4eead fix: correct typo in HEALTHCHECK start-period option 2026-03-22 20:44:57 -04:00
MayaTheShy
a499446366 fix: use wget for Docker health check instead of node
Spawning a full Node process for health checks is slow on Alpine and
can exceed the 3s timeout, causing the container to be marked unhealthy.
Use wget (built into Alpine) instead, and increase start_period to 15s.
2026-03-22 20:42:37 -04:00
MayaTheShy
b49574f39b fix: SQLite readonly error in Docker container
- Add entrypoint script that ensures /data is owned by node user
  before dropping privileges with su-exec
- Remove USER node from Dockerfile (entrypoint handles it)
- Change client depends_on to service_healthy so nginx waits for
  the server to pass its healthcheck before starting
2026-03-22 19:15:04 -04:00
MayaTheShy
40df13e756 Refactor database test setup to use DB_PATH from vitest.config.js 2026-03-22 11:54:57 -04:00
MayaTheShy
f2634328ec Add Vitest configuration for testing environment setup 2026-03-22 11:54:51 -04:00
MayaTheShy
53863657d7 Refactor code structure for improved readability and maintainability 2026-03-22 11:54:07 -04:00
MayaTheShy
ba0cbfbbb6 Add unit tests for server logic including rate limiter, normalization helpers, and input validation 2026-03-22 11:52:33 -04:00
MayaTheShy
a8513b339c Add comprehensive tests for the database layer in db.test.js 2026-03-22 11:51:47 -04:00
MayaTheShy
21f12501ca Add testing scripts and update devDependencies in package.json 2026-03-22 11:46:57 -04:00
MayaTheShy
026d0c8d6b Add Cross-Project Integration API for RemoteTurtle system 2026-03-22 04:10:11 -04:00
MayaTheShy
2ac11350e6 Add API endpoint for remote reboot of CC:Tweaked computers 2026-03-22 03:15:36 -04:00
MayaTheShy
479e1918f5 Implement rate limiting and enhance input validation for API endpoints 2026-03-22 02:57:21 -04:00
MayaTheShy
9d5fceee5c Enhance Dockerfile to create SQLite data directory with proper ownership 2026-03-22 02:57:18 -04:00
MayaTheShy
78674714b1 Enhance WebSocket keep-alive mechanism to include bridge connections and handle stale connections 2026-03-22 02:41:52 -04:00
MayaTheShy
460cf34252 Enhance WebSocket error handling and implement command idempotency for dropper nickname and recipe management endpoints 2026-03-22 02:38:30 -04:00
MayaTheShy
0fb57d7c94 Ensure database is only closed if it is open in closeDb function 2026-03-22 02:38:17 -04:00
MayaTheShy
465efbeb0e Implement API key authentication for secure access to mutating endpoints and WebSocket connections 2026-03-22 02:13:24 -04:00
MayaTheShy
bbae2740a7 Implement idempotent command tracking with cleanup and caching for improved request handling 2026-03-22 02:12:18 -04:00
MayaTheShy
a5e6be7f4b Enhance command handling: implement monotonic ID for deduplication and improve acknowledgment process 2026-03-22 01:29:16 -04:00
MayaTheShy
bee1019fd6 Add dropper nickname management: implement get and set endpoints 2026-03-21 20:55:01 -04:00
MayaTheShy
5416f18f4b Add droppers to full state load: include droppers array from inventory metadata for comprehensive state management 2026-03-21 20:12:54 -04:00
MayaTheShy
9f75866ce7 Notify web clients on bridge connection status: broadcast updates when the bridge connects or disconnects 2026-03-21 20:05:45 -04:00
MayaTheShy
79eca14f4c Add dropper location selector: discover available droppers on network, pass through server, and add dropdown in order panel for location-based dispensing 2026-03-21 19:57:13 -04:00
MayaTheShy
fcfef379be Add droppers array to state update: ensure droppers data is handled correctly in the state from bridge 2026-03-21 19:41:56 -04:00
MayaTheShy
05f5a3519e Add texture proxy and caching mechanism: implement upstream fetching and local caching for texture assets 2026-03-21 19:29:59 -04:00
MayaTheShy
b5ae28944d Enhance health check and inventory endpoints: include bridge connection status and web client count 2026-03-21 19:26:36 -04:00
MayaTheShy
29498a2f6a Major UI overhaul: bigger icons, creative inventory tabs, grouped smelting, alerts popup, analytics, mod icons
- Inventory: Bigger item icons (48px) filling their slots, MC-style hover tooltips
- Creative inventory category tabs (All/Blocks/Tools/Combat/Food/Redstone/Materials/Misc)
- Smelting recipes grouped by output item with collapsible sections
- Alerts moved from full tab to popup overlay triggered from header bell icon
- New Analytics tab with SVG charts (storage over time, top items, item trend lookup)
- Mod icon support for ComputerCraft (CC:Tweaked) via GitHub CDN fallback
- Server: new /api/history-summary endpoint for aggregate storage history
- Store: fetchHistorySummary and fetchItemHistory for analytics data
2026-03-21 19:07:17 -04:00
MayaTheShy
c25ef9f2cc Fix inventory disappearing: add WS keep-alive pings + HTTP API fallback
- Server pings web clients every 25s to keep connections alive through reverse proxies
- Client fetches /api/inventory on page load (doesn't depend solely on WebSocket)
- Prevent duplicate WebSocket connections on reconnect
- Deduplicate initial_state/state_update handlers
2026-03-21 18:35:17 -04:00
MayaTheShy
4af91235e1 Refactor furnace input, fuel, and output handling: stringify on save and parse on load 2026-03-21 18:21:23 -04:00
MayaTheShy
80338d1973 Fix live updates: debounce DB writes, broadcast before saving, include smeltable/craftable in updates 2026-03-21 18:15:50 -04:00
MayaTheShy
aed7d1f735 Enhance database performance: add cache size and temp store settings; refactor alert clearing statement 2026-03-21 18:14:16 -04:00
MayaTheShy
9f322003db Add SQLite persistence + official Minecraft item icons
Database (better-sqlite3):
- Persist items, furnaces, alerts, recipes, settings to SQLite
- Auto-restore last known state when server restarts or bridge disconnects
- Item count history tracking (5-min snapshots, 7-day retention)
- /api/history/:itemName endpoint for item count history
- Docker volume for database file persistence
- Graceful shutdown with DB connection cleanup

Icons:
- Replace mc-heads.net with official Minecraft game textures via CDN
- Cascading fallback: item texture -> block texture -> emoji
- In-memory URL cache to avoid redundant network requests
- Block texture suffix mapping (furnace_front, barrel_top, etc.)
- Crisp pixel-art rendering with image-rendering: pixelated
2026-03-21 18:10:44 -04:00
MayaTheShy
bbc44c3d97 Fix healthcheck: use node instead of wget, relax client dependency to service_started 2026-03-21 18:03:22 -04:00
MayaTheShy
d4d6e5e480 Fix healthcheck: use wget -qO instead of --spider (BusyBox compat) 2026-03-21 17:57:25 -04:00
MayaTheShy
0ce63bacd7 Normalize inventory and alerts data structure in updateStateFromBridge function 2026-03-21 17:42:49 -04:00
MayaTheShy
a16039e920 Update HEALTHCHECK command in Dockerfile to use wget for improved reliability 2026-03-21 17:35:53 -04:00
MayaTheShy
bd5b1db5a0 Refactor server configuration to use environment variables for PORT and HOST; normalize itemList structure in inventory state update 2026-03-21 17:30:59 -04:00
MayaTheShy
ba72ce40cd Implement feature X to enhance user experience and optimize performance 2026-03-21 16:53:18 -04:00
MayaTheShy
7935bd6938 Add .dockerignore file to exclude node_modules, dist, and .env 2026-03-21 16:53:15 -04:00
MayaTheShy
1f57333cb0 Implement initial server setup with Express, WebSocket support, and API endpoints for inventory management 2026-03-21 16:42:30 -04:00
MayaTheShy
12b1165938 Add package.json for server configuration and dependencies 2026-03-21 16:42:21 -04:00
MayaTheShy
953e8aba99 Add Dockerfile for Node.js backend setup 2026-03-21 16:42:14 -04:00