diff --git a/scripts/test/api.ts b/scripts/test/api.ts index 93dd407..b3eda72 100644 --- a/scripts/test/api.ts +++ b/scripts/test/api.ts @@ -29,8 +29,7 @@ const { values } = parseArgs({ }); // check --skip-db-reset param -const shouldSkipDbReset = - values["skip-db-reset"] ?? testEnv.SKIP_DB_RESET; +const shouldSkipDbReset = values["skip-db-reset"] ?? testEnv.SKIP_DB_RESET; const isWatchMode = values.watch || false; // Performance options diff --git a/src/core/app.ts b/src/core/app.ts index f109ee0..165d02a 100644 --- a/src/core/app.ts +++ b/src/core/app.ts @@ -2,8 +2,8 @@ import { Elysia } from "elysia"; import { articlesPlugin as articles } from "@/articles/articles.plugin"; import { commentsPlugin as comments } from "@/comments/comments.plugin"; import { profiles } from "@/profiles/profiles.plugin"; -import { tags } from "@/tags/tags.plugin"; -import { usersPlugin as users } from "@/users/users.plugin"; +import { tags } from "@/tags/tags.controller"; +import { usersPlugin as users } from "@/users/users.controller"; import { errors, openapi } from "./plugins"; import { health } from "./plugins/health.plugin"; diff --git a/src/tags/tags.plugin.ts b/src/tags/tags.controller.ts similarity index 73% rename from src/tags/tags.plugin.ts rename to src/tags/tags.controller.ts index 22c5d59..c23a43a 100644 --- a/src/tags/tags.plugin.ts +++ b/src/tags/tags.controller.ts @@ -1,15 +1,13 @@ import { Elysia, t } from "elysia"; -import { db } from "@/core/db"; +import * as TagsService from "./tags.service"; export const tags = new Elysia({ tags: ["Tags"], }).get( "/tags", async () => { - const allTags = await db.tag.findMany(); - return { - tags: allTags.map((tag) => tag.name), - }; + const tags = await TagsService.findAll(); + return { tags }; }, { detail: { diff --git a/src/tags/tags.service.ts b/src/tags/tags.service.ts new file mode 100644 index 0000000..a9b1d5d --- /dev/null +++ b/src/tags/tags.service.ts @@ -0,0 +1,6 @@ +import type { Tag } from "@prisma/client"; +import { db } from "@/core/db"; + +export async function findAll(): Promise { + return await db.tag.findMany(); +} diff --git a/src/users/users.plugin.ts b/src/users/users.controller.ts similarity index 100% rename from src/users/users.plugin.ts rename to src/users/users.controller.ts diff --git a/src/users/users.service.ts b/src/users/users.service.ts new file mode 100644 index 0000000..e69de29