feat(core-api): compose @repo/blog/api into appRouter under 'blog' namespace
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import type { Article } from "@/entities/article";
|
import type { Article } from "../../entities/article";
|
||||||
|
|
||||||
export interface IArticlesRepository {
|
export interface IArticlesRepository {
|
||||||
getArticle(id: string): Promise<Article | undefined>;
|
getArticle(id: string): Promise<Article | undefined>;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { beforeEach, describe, expect, it } from "vitest";
|
import { beforeEach, describe, expect, it } from "vitest";
|
||||||
import { blogContainer } from "@/di/container";
|
import { blogContainer } from "../../di/container";
|
||||||
import { BLOG_SYMBOLS } from "@/di/symbols";
|
import { BLOG_SYMBOLS } from "../../di/symbols";
|
||||||
import type { IArticlesRepository } from "@/application/repositories/articles-repository.interface";
|
import type { IArticlesRepository } from "../../application/repositories/articles-repository.interface";
|
||||||
import { MockArticlesRepository } from "@/infrastructure/repositories/mock-articles.repository";
|
import { MockArticlesRepository } from "../../infrastructure/repositories/mock-articles.repository";
|
||||||
import { createArticleUseCase } from "./create-article.use-case";
|
import { createArticleUseCase } from "./create-article.use-case";
|
||||||
|
|
||||||
describe("createArticleUseCase", () => {
|
describe("createArticleUseCase", () => {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import type { Article } from "@/entities/article";
|
import type { Article } from "../../entities/article";
|
||||||
import { blogContainer } from "@/di/container";
|
import { blogContainer } from "../../di/container";
|
||||||
import { BLOG_SYMBOLS } from "@/di/symbols";
|
import { BLOG_SYMBOLS } from "../../di/symbols";
|
||||||
import type { IArticlesRepository } from "@/application/repositories/articles-repository.interface";
|
import type { IArticlesRepository } from "../repositories/articles-repository.interface";
|
||||||
|
|
||||||
function generateSlug(title: string): string {
|
function generateSlug(title: string): string {
|
||||||
return title
|
return title
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { beforeEach, describe, expect, it } from "vitest";
|
import { beforeEach, describe, expect, it } from "vitest";
|
||||||
import { blogContainer } from "@/di/container";
|
import { blogContainer } from "../../di/container";
|
||||||
import { BLOG_SYMBOLS } from "@/di/symbols";
|
import { BLOG_SYMBOLS } from "../../di/symbols";
|
||||||
import type { IArticlesRepository } from "@/application/repositories/articles-repository.interface";
|
import type { IArticlesRepository } from "../../application/repositories/articles-repository.interface";
|
||||||
import { MockArticlesRepository } from "@/infrastructure/repositories/mock-articles.repository";
|
import { MockArticlesRepository } from "../../infrastructure/repositories/mock-articles.repository";
|
||||||
import { getArticlesUseCase } from "./get-articles.use-case";
|
import { getArticlesUseCase } from "./get-articles.use-case";
|
||||||
|
|
||||||
describe("getArticlesUseCase", () => {
|
describe("getArticlesUseCase", () => {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import type { Article } from "@/entities/article";
|
import type { Article } from "../../entities/article";
|
||||||
import { blogContainer } from "@/di/container";
|
import { blogContainer } from "../../di/container";
|
||||||
import { BLOG_SYMBOLS } from "@/di/symbols";
|
import { BLOG_SYMBOLS } from "../../di/symbols";
|
||||||
import type { IArticlesRepository } from "@/application/repositories/articles-repository.interface";
|
import type { IArticlesRepository } from "../repositories/articles-repository.interface";
|
||||||
|
|
||||||
export async function getArticlesUseCase(options?: {
|
export async function getArticlesUseCase(options?: {
|
||||||
status?: string;
|
status?: string;
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|||||||
import { blogContainer } from "./container";
|
import { blogContainer } from "./container";
|
||||||
import { BLOG_SYMBOLS } from "./symbols";
|
import { BLOG_SYMBOLS } from "./symbols";
|
||||||
import { BlogModule } from "./module";
|
import { BlogModule } from "./module";
|
||||||
import { MockArticlesRepository } from "@/infrastructure/repositories/mock-articles.repository";
|
import { MockArticlesRepository } from "../infrastructure/repositories/mock-articles.repository";
|
||||||
import type { IArticlesRepository } from "@/application/repositories/articles-repository.interface";
|
import type { IArticlesRepository } from "../application/repositories/articles-repository.interface";
|
||||||
|
|
||||||
describe("blogContainer", () => {
|
describe("blogContainer", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { ContainerModule, type interfaces } from "inversify";
|
import { ContainerModule, type interfaces } from "inversify";
|
||||||
|
|
||||||
import type { IArticlesRepository } from "@/application/repositories/articles-repository.interface";
|
import type { IArticlesRepository } from "../application/repositories/articles-repository.interface";
|
||||||
import { MockArticlesRepository } from "@/infrastructure/repositories/mock-articles.repository";
|
import { MockArticlesRepository } from "../infrastructure/repositories/mock-articles.repository";
|
||||||
import { BLOG_SYMBOLS } from "./symbols";
|
import { BLOG_SYMBOLS } from "./symbols";
|
||||||
|
|
||||||
export const BlogModule = new ContainerModule((bind: interfaces.Bind) => {
|
export const BlogModule = new ContainerModule((bind: interfaces.Bind) => {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import "reflect-metadata";
|
import "reflect-metadata";
|
||||||
import { injectable } from "inversify";
|
import { injectable } from "inversify";
|
||||||
|
|
||||||
import type { IArticlesRepository } from "@/application/repositories/articles-repository.interface";
|
import type { IArticlesRepository } from "../../application/repositories/articles-repository.interface";
|
||||||
import type { Article } from "@/entities/article";
|
import type { Article } from "../../entities/article";
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class MockArticlesRepository implements IArticlesRepository {
|
export class MockArticlesRepository implements IArticlesRepository {
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ import { injectable } from "inversify";
|
|||||||
import { getPayload } from "payload";
|
import { getPayload } from "payload";
|
||||||
import type { SanitizedConfig } from "payload";
|
import type { SanitizedConfig } from "payload";
|
||||||
|
|
||||||
import type { IArticlesRepository } from "@/application/repositories/articles-repository.interface";
|
import type { IArticlesRepository } from "../../application/repositories/articles-repository.interface";
|
||||||
import type { Article } from "@/entities/article";
|
import type { Article } from "../../entities/article";
|
||||||
|
|
||||||
type PayloadArticleDoc = {
|
type PayloadArticleDoc = {
|
||||||
id: string | number;
|
id: string | number;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { beforeEach, describe, expect, it } from "vitest";
|
import { beforeEach, describe, expect, it } from "vitest";
|
||||||
import { blogContainer } from "@/di/container";
|
import { blogContainer } from "../../di/container";
|
||||||
import { BLOG_SYMBOLS } from "@/di/symbols";
|
import { BLOG_SYMBOLS } from "../../di/symbols";
|
||||||
import { MockArticlesRepository } from "@/infrastructure/repositories/mock-articles.repository";
|
import { MockArticlesRepository } from "../../infrastructure/repositories/mock-articles.repository";
|
||||||
import type { IArticlesRepository } from "@/application/repositories/articles-repository.interface";
|
import type { IArticlesRepository } from "../../application/repositories/articles-repository.interface";
|
||||||
import { blogRouter } from "./router";
|
import { blogRouter } from "./router";
|
||||||
|
|
||||||
describe("blogRouter", () => {
|
describe("blogRouter", () => {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import {
|
|||||||
createArticleController,
|
createArticleController,
|
||||||
getArticlesController,
|
getArticlesController,
|
||||||
getArticleBySlugController,
|
getArticleBySlugController,
|
||||||
} from "@/interface-adapters/controllers/articles.controller";
|
} from "../../interface-adapters/controllers/articles.controller";
|
||||||
|
|
||||||
export const blogRouter = router({
|
export const blogRouter = router({
|
||||||
articleBySlug: publicProcedure
|
articleBySlug: publicProcedure
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { beforeEach, describe, expect, it } from "vitest";
|
import { beforeEach, describe, expect, it } from "vitest";
|
||||||
import { blogContainer } from "@/di/container";
|
import { blogContainer } from "../../di/container";
|
||||||
import { BLOG_SYMBOLS } from "@/di/symbols";
|
import { BLOG_SYMBOLS } from "../../di/symbols";
|
||||||
import { MockArticlesRepository } from "@/infrastructure/repositories/mock-articles.repository";
|
import { MockArticlesRepository } from "../../infrastructure/repositories/mock-articles.repository";
|
||||||
import type { IArticlesRepository } from "@/application/repositories/articles-repository.interface";
|
import type { IArticlesRepository } from "../../application/repositories/articles-repository.interface";
|
||||||
import { InputParseError } from "@/entities/errors";
|
import { InputParseError } from "../../entities/errors";
|
||||||
import {
|
import {
|
||||||
createArticleController,
|
createArticleController,
|
||||||
getArticlesController,
|
getArticlesController,
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
import { InputParseError } from "@/entities/errors";
|
import { InputParseError } from "../../entities/errors";
|
||||||
import type { Article } from "@/entities/article";
|
import type { Article } from "../../entities/article";
|
||||||
import { blogContainer } from "@/di/container";
|
import { blogContainer } from "../../di/container";
|
||||||
import { BLOG_SYMBOLS } from "@/di/symbols";
|
import { BLOG_SYMBOLS } from "../../di/symbols";
|
||||||
import type { IArticlesRepository } from "@/application/repositories/articles-repository.interface";
|
import type { IArticlesRepository } from "../../application/repositories/articles-repository.interface";
|
||||||
import { getArticlesUseCase } from "@/application/use-cases/get-articles.use-case";
|
import { getArticlesUseCase } from "../../application/use-cases/get-articles.use-case";
|
||||||
import { createArticleUseCase } from "@/application/use-cases/create-article.use-case";
|
import { createArticleUseCase } from "../../application/use-cases/create-article.use-case";
|
||||||
|
|
||||||
const createInputSchema = z.object({
|
const createInputSchema = z.object({
|
||||||
title: z.string().min(1).max(255),
|
title: z.string().min(1).max(255),
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
"typecheck": "tsc --noEmit"
|
"typecheck": "tsc --noEmit"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@repo/blog": "workspace:*",
|
||||||
"@repo/core-shared": "workspace:*",
|
"@repo/core-shared": "workspace:*",
|
||||||
"@trpc/server": "^11.0.0"
|
"@trpc/server": "^11.0.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
import { router } from "@repo/core-shared/trpc/init";
|
import { router } from "@repo/core-shared/trpc/init";
|
||||||
|
import { blogRouter } from "@repo/blog/api";
|
||||||
|
|
||||||
export const appRouter = router({});
|
export const appRouter = router({
|
||||||
|
blog: blogRouter,
|
||||||
|
});
|
||||||
|
|
||||||
export type AppRouter = typeof appRouter;
|
export type AppRouter = typeof appRouter;
|
||||||
|
|||||||
3
pnpm-lock.yaml
generated
3
pnpm-lock.yaml
generated
@@ -327,6 +327,9 @@ importers:
|
|||||||
|
|
||||||
packages/core-api:
|
packages/core-api:
|
||||||
dependencies:
|
dependencies:
|
||||||
|
'@repo/blog':
|
||||||
|
specifier: workspace:*
|
||||||
|
version: link:../blog
|
||||||
'@repo/core-shared':
|
'@repo/core-shared':
|
||||||
specifier: workspace:*
|
specifier: workspace:*
|
||||||
version: link:../core-shared
|
version: link:../core-shared
|
||||||
|
|||||||
Reference in New Issue
Block a user