feat(media): full Clean Architecture scaffold
Media is now a complete vertical-feature package mirroring auth/blog structure: entities (models + errors), application (repositories + use-cases), infrastructure (real Payload-backed + mock siblings), interface-adapters (per-use-case controllers), DI (symbols + module + container + bind-production), integrations/api (mediaRouter), factory, contract suite, and feature integration tests. Wired into: - packages/core-api/src/root.ts (added `media: mediaRouter`) - apps/web-next/src/server/bind-production.ts (calls bindProductionMedia) - tsconfig.base.json (added @repo/media/api and ./di/bind-production aliases) 56 new tests in @repo/media (13 test files); core-api router test updated to assert media. procedures. All 26 turbo tasks green. Refactor log: §2, §4.1, §4.2, §5.1, §6.1 Spec: §6.5 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2
packages/media/src/integrations/api/index.ts
Normal file
2
packages/media/src/integrations/api/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export { mediaRouter } from "./router";
|
||||
export type { MediaRouter } from "./router";
|
||||
45
packages/media/src/integrations/api/router.ts
Normal file
45
packages/media/src/integrations/api/router.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { z } from "zod";
|
||||
import { router, publicProcedure } from "@repo/core-shared/trpc/init";
|
||||
import { mediaContainer } from "../../di/container";
|
||||
import { MEDIA_SYMBOLS } from "../../di/symbols";
|
||||
import type { IGetMediaController } from "../../interface-adapters/controllers/get-media.controller";
|
||||
import type { IListMediaController } from "../../interface-adapters/controllers/list-media.controller";
|
||||
import type { IDeleteMediaController } from "../../interface-adapters/controllers/delete-media.controller";
|
||||
|
||||
export const mediaRouter = router({
|
||||
getMedia: publicProcedure
|
||||
.input(z.object({ id: z.string().min(1) }))
|
||||
.query(({ input }) => {
|
||||
const ctrl = mediaContainer.get<IGetMediaController>(
|
||||
MEDIA_SYMBOLS.IGetMediaController,
|
||||
);
|
||||
return ctrl(input);
|
||||
}),
|
||||
|
||||
listMedia: publicProcedure
|
||||
.input(
|
||||
z
|
||||
.object({
|
||||
limit: z.number().optional(),
|
||||
offset: z.number().optional(),
|
||||
})
|
||||
.optional(),
|
||||
)
|
||||
.query(({ input }) => {
|
||||
const ctrl = mediaContainer.get<IListMediaController>(
|
||||
MEDIA_SYMBOLS.IListMediaController,
|
||||
);
|
||||
return ctrl(input ?? {});
|
||||
}),
|
||||
|
||||
deleteMedia: publicProcedure
|
||||
.input(z.object({ id: z.string().min(1) }))
|
||||
.mutation(({ input }) => {
|
||||
const ctrl = mediaContainer.get<IDeleteMediaController>(
|
||||
MEDIA_SYMBOLS.IDeleteMediaController,
|
||||
);
|
||||
return ctrl(input);
|
||||
}),
|
||||
});
|
||||
|
||||
export type MediaRouter = typeof mediaRouter;
|
||||
Reference in New Issue
Block a user