feat: add app_config table with runtime log level control and POS structured logging
All checks were successful
CI / ci (pull_request) Successful in 20s
CI / e2e (pull_request) Successful in 56s

- New app_config key-value table for system settings, with in-memory cache (mirrors ModuleService pattern)
- GET/PATCH /v1/config endpoints for reading and updating config (settings.view/settings.edit permissions)
- Runtime log level: PATCH /v1/config/log_level applies immediately, persists across restarts
- Startup loads log level from DB in onReady hook (env var is default, DB overrides)
- Add structured request.log.info() to POS routes: transaction create/complete/void, drawer open/close, discount create/update/delete

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
ryan
2026-04-04 18:56:21 +00:00
parent 51e7902ee2
commit 772d5578ad
11 changed files with 154 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
CREATE TABLE IF NOT EXISTS "app_config" (
"key" varchar(100) PRIMARY KEY NOT NULL,
"value" text,
"description" text,
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
);
-- Seed default log level
INSERT INTO "app_config" ("key", "value", "description")
VALUES ('log_level', 'info', 'Application log level (fatal, error, warn, info, debug, trace)')
ON CONFLICT ("key") DO NOTHING;

View File

@@ -281,6 +281,13 @@
"when": 1775408000000,
"tag": "0039_cash-rounding",
"breakpoints": true
},
{
"idx": 40,
"version": "7",
"when": 1775494000000,
"tag": "0040_app-config",
"breakpoints": true
}
]
}

View File

@@ -38,7 +38,16 @@ export const locations = pgTable('location', {
updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
})
export const appConfig = pgTable('app_config', {
key: varchar('key', { length: 100 }).primaryKey(),
value: text('value'),
description: text('description'),
updatedAt: timestamp('updated_at', { withTimezone: true }).notNull().defaultNow(),
})
export type Company = typeof companies.$inferSelect
export type CompanyInsert = typeof companies.$inferInsert
export type Location = typeof locations.$inferSelect
export type LocationInsert = typeof locations.$inferInsert
export type AppConfig = typeof appConfig.$inferSelect
export type AppConfigInsert = typeof appConfig.$inferInsert