forked from lunanting/cangku
Allow PDD production startup without optional image-search integrations
This commit is contained in:
parent
ec8949cfbf
commit
f182ec962a
@ -55,7 +55,7 @@ LOCAL_DB_QUERY_TIMEOUT_MS=60000
|
||||
# 生产环境由部署脚本强制使用 /www/wwwroot/shujuku3/shared/image-search-secrets.json
|
||||
# 本地留空时使用 ~/.config/shujuku3/secrets.json
|
||||
SHUJUKU3_SECRET_STORE_PATH=
|
||||
# 生产环境默认开启;公司图搜或 1688 图搜凭据缺失时拒绝启动
|
||||
# 可选:设为 true 时要求公司图搜和 1688 图搜凭据齐全
|
||||
REQUIRE_PERSISTED_IMAGE_SEARCH_SECRETS=false
|
||||
# 系统库连接池建议保持小而稳,避免单个应用实例吃满 MySQL 连接
|
||||
LOCAL_DB_CONNECTION_LIMIT=6
|
||||
|
||||
@ -4,7 +4,7 @@ const { getAlibaba1688ImageSearchRuntimeConfig } = require('./alibaba1688ImageSe
|
||||
const { getSimilarProductsRuntimeConfig } = require('./similarProductsSettings');
|
||||
|
||||
function shouldRequireImageSearchCredentials() {
|
||||
if (String(process.env.NODE_ENV || '').trim().toLowerCase() === 'production') return true;
|
||||
// Image search is an optional integration in the PDD edition.
|
||||
const configured = String(process.env.REQUIRE_PERSISTED_IMAGE_SEARCH_SECRETS || '').trim().toLowerCase();
|
||||
return configured === 'true' || configured === '1';
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@ const assert = require('node:assert/strict');
|
||||
|
||||
const { shouldRequireImageSearchCredentials } = require('../src/services/imageSearchCredentialGuard');
|
||||
|
||||
test('production requires persisted image-search credentials by default', (context) => {
|
||||
test('optional image search never blocks production unless explicitly required', (context) => {
|
||||
const previousNodeEnv = process.env.NODE_ENV;
|
||||
const previousRequirement = process.env.REQUIRE_PERSISTED_IMAGE_SEARCH_SECRETS;
|
||||
context.after(() => {
|
||||
@ -17,9 +17,9 @@ test('production requires persisted image-search credentials by default', (conte
|
||||
|
||||
process.env.NODE_ENV = 'production';
|
||||
delete process.env.REQUIRE_PERSISTED_IMAGE_SEARCH_SECRETS;
|
||||
assert.equal(shouldRequireImageSearchCredentials(), true);
|
||||
assert.equal(shouldRequireImageSearchCredentials(), false);
|
||||
process.env.REQUIRE_PERSISTED_IMAGE_SEARCH_SECRETS = 'false';
|
||||
assert.equal(shouldRequireImageSearchCredentials(), true);
|
||||
assert.equal(shouldRequireImageSearchCredentials(), false);
|
||||
|
||||
process.env.NODE_ENV = 'development';
|
||||
delete process.env.REQUIRE_PERSISTED_IMAGE_SEARCH_SECRETS;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user