initialize generic rms-software repository

Add the reusable RMS core application (server, web UI, plugins, tests, tools) with generic defaults, GPL licensing, and maintainer context documentation so deployments can consume this repo as software source independent of station-specific overlays.
This commit is contained in:
2026-03-16 03:31:08 +01:00
commit e1a4ce0b8b
58 changed files with 20611 additions and 0 deletions

60
server/storage/index.js Normal file
View File

@@ -0,0 +1,60 @@
const fs = require("fs");
const path = require("path");
const { createJsonStorage } = require("./providers/json");
const { createSqliteStorage } = require("./providers/sqlite");
async function createStorageProvider(config) {
const providerId = String(config.storageProvider || "json").trim().toLowerCase();
if (providerId === "json") {
const provider = createJsonStorage({ dataDir: config.dataDir });
await provider.init();
return provider;
}
if (providerId === "sqlite") {
const sqlitePath = config.storageSqlitePath || path.join(config.dataDir, "rms-storage.db");
const provider = createSqliteStorage({
sqlitePath
});
try {
await provider.init();
return provider;
} catch (error) {
const sqliteMissing = /node:sqlite/i.test(String(error && error.message ? error.message : error));
const sqliteDbExists = fs.existsSync(sqlitePath);
if (sqliteMissing && !sqliteDbExists) {
console.warn(`WARN: SQLite not available (${String(error.message || error)}), falling back to JSON storage at ${config.dataDir}`);
const fallback = createJsonStorage({ dataDir: config.dataDir });
await fallback.init();
return fallback;
}
throw error;
}
}
if (providerId === "module") {
const modulePath = config.storageModulePath;
if (!modulePath) {
throw new Error("STORAGE_PROVIDER=module requires STORAGE_MODULE_PATH");
}
const resolved = path.isAbsolute(modulePath) ? modulePath : path.resolve(config.rootDir, modulePath);
const mod = require(resolved);
const create = typeof mod.createStorage === "function" ? mod.createStorage : mod;
const provider = await create(config);
if (!provider || typeof provider.readJson !== "function" || typeof provider.writeJson !== "function") {
throw new Error("Custom storage module must implement readJson/writeJson");
}
if (typeof provider.init === "function") {
await provider.init();
}
return provider;
}
throw new Error(`Unknown STORAGE_PROVIDER: ${providerId}`);
}
module.exports = {
createStorageProvider
};