970092fccb
- add `ZEN_DEVKIT` env variable to enable/disable devkit - add `isDevkitEnabled()` utility and export it from public api - register devkit nav section and items conditionally when devkit is enabled - add devkit route handling in admin page client and server - add DevkitPage, ComponentsPage, and IconsPage client components
55 lines
1.6 KiB
JavaScript
55 lines
1.6 KiB
JavaScript
/**
|
|
* Application Configuration
|
|
* Centralized configuration management for the entire package
|
|
*/
|
|
|
|
/**
|
|
* Get application name from environment variables
|
|
* @returns {string} Application name
|
|
*/
|
|
export function getAppName() {
|
|
return process.env.ZEN_NAME || 'ZEN';
|
|
}
|
|
|
|
/**
|
|
* Get session cookie name from environment variables
|
|
* @returns {string} Session cookie name
|
|
*/
|
|
export function getSessionCookieName() {
|
|
return process.env.ZEN_AUTH_SESSION_COOKIE_NAME || 'zen_session';
|
|
}
|
|
|
|
/**
|
|
* Public site origin for server-side absolute URLs (emails, redirects, PDF assets).
|
|
* When NODE_ENV is development, NEXT_PUBLIC_URL_DEV is preferred, then NEXT_PUBLIC_URL.
|
|
* Otherwise NEXT_PUBLIC_URL is used. Trailing slashes are stripped.
|
|
* @returns {string}
|
|
*/
|
|
export function getPublicBaseUrl() {
|
|
const fallback = 'http://localhost:3000';
|
|
const isDev = process.env.NODE_ENV === 'development';
|
|
const raw = isDev
|
|
? (process.env.NEXT_PUBLIC_URL_DEV || process.env.NEXT_PUBLIC_URL || fallback)
|
|
: (process.env.NEXT_PUBLIC_URL || fallback);
|
|
return String(raw).replace(/\/$/, '');
|
|
}
|
|
|
|
/**
|
|
* Get application configuration
|
|
* @returns {Object} Application configuration object
|
|
*/
|
|
export function getAppConfig() {
|
|
return {
|
|
name: getAppName(),
|
|
sessionCookieName: getSessionCookieName(),
|
|
timezone: process.env.ZEN_TIMEZONE || 'America/Toronto',
|
|
dateFormat: process.env.ZEN_DATE_FORMAT || 'YYYY-MM-DD',
|
|
defaultCurrency: process.env.ZEN_CURRENCY || 'CAD',
|
|
currencySymbol: process.env.ZEN_CURRENCY_SYMBOL || '$',
|
|
};
|
|
}
|
|
|
|
export function isDevkitEnabled() {
|
|
return process.env.ZEN_DEVKIT === 'true';
|
|
}
|