fix: mark ChunkedUploadService constructor params @Optional
Nest tried to resolve String/Number/Function as DI tokens and the api crashed at bootstrap.
This commit is contained in:
parent
93edeab5ca
commit
4cbb63920a
1 changed files with 4 additions and 4 deletions
|
|
@ -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).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue