feat(storage): refactor storage config and remove module registry
Introduce a dedicated `storage-config.js` for registering public prefixes and access policies via `configureStorageApi()`, replacing the previous `getAllStoragePublicPrefixes` / `getAllStorageAccessPolicies` imports from the module registry. Remove `getAllApiRoutes()` from the router so module-level routes are no longer auto-collected; feature routes must now be registered explicitly via `registerFeatureRoutes()` during `initializeZen()`. Update `.env.example` to document separate `ZEN_STORAGE_PROVIDER`, `ZEN_STORAGE_B2_*` variables for Backblaze B2 alongside the existing Cloudflare R2 variables, making provider selection explicit. Clean up admin navigation and page components to drop module-injected nav entries, keeping only core and system sections.
This commit is contained in:
@@ -3,8 +3,6 @@
|
||||
* Centralized configuration management for the entire package
|
||||
*/
|
||||
|
||||
import { getAvailableModules } from '../../modules/modules.registry.js';
|
||||
|
||||
/**
|
||||
* Get application name from environment variables
|
||||
* @returns {string} Application name
|
||||
@@ -36,28 +34,6 @@ export function getPublicBaseUrl() {
|
||||
return String(raw).replace(/\/$/, '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get enabled modules configuration (server-side only)
|
||||
* This function dynamically reads from modules.registry.js and checks environment variables
|
||||
* Use this on the server and pass the result to client components as props
|
||||
*
|
||||
* To enable a module, set the environment variable: ZEN_MODULE_{NAME}=true
|
||||
* Example: ZEN_MODULE_INVOICE=true
|
||||
*
|
||||
* @returns {Object} Object with module names as keys and boolean values
|
||||
*/
|
||||
export function getModulesConfig() {
|
||||
const modules = {};
|
||||
const availableModules = getAvailableModules();
|
||||
|
||||
for (const moduleName of availableModules) {
|
||||
const envVar = `ZEN_MODULE_${moduleName.toUpperCase()}`;
|
||||
modules[moduleName] = process.env[envVar] === 'true';
|
||||
}
|
||||
|
||||
return modules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get application configuration
|
||||
* @returns {Object} Application configuration object
|
||||
@@ -68,10 +44,7 @@ export function getAppConfig() {
|
||||
sessionCookieName: getSessionCookieName(),
|
||||
timezone: process.env.ZEN_TIMEZONE || 'America/Toronto',
|
||||
dateFormat: process.env.ZEN_DATE_FORMAT || 'YYYY-MM-DD',
|
||||
// Currency configuration (for currency module)
|
||||
defaultCurrency: process.env.ZEN_CURRENCY || 'CAD',
|
||||
currencySymbol: process.env.ZEN_CURRENCY_SYMBOL || '$',
|
||||
// Enabled modules
|
||||
modules: getModulesConfig(),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user