mirror of
https://github.com/nicotsx/zerobyte.git
synced 2025-12-10 12:10:51 +01:00
refactor: unify backend and frontend servers (#3)
* refactor: unify backend and frontend servers * refactor: correct paths for openapi & drizzle * refactor: move api-client to client * fix: drizzle paths * chore: fix linting issues * fix: form reset issue
This commit is contained in:
14
app/utils/object.ts
Normal file
14
app/utils/object.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
export function deepClean<T>(obj: T): T {
|
||||
if (Array.isArray(obj)) {
|
||||
return obj.map(deepClean).filter((v) => v !== undefined && v !== null && v !== "") as T;
|
||||
}
|
||||
|
||||
if (obj && typeof obj === "object") {
|
||||
return Object.entries(obj).reduce((acc, [key, value]) => {
|
||||
const cleaned = deepClean(value);
|
||||
if (cleaned !== undefined && cleaned !== "") acc[key as keyof T] = cleaned;
|
||||
return acc;
|
||||
}, {} as T);
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
Reference in New Issue
Block a user