settings ModuleThe Settings Module is responsible for storing and managing user-specific preferences such as UI themes and notification preferences.
This module:
user_settings table in the database├── settings/
│ ├── api/
│ │ └── settings.rs # Core API logic for fetching and updating user settings
│ ├── constants.rs # Route and path constants
│ ├── web/
│ │ └── settings.rs # Web-based handler (HTML rendering, etc.)
│ └── routes.rs # Axum router configuration for settings
| Method | Path | Description |
|---|---|---|
| GET | /api/settings/get |
Get current user's settings |
| POST | /api/settings/update |
Update theme and notifications |
/profile/entity/user_settings.rspub struct Model {
pub id: Uuid,
pub user_id: Uuid,
pub theme: String, // e.g. "dark"
pub notifications: bool, // Enable/disable email/push
pub created_at: DateTimeUtc,
pub updated_at: DateTimeUtc,
}
Setter: ActiveModel::before_save() sets timestamps
Getter: Accessed via user_id queries
Notes:
UpdateSettings
pub struct UpdateSettings {
pub theme: Option<String>,
pub notifications: Option<bool>,
}
update_settingsThe module currently returns only HTTP status codes for API feedback.
Possible responses:
200 OK: Settings updated successfully404 NOT_FOUND: No settings found for user (on fetch)500 INTERNAL_SERVER_ERROR: Database errorget_settings
Fetches current settings for the logged-in user
Returns JSON struct of user_settings::Model
Handles 3 scenarios:
update_settings
updated_at fieldThe settings routes are registered using Axum's Router and include:
API Routes
GET /api/settings/get → get_settingsPOST /api/settings/update → update_settingsWeb Routes
GET /api/settings → Renders settings.html (web frontend)Middleware
CSRF and CORS protections are applied via:
csrf_layer()cors_layer()user_settings model to support additional settings