refactor(blog): factory-style use cases + per-use-case controllers + getArticleBySlug

- Use cases (create-article, get-articles, get-article-by-slug NEW) → factory functions
- Controllers split: articles.controller.ts → 3 single-responsibility files
- DI module wires factories with .toDynamicValue()
- tRPC router resolves controllers via container

Refactor log: §2, §3, §4.1, §4.2, §5.1
Spec: §6.2

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-06 00:08:15 +02:00
parent 780d5cb83b
commit 700d311052
21 changed files with 488 additions and 302 deletions

View File

@@ -22,15 +22,18 @@ describe("blogContainer", () => {
expect(repo).toBeInstanceOf(MockArticlesRepository);
});
it("supports rebinding to a custom repo", () => {
blogContainer.unbind(BLOG_SYMBOLS.IArticlesRepository);
const custom = new MockArticlesRepository();
blogContainer
.bind<IArticlesRepository>(BLOG_SYMBOLS.IArticlesRepository)
.toConstantValue(custom);
const resolved = blogContainer.get<IArticlesRepository>(
BLOG_SYMBOLS.IArticlesRepository,
);
expect(resolved).toBe(custom);
it("resolves IGetArticlesController from the container", () => {
const ctrl = blogContainer.get(BLOG_SYMBOLS.IGetArticlesController);
expect(typeof ctrl).toBe("function");
});
it("resolves ICreateArticleController from the container", () => {
const ctrl = blogContainer.get(BLOG_SYMBOLS.ICreateArticleController);
expect(typeof ctrl).toBe("function");
});
it("resolves IGetArticleBySlugController from the container", () => {
const ctrl = blogContainer.get(BLOG_SYMBOLS.IGetArticleBySlugController);
expect(typeof ctrl).toBe("function");
});
});