重构后台管理服务并推进渐进式类型化

This commit is contained in:
yml2213
2026-04-14 09:21:20 +08:00
parent fa36be6539
commit 335eb44104
35 changed files with 4143 additions and 2738 deletions
+9 -2
View File
@@ -1,9 +1,14 @@
// @ts-check
import fs from 'node:fs'
import path from 'node:path'
import process from 'node:process'
import { createRequire } from 'node:module'
import { fileURLToPath } from 'node:url'
/** @typedef {import('../types/runtime-config.js').AgisoMessagingShopsConfig} AgisoMessagingShopsConfig */
/** @typedef {import('../types/runtime-config.js').RuntimeConfig} RuntimeConfig */
const require = createRequire(import.meta.url)
const CURRENT_DIR = path.dirname(fileURLToPath(import.meta.url))
export const PROJECT_ROOT = path.resolve(CURRENT_DIR, '../..')
@@ -15,9 +20,9 @@ loadEnvFiles([
path.join(PROJECT_ROOT, '.env'),
])
const defaultConfig = loadConfig(path.join(CONFIG_ROOT, 'default.cjs'))
const defaultConfig = /** @type {RuntimeConfig} */ (loadConfig(path.join(CONFIG_ROOT, 'default.cjs')))
export const runtimeConfig = applyEnvOverrides(defaultConfig)
export const runtimeConfig = /** @type {RuntimeConfig} */ (applyEnvOverrides(defaultConfig))
function loadConfig(configPath) {
if (!fs.existsSync(configPath)) {
@@ -381,6 +386,7 @@ function parseJsonArray(rawValue) {
}
function normalizeAgisoMessagingShops(rawValue) {
/** @type {AgisoMessagingShopsConfig} */
const output = {}
for (const [shopId, config] of Object.entries(rawValue || {})) {
@@ -389,6 +395,7 @@ function normalizeAgisoMessagingShops(rawValue) {
continue
}
/** @type {AgisoMessagingShopsConfig[string]} */
const next = {}
const enabled = normalizeBooleanLike(config.enabled)
if (enabled !== null) {