fix(server): config defaults (#11879)

This commit is contained in:
forehalo
2025-04-22 04:26:28 +00:00
parent a1e338efc1
commit f918573ba8
6 changed files with 46 additions and 9 deletions
@@ -57,6 +57,10 @@ function typeFromShape(shape: z.ZodType<any>): ConfigType {
return 'array';
case z.ZodObject:
return 'object';
case z.ZodOptional:
case z.ZodNullable:
// @ts-expect-error checked
return typeFromShape(shape.unwrap());
default:
return 'any';
}
@@ -251,6 +255,14 @@ export function override(config: AppConfig, update: DeepPartial<AppConfig>) {
return right;
}
// EDGE CASE:
// the right value is primitive and we're still not finding the key in descriptors,
// which means the overrides has keys not defined
// that's where we should return
if (typeof right !== 'object') {
return left;
}
// go deeper
return mergeWith(left, right, (left, right, key) => {
return merge(left, right, path === '' ? key : `${path}.${key}`);