接入多发货平台与电子凭证
This commit is contained in:
@@ -57,6 +57,14 @@ export function createDefaultRuntimeConfig(projectRoot: string): RuntimeConfig {
|
||||
shopName: "快手行业电子凭证",
|
||||
version: "1",
|
||||
},
|
||||
kuaishouFeifei: {
|
||||
baseUrl: "http://skin-exchange.yiquyou.icu",
|
||||
appKey: "",
|
||||
appSecret: "",
|
||||
timeoutMs: 10000,
|
||||
notifyUrl: "",
|
||||
productRules: [],
|
||||
},
|
||||
cloudtentacles: {
|
||||
baseUrl: "https://123.207.217.176",
|
||||
timeoutMs: 5000,
|
||||
|
||||
@@ -20,6 +20,7 @@ const DEPLOYMENT_ONLY_ENV_NAMES = [
|
||||
'BACKEND_PORT',
|
||||
'CADDY_SITE_ADDR',
|
||||
'CHOKIDAR_USEPOLLING',
|
||||
'KUASHOU_INDUSTRY_RATE_LIMIT_MAX',
|
||||
'NPM_CONFIG_REGISTRY',
|
||||
'POSTGRES_DB',
|
||||
'POSTGRES_PASSWORD',
|
||||
|
||||
@@ -3,6 +3,7 @@ import process from "node:process";
|
||||
|
||||
import type {
|
||||
AdminDefaultUser,
|
||||
KuaishouFeifeiProductRule,
|
||||
RuntimeConfig,
|
||||
} from "../types/runtime-config.js";
|
||||
import {
|
||||
@@ -18,6 +19,7 @@ type RuntimeConfigValue =
|
||||
| number
|
||||
| boolean
|
||||
| AdminDefaultUser[]
|
||||
| KuaishouFeifeiProductRule[]
|
||||
| string[];
|
||||
type RuntimeEnv = Record<string, string | undefined>;
|
||||
|
||||
@@ -274,6 +276,36 @@ export const ENV_OVERRIDES: readonly EnvOverride[] = [
|
||||
"kuaishouIndustry",
|
||||
"version",
|
||||
]),
|
||||
stringEnv("KUAISHOU_FEIFEI_BASE_URL", [
|
||||
"platforms",
|
||||
"kuaishouFeifei",
|
||||
"baseUrl",
|
||||
]),
|
||||
stringEnv("KUAISHOU_FEIFEI_APP_KEY", [
|
||||
"platforms",
|
||||
"kuaishouFeifei",
|
||||
"appKey",
|
||||
]),
|
||||
stringEnv("KUAISHOU_FEIFEI_APP_SECRET", [
|
||||
"platforms",
|
||||
"kuaishouFeifei",
|
||||
"appSecret",
|
||||
]),
|
||||
integerEnv("KUAISHOU_FEIFEI_TIMEOUT_MS", [
|
||||
"platforms",
|
||||
"kuaishouFeifei",
|
||||
"timeoutMs",
|
||||
]),
|
||||
stringEnv("KUAISHOU_FEIFEI_NOTIFY_URL", [
|
||||
"platforms",
|
||||
"kuaishouFeifei",
|
||||
"notifyUrl",
|
||||
]),
|
||||
kuaishouFeifeiProductRulesEnv("KUAISHOU_FEIFEI_PRODUCT_RULES_JSON", [
|
||||
"platforms",
|
||||
"kuaishouFeifei",
|
||||
"productRules",
|
||||
]),
|
||||
corsOriginsEnv("CORS_ALLOWED_ORIGINS", ["cors", "allowedOrigins"]),
|
||||
];
|
||||
|
||||
@@ -355,6 +387,20 @@ function adminUsersJsonEnv(
|
||||
};
|
||||
}
|
||||
|
||||
function kuaishouFeifeiProductRulesEnv(
|
||||
env: string,
|
||||
configPath: RuntimeConfigPath
|
||||
): EnvOverride {
|
||||
return {
|
||||
env,
|
||||
path: configPath,
|
||||
read(rawValue) {
|
||||
const parsed = parseJsonArray<KuaishouFeifeiProductRule>(rawValue);
|
||||
return parsed === null ? null : parsed;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function corsOriginsEnv(
|
||||
env: string,
|
||||
configPath: RuntimeConfigPath
|
||||
|
||||
@@ -48,6 +48,9 @@ export function validateRuntimeConfig(
|
||||
requireInteger(issues, 'orders.tokenTtlHours', config.orders?.tokenTtlHours, { min: 1 })
|
||||
requireInteger(issues, 'admin.sessionTtlHours', config.admin?.sessionTtlHours, { min: 1 })
|
||||
requireInteger(issues, 'platforms.cloudtentacles.timeoutMs', config.platforms?.cloudtentacles?.timeoutMs, { min: 1 })
|
||||
if (config.platforms?.kuaishouFeifei) {
|
||||
requireInteger(issues, 'platforms.kuaishouFeifei.timeoutMs', config.platforms.kuaishouFeifei.timeoutMs, { min: 1 })
|
||||
}
|
||||
requireInteger(issues, 'platforms.cloudtentacles.bindUrlTtlSeconds', config.platforms?.cloudtentacles?.bindUrlTtlSeconds, { min: 1 })
|
||||
requireInteger(
|
||||
issues,
|
||||
|
||||
Reference in New Issue
Block a user