refactor: full codebase audit — extract modules, fix type safety, clean dead code

- Extract API helpers from UploadZone into lib/upload-api.ts (FormData builder, checkFolderDiffs, uploadDrive, uploadGit)
- Extract upload orchestration into hooks/useUploadOrchestrator.ts (UploadZone: 489 → 162 lines)
- Extract file diff classification into lib/diff-files.ts (from git route)
- Extract shared SVG icons into components/ui/icons.tsx (7 icons, 0 duplication)
- Extract shared modal wrapper into components/ui/Modal.tsx + ModalActions
- Extract DriveStatusLine sub-component from FolderCard
- Fix checkFolderDiffs silently swallowing auth/network errors (now throws)
- Fix type safety: remove as never casts, add isHttpError type guard, use discriminated union for validateFolder
- Fix nextcloud: cache getConfig, add max bound to findNextVersion, optimize mkdirRecursive (skip PROPFIND)
- Fix drive route: remove req.clone(), extend parseMultiUpload to return extra fields
- Fix commit message: model shown as unchanged with ↔️ on updates (not falsely marked as modified)
- Clean dead code: unused folderExists import, FileStatus/DriveStatus exports, ParsedFile.textureName, getConfig basePath
- Add security headers in next.config.ts (HSTS, X-Content-Type-Options, X-Frame-Options, etc.)
- Update README with new project structure
This commit is contained in:
Tom Boullay
2026-04-14 17:19:10 +02:00
parent 110d64ec33
commit 78f4aa83e0
26 changed files with 957 additions and 721 deletions
+5 -16
View File
@@ -1,5 +1,6 @@
import type { FolderEntry } from '@/lib/client-types'
import { validateFolder } from '@/lib/validate-folder'
import { FolderIcon } from '@/components/ui/icons'
interface FolderDropzoneProps {
isUploading: boolean
@@ -20,19 +21,19 @@ export default function FolderDropzone({
const folderName = fileArray[0].webkitRelativePath?.split('/')[0] || 'folder'
const validation = validateFolder(fileArray)
if (validation.errors.length > 0) {
if (!validation.ok) {
onError(validation.errors.join(' | '))
return
}
const entry: FolderEntry = {
folderName,
modelFile: validation.model!,
modelFile: validation.model,
textures: validation.textures,
status: 'pending',
progress: 0,
warnings: validation.warnings,
modelUrl: URL.createObjectURL(validation.model!),
modelUrl: URL.createObjectURL(validation.model),
viewerOpen: true,
}
onFolderSelected(entry)
@@ -59,19 +60,7 @@ export default function FolderDropzone({
>
<div className="flex justify-center mb-3">
<div className="w-12 h-12 rounded-full flex items-center justify-center bg-black-700">
<svg
className="w-6 h-6 text-gray-400"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
strokeWidth={1.5}
>
<path
strokeLinecap="round"
strokeLinejoin="round"
d="M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"
/>
</svg>
<FolderIcon className="w-6 h-6 text-gray-400" />
</div>
</div>
<p className="text-sm font-medium text-gray-300">