System settings #270

Closed
opened 2026-04-05 16:17:13 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @wayneshn on 8/24/2025

The goal of this issue is to create a centralized place for administrators to manage global, generic configurations for the application.

  1. Database Schema:

    • A new table, system_settings, will be created.
    • It will contain a single row to store all settings in a single JSONB column named config. This allows for easy extension of settings in the future without requiring schema migrations.
    • The schema will be defined in a new file: packages/backend/src/database/schema/system-settings.ts.
  2. Shared Types:

    • To ensure type safety between the frontend and backend, new types will be defined in packages/types/src/system.types.ts.
    • SupportedLanguage Type: A specific union type will be created to constrain the available languages.
    • SystemSettings Interface: This interface will define the shape of the settings object.
  3. Proposed Settings Schema:
    Based on the feedback, the settings will be simplified to only include essential generic configurations.

    // In packages/types/src/system.types.ts
    
    export type SupportedLanguage =
    	| 'en' // English
    	| 'es' // Spanish
    	| 'fr' // French
    	| 'de' // German
    	| 'it' // Italian
    	| 'pt' // Portuguese
    	| 'nl' // Dutch
    	| 'ja'; // Japanese
    
    export type Theme = 'light' | 'dark' | 'system';
    
    export interface SystemSettings {
    	/** The default display language for the application UI. */
    	language: SupportedLanguage;
    
    	/** The default color theme for the application. */
    	theme: Theme;
    
    	/** A public-facing email address for user support inquiries. */
    	supportEmail: string | null;
    }
    
  4. API Endpoints & Routing:

    • A new route file will be created: packages/backend/src/api/routes/settings.routes.ts.
    • It will define two endpoints:
      • GET /api/v1/settings: Retrieves the current system settings.
      • PUT /api/v1/settings: Updates the system settings.
  5. Permissions & Access Control:

    • The requirePermission middleware will be used to secure the endpoints.
    • Based on packages/types/src/iam.types.ts, the existing AppSubjects type includes 'settings', which will be used for this feature. No new subject is needed.
    • Access will be configured as follows, using existing AppActions:
      • GET /api/v1/settings: This should be an open api route, it should be accessible without authorization or permissions. Make sure no sensitive data is exposed in this route.
      • PUT /api/v1/settings: Requires 'manage' permission on the 'settings' subject. This is appropriate as 'manage' is a valid action and implies the ability to create and update.
  6. Controller and Service:

    • A new SettingsController will handle the HTTP logic.
    • A new SettingsService will contain the business logic for interacting with the database.

Part 2: Frontend UI Implementation

A new page will be added to the dashboard for administrators to manage these settings.

  1. New Route:
    • A new page will be created at packages/frontend/src/routes/dashboard/settings/system/+page.svelte.
    • A corresponding +page.server.ts will fetch the settings data from the API on page load.
*Originally created by @wayneshn on 8/24/2025* The goal of this issue is to create a centralized place for administrators to manage global, generic configurations for the application. 1. **Database Schema:** - A new table, `system_settings`, will be created. - It will contain a single row to store all settings in a single `JSONB` column named `config`. This allows for easy extension of settings in the future without requiring schema migrations. - The schema will be defined in a new file: `packages/backend/src/database/schema/system-settings.ts`. 2. **Shared Types:** - To ensure type safety between the frontend and backend, new types will be defined in `packages/types/src/system.types.ts`. - **`SupportedLanguage` Type:** A specific union type will be created to constrain the available languages. - **`SystemSettings` Interface:** This interface will define the shape of the settings object. 3. **Proposed Settings Schema:** Based on the feedback, the settings will be simplified to only include essential generic configurations. ```typescript // In packages/types/src/system.types.ts export type SupportedLanguage = | 'en' // English | 'es' // Spanish | 'fr' // French | 'de' // German | 'it' // Italian | 'pt' // Portuguese | 'nl' // Dutch | 'ja'; // Japanese export type Theme = 'light' | 'dark' | 'system'; export interface SystemSettings { /** The default display language for the application UI. */ language: SupportedLanguage; /** The default color theme for the application. */ theme: Theme; /** A public-facing email address for user support inquiries. */ supportEmail: string | null; } ``` 4. **API Endpoints & Routing:** - A new route file will be created: `packages/backend/src/api/routes/settings.routes.ts`. - It will define two endpoints: - `GET /api/v1/settings`: Retrieves the current system settings. - `PUT /api/v1/settings`: Updates the system settings. 5. **Permissions & Access Control:** - The `requirePermission` middleware will be used to secure the endpoints. - Based on `packages/types/src/iam.types.ts`, the existing `AppSubjects` type includes `'settings'`, which will be used for this feature. No new subject is needed. - Access will be configured as follows, using existing `AppActions`: - `GET /api/v1/settings`: This should be an **open** api route, it should be accessible without authorization or permissions. Make sure no sensitive data is exposed in this route. - `PUT /api/v1/settings`: Requires `'manage'` permission on the `'settings'` subject. This is appropriate as `'manage'` is a valid action and implies the ability to create and update. 6. **Controller and Service:** - A new `SettingsController` will handle the HTTP logic. - A new `SettingsService` will contain the business logic for interacting with the database. --- ### **Part 2: Frontend UI Implementation** A new page will be added to the dashboard for administrators to manage these settings. 1. **New Route:** - A new page will be created at `packages/frontend/src/routes/dashboard/settings/system/+page.svelte`. - A corresponding `+page.server.ts` will fetch the settings data from the API on page load.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/OpenArchiver#270