fix(api): seed empty system settings from env including Tencent LBS key
CI / verify (pull_request) Has been cancelled
CI / verify (pull_request) Has been cancelled
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -184,16 +184,22 @@ export class SystemConfigService implements OnModuleInit {
|
|||||||
|
|
||||||
async importFromProcessEnv(): Promise<{ imported: number }> {
|
async importFromProcessEnv(): Promise<{ imported: number }> {
|
||||||
let imported = 0;
|
let imported = 0;
|
||||||
|
const overlay: Record<string, string> = {};
|
||||||
for (const field of SYSTEM_CONFIG_FIELDS) {
|
for (const field of SYSTEM_CONFIG_FIELDS) {
|
||||||
const envVal = process.env[field.key];
|
const envVal = process.env[field.key];
|
||||||
if (envVal === undefined || envVal === '') continue;
|
if (envVal === undefined || envVal === '') continue;
|
||||||
|
const normalized = this.normalizeByMeta(field, envVal);
|
||||||
const existing = await this.prisma.systemConfig.findUnique({ where: { configKey: field.key } });
|
const existing = await this.prisma.systemConfig.findUnique({ where: { configKey: field.key } });
|
||||||
if (existing) continue;
|
if (existing?.value?.trim()) continue;
|
||||||
await this.prisma.systemConfig.create({
|
await this.prisma.systemConfig.upsert({
|
||||||
data: { configKey: field.key, value: this.normalizeByMeta(field, envVal) },
|
where: { configKey: field.key },
|
||||||
|
create: { configKey: field.key, value: normalized },
|
||||||
|
update: { value: normalized },
|
||||||
});
|
});
|
||||||
|
overlay[field.key] = normalized;
|
||||||
imported += 1;
|
imported += 1;
|
||||||
}
|
}
|
||||||
|
if (imported) applyEnvOverlay(overlay);
|
||||||
await this.onModuleInit();
|
await this.onModuleInit();
|
||||||
return { imported };
|
return { imported };
|
||||||
}
|
}
|
||||||
@@ -208,12 +214,15 @@ export class SystemConfigService implements OnModuleInit {
|
|||||||
|
|
||||||
private async seedMissingFromProcessEnv() {
|
private async seedMissingFromProcessEnv() {
|
||||||
for (const field of SYSTEM_CONFIG_FIELDS) {
|
for (const field of SYSTEM_CONFIG_FIELDS) {
|
||||||
const existing = await this.prisma.systemConfig.findUnique({ where: { configKey: field.key } });
|
|
||||||
if (existing) continue;
|
|
||||||
const envVal = process.env[field.key];
|
const envVal = process.env[field.key];
|
||||||
if (envVal === undefined || envVal === '') continue;
|
if (envVal === undefined || envVal === '') continue;
|
||||||
await this.prisma.systemConfig.create({
|
const existing = await this.prisma.systemConfig.findUnique({ where: { configKey: field.key } });
|
||||||
data: { configKey: field.key, value: this.normalizeByMeta(field, envVal) },
|
if (existing?.value?.trim()) continue;
|
||||||
|
const value = this.normalizeByMeta(field, envVal);
|
||||||
|
await this.prisma.systemConfig.upsert({
|
||||||
|
where: { configKey: field.key },
|
||||||
|
create: { configKey: field.key, value },
|
||||||
|
update: { value },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user