refactor: dedup dead code, shared utils, conditional headers helper

- Extract shared utils: asSafeChunkSize (validation.ts), S3 detection (s3-detection.ts)
- Remove dead _handleMaybeS3Root from index.ts and routes/index.ts
- Remove dead _asArray from file-controller.ts
- Consolidate maybeCompressChunk into shared compress.ts
- Extract checkConditionalHeaders helper, remove ~120 lines dupe in s3-controller
- Remove 500+ lines dead code from s3-object.ts (unused use cases + helpers)
- Delegate upload-file.ts chunked path to ChunkedStorage, remove dupe
- Fix broken dynamic import in file-controller.ts → proper DI
- Fix test/files.test.ts import path and mocks

[skip ci]
This commit is contained in:
Claude
2026-07-29 16:39:52 +07:00
parent fab91ad69c
commit ad917f6675
10 changed files with 316 additions and 1100 deletions
+13
View File
@@ -0,0 +1,13 @@
/**
* Validates a chunk size value and returns it as a safe integer.
*
* @param chunkSizeBytes - The desired chunk size in bytes.
* @returns The same value if it is a positive safe integer.
* @throws {Error} If the chunk size is not a safe positive integer.
*/
export const asSafeChunkSize = (chunkSizeBytes: number): number => {
if (!Number.isSafeInteger(chunkSizeBytes) || chunkSizeBytes <= 0) {
throw new Error('Invalid Telegram chunk size');
}
return chunkSizeBytes;
};