refactor: 拆分媒体上传职责并锁定API路由
This commit is contained in:
1 parent
6f18c67315
commit
2ad009f5c0
8 files changed
+375
-171
No files matched your search
@@ -5,7 +5,7 @@ import path from "node:path";
|
||||
import test from "node:test";
|
||||
|
||||
test("upload presign DTO rejects unsupported media type and oversized names", async () => {
|
||||
const { PresignUploadDto } = await import("../dist/modules/admin/admin-upload.controller.js");
|
||||
const { PresignUploadDto } = await import("../dist/modules/admin/admin-upload.dto.js");
|
||||
const validator = await import("class-validator");
|
||||
const invalid = new PresignUploadDto();
|
||||
invalid.fileName = "x".repeat(256);
|
||||
@@ -23,6 +23,7 @@ test("upload presign DTO rejects unsupported media type and oversized names", as
|
||||
test("local upload presign targets the API route and requires brand access", async () => {
|
||||
const { AdminUploadController } =
|
||||
await import("../dist/modules/admin/admin-upload.controller.js");
|
||||
const { AdminUploadService } = await import("../dist/modules/admin/admin-upload.service.js");
|
||||
const mediaRoot = await mkdtemp(path.join(os.tmpdir(), "personal-brand-upload-"));
|
||||
const previousRoot = process.env.LOCAL_MEDIA_ROOT;
|
||||
const previousBucket = process.env.OBJECT_STORAGE_BUCKET;
|
||||
@@ -34,7 +35,7 @@ test("local upload presign targets the API route and requires brand access", asy
|
||||
delete process.env.OBJECT_STORAGE_ACCESS_KEY;
|
||||
delete process.env.OBJECT_STORAGE_SECRET_KEY;
|
||||
try {
|
||||
const controller = new AdminUploadController(access);
|
||||
const controller = new AdminUploadController(access, new AdminUploadService());
|
||||
const result = await controller.presign(
|
||||
{},
|
||||
{ fileName: "portrait.jpg", contentType: "image/jpeg" },
|
||||
|
||||
Reference in new issue
Block a user