feat(config): add shared browser cookie policy
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wrnexus/dev-server",
|
||||
"version": "0.8.27",
|
||||
"version": "0.8.28",
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
"exports": {
|
||||
|
||||
@@ -12,6 +12,8 @@ import type { Middleware, Mode, SecurityConfig, SeoConfig } from "@wrnexus/core"
|
||||
import { buildRouter, type Router } from "@wrnexus/router";
|
||||
import {
|
||||
resolveThemeConfig,
|
||||
resolveBrowserCookieOptions,
|
||||
type BrowserCookiesConfig,
|
||||
type StylesConfig,
|
||||
type ThemeConfig,
|
||||
type MobileConfig,
|
||||
@@ -101,6 +103,8 @@ export interface ServeOptions {
|
||||
security?: SecurityConfig;
|
||||
/** Design-token theme config (merged over the built-in light/dark). */
|
||||
theme?: ThemeConfig;
|
||||
/** Shared browser-cookie defaults and preference-specific overrides. */
|
||||
cookies?: BrowserCookiesConfig;
|
||||
/** i18n config (default language + supported locales). */
|
||||
i18n?: I18nConfig;
|
||||
/** Default database connection (driver + url). Enables `getDb()` and dev auto-migrate. */
|
||||
@@ -355,7 +359,7 @@ export async function startServer(opts: ServeOptions): Promise<RunningServer> {
|
||||
// Compile every `.wrn` into ONE cache dir at the project root, instead of a
|
||||
// `.wrnexus/` next to each source file (and inside node_modules UI dirs).
|
||||
setCompileCacheDir(cacheDir);
|
||||
const theme = resolveThemeConfig(opts.theme);
|
||||
const theme = resolveThemeConfig(opts.theme, opts.cookies);
|
||||
const uiStylesPath = uiCssPath();
|
||||
|
||||
const schemasJs = await schemaRuntime(router);
|
||||
@@ -375,8 +379,17 @@ export async function startServer(opts: ServeOptions): Promise<RunningServer> {
|
||||
|
||||
// i18n is opt-in by the presence of app/locales/*.json.
|
||||
const localeMessages = loadLocales(join(appDir, "locales"), { strict: opts.i18n?.strict });
|
||||
const i18nConfig = opts.i18n
|
||||
? {
|
||||
...opts.i18n,
|
||||
cookie: {
|
||||
...resolveBrowserCookieOptions(opts.cookies, "language"),
|
||||
...(opts.i18n.cookie ?? {}),
|
||||
},
|
||||
}
|
||||
: undefined;
|
||||
const i18n = Object.keys(localeMessages).length
|
||||
? resolveI18n(localeMessages, opts.i18n)
|
||||
? resolveI18n(localeMessages, i18nConfig)
|
||||
: undefined;
|
||||
|
||||
// Databases: configure the default (getDb()) + each named one (getDb("<name>")),
|
||||
|
||||
@@ -54,6 +54,7 @@ const server = await startServer({
|
||||
seo: config.seo,
|
||||
security: config.security,
|
||||
theme: config.theme,
|
||||
cookies: config.cookies,
|
||||
i18n: config.i18n,
|
||||
db: config.db,
|
||||
databases: config.databases,
|
||||
|
||||
Reference in New Issue
Block a user