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>
21 lines
734 B
TypeScript
21 lines
734 B
TypeScript
import { z } from "zod";
|
|
import { InputParseError } from "../../entities/errors/common";
|
|
import type { Media } from "../../entities/models/media";
|
|
import type { IGetMediaUseCase } from "../../application/use-cases/get-media.use-case";
|
|
|
|
const inputSchema = z.object({
|
|
id: z.string().min(1),
|
|
});
|
|
|
|
export type IGetMediaController = ReturnType<typeof getMediaController>;
|
|
|
|
export const getMediaController =
|
|
(getMediaUseCase: IGetMediaUseCase) =>
|
|
async (input: Partial<z.infer<typeof inputSchema>>): Promise<Media> => {
|
|
const parsed = inputSchema.safeParse(input);
|
|
if (!parsed.success) {
|
|
throw new InputParseError("Invalid get-media input", { cause: parsed.error });
|
|
}
|
|
return getMediaUseCase(parsed.data);
|
|
};
|