Docs/API Reference/Packages

@veap/settings

Inspected version: 0.1.3 · Source

2 min read

Inspected version: 0.1.3 · Source →

Database-persisted key/value settings with cache integration.

Entry points#

The manifest exports ., /models, /server, /migrations and /package.json.

Main exports#

  • SettingsService
  • SettingsServiceProvider
  • SettingsConfig
  • SETTINGS_REPOSITORY, SETTINGS_SERVICE
  • ISettingsRepository, ISettingsService
  • setting model and migration exports

Service methods#

MethodBehavior
get<T>(key, defaultValue?)Reads cache/persistence and returns value or fallback/null
has(key)Tests whether get(key) returns a non-null value
set(key, value)Persists and updates the cache
remove(key)Deletes persistence and the corresponding cache key
clear()Clears the repository and cache
all()Returns all settings when repository supports it; otherwise an empty object

The service uses cache keys prefixed with settings:. Values should be JSON-compatible.

Provider configuration#

SettingsServiceProvider takes the container and optional { autoMigrate?: boolean }. Automatic migration defaults to enabled when a database is initialized, unless overridden by config or SETTINGS_AUTO_MIGRATE.

ts
import { Application } from "@veap/kernel";
import { DatabaseServiceProvider } from "@veap/database";
import { SettingsServiceProvider } from "@veap/settings";

const app = Application.configure()
  .use(DatabaseServiceProvider)
  .use(SettingsServiceProvider)
  .create();

Register the database provider before settings because the settings repository uses the ORM. For controlled production releases, run migrations through an explicit deployment workflow.

veap
Preparing0%