From 4cbb63920ac9cc052ebddd49ce7b19b11091d35d Mon Sep 17 00:00:00 2001 From: glass beadian Date: Thu, 15 Oct 2026 22:48:40 +0000 Subject: [PATCH] fix: mark ChunkedUploadService constructor params @Optional Nest tried to resolve String/Number/Function as DI tokens and the api crashed at bootstrap. --- apps/api/src/video/chunked-upload.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/api/src/video/chunked-upload.ts b/apps/api/src/video/chunked-upload.ts index 00bbadc..69fdcfe 100644 --- a/apps/api/src/video/chunked-upload.ts +++ b/apps/api/src/video/chunked-upload.ts @@ -2,7 +2,7 @@ import { randomUUID } from "node:crypto"; import { mkdir, open, rm, stat } from "node:fs/promises"; import { join } from "node:path"; import { tmpdir } from "node:os"; -import { BadRequestException, ConflictException, Injectable, NotFoundException, OnModuleDestroy } from "@nestjs/common"; +import { BadRequestException, ConflictException, Injectable, NotFoundException, OnModuleDestroy, Optional } from "@nestjs/common"; import { CHUNK_SIZE_BYTES, CHUNKED_UPLOAD_TTL_MS, @@ -99,9 +99,9 @@ export class ChunkedUploadService implements OnModuleDestroy { private sweeper: NodeJS.Timeout | undefined; constructor( - private readonly directory: string = process.env.SP_CHUNK_UPLOAD_DIR ?? join(tmpdir(), "uploads"), - private readonly sweeperIntervalMs: number = 30 * 60 * 1000, - private readonly generateId: () => string = randomUUID, + @Optional() private readonly directory: string = process.env.SP_CHUNK_UPLOAD_DIR ?? join(tmpdir(), "uploads"), + @Optional() private readonly sweeperIntervalMs: number = 30 * 60 * 1000, + @Optional() private readonly generateId: () => string = randomUUID, ) { // Only arm the sweeper when running under a live event loop (not unit tests // that construct the service directly and would hold the process open).