diff options
| author | MohamedBassem <me@mbassem.com> | 2024-03-30 16:26:16 +0000 |
|---|---|---|
| committer | MohamedBassem <me@mbassem.com> | 2024-03-30 16:26:16 +0000 |
| commit | 46b78eaac30be26fe40520e97786563344af8403 (patch) | |
| tree | c4c0e1ae1d3d21a6f1fbf5f44f68e99243bbb5d3 /packages/trpc/routers | |
| parent | 853ed13450b3a0d92cba144cc0dfd0696e7c810c (diff) | |
| download | karakeep-46b78eaac30be26fe40520e97786563344af8403.tar.zst | |
format: Add missing lint and format, and format the entire repo
Diffstat (limited to 'packages/trpc/routers')
| -rw-r--r-- | packages/trpc/routers/_app.ts | 1 | ||||
| -rw-r--r-- | packages/trpc/routers/admin.ts | 6 | ||||
| -rw-r--r-- | packages/trpc/routers/apiKeys.ts | 10 | ||||
| -rw-r--r-- | packages/trpc/routers/bookmarks.test.ts | 6 | ||||
| -rw-r--r-- | packages/trpc/routers/bookmarks.ts | 44 | ||||
| -rw-r--r-- | packages/trpc/routers/lists.ts | 3 | ||||
| -rw-r--r-- | packages/trpc/routers/users.test.ts | 10 |
7 files changed, 43 insertions, 37 deletions
diff --git a/packages/trpc/routers/_app.ts b/packages/trpc/routers/_app.ts index 780fd76d..577b523e 100644 --- a/packages/trpc/routers/_app.ts +++ b/packages/trpc/routers/_app.ts @@ -5,6 +5,7 @@ import { bookmarksAppRouter } from "./bookmarks"; import { listsAppRouter } from "./lists"; import { tagsAppRouter } from "./tags"; import { usersAppRouter } from "./users"; + export const appRouter = router({ bookmarks: bookmarksAppRouter, apiKeys: apiKeysAppRouter, diff --git a/packages/trpc/routers/admin.ts b/packages/trpc/routers/admin.ts index 8a7b592d..4a7c6a80 100644 --- a/packages/trpc/routers/admin.ts +++ b/packages/trpc/routers/admin.ts @@ -1,6 +1,6 @@ -import { adminProcedure, router } from "../index"; -import { z } from "zod"; import { count } from "drizzle-orm"; +import { z } from "zod"; + import { bookmarks, users } from "@hoarder/db/schema"; import { LinkCrawlerQueue, @@ -8,6 +8,8 @@ import { SearchIndexingQueue, } from "@hoarder/shared/queues"; +import { adminProcedure, router } from "../index"; + export const adminAppRouter = router({ stats: adminProcedure .output( diff --git a/packages/trpc/routers/apiKeys.ts b/packages/trpc/routers/apiKeys.ts index 3093b433..deeb108f 100644 --- a/packages/trpc/routers/apiKeys.ts +++ b/packages/trpc/routers/apiKeys.ts @@ -1,9 +1,11 @@ -import { generateApiKey, validatePassword } from "../auth"; -import { authedProcedure, publicProcedure, router } from "../index"; +import { TRPCError } from "@trpc/server"; +import { and, eq } from "drizzle-orm"; import { z } from "zod"; + import { apiKeys } from "@hoarder/db/schema"; -import { eq, and } from "drizzle-orm"; -import { TRPCError } from "@trpc/server"; + +import { generateApiKey, validatePassword } from "../auth"; +import { authedProcedure, publicProcedure, router } from "../index"; const zApiKeySchema = z.object({ id: z.string(), diff --git a/packages/trpc/routers/bookmarks.test.ts b/packages/trpc/routers/bookmarks.test.ts index 724a9998..58f4739d 100644 --- a/packages/trpc/routers/bookmarks.test.ts +++ b/packages/trpc/routers/bookmarks.test.ts @@ -1,5 +1,7 @@ -import { CustomTestContext, defaultBeforeEach } from "../testUtils"; -import { expect, describe, test, beforeEach, assert } from "vitest"; +import { assert, beforeEach, describe, expect, test } from "vitest"; + +import type { CustomTestContext } from "../testUtils"; +import { defaultBeforeEach } from "../testUtils"; beforeEach<CustomTestContext>(defaultBeforeEach(true)); diff --git a/packages/trpc/routers/bookmarks.ts b/packages/trpc/routers/bookmarks.ts index 4fb29c4c..9611829f 100644 --- a/packages/trpc/routers/bookmarks.ts +++ b/packages/trpc/routers/bookmarks.ts @@ -21,19 +21,19 @@ import { } from "@hoarder/shared/queues"; import { getSearchIdxClient } from "@hoarder/shared/search"; -import { authedProcedure, Context, router } from "../index"; +import type { Context } from "../index"; +import type { ZBookmark, ZBookmarkContent } from "../types/bookmarks"; +import type { ZBookmarkTags } from "../types/tags"; +import { authedProcedure, router } from "../index"; import { DEFAULT_NUM_BOOKMARKS_PER_PAGE, zBareBookmarkSchema, - ZBookmark, - ZBookmarkContent, zBookmarkSchema, zGetBookmarksRequestSchema, zGetBookmarksResponseSchema, zNewBookmarkRequestSchema, zUpdateBookmarksRequestSchema, } from "../types/bookmarks"; -import { ZBookmarkTags } from "../types/tags"; export const ensureBookmarkOwnership = experimental_trpcMiddleware<{ ctx: Context; @@ -423,29 +423,29 @@ export const bookmarksAppRouter = router({ input.ids ? inArray(bookmarks.id, input.ids) : undefined, input.tagId !== undefined ? exists( - ctx.db - .select() - .from(tagsOnBookmarks) - .where( - and( - eq(tagsOnBookmarks.bookmarkId, bookmarks.id), - eq(tagsOnBookmarks.tagId, input.tagId), + ctx.db + .select() + .from(tagsOnBookmarks) + .where( + and( + eq(tagsOnBookmarks.bookmarkId, bookmarks.id), + eq(tagsOnBookmarks.tagId, input.tagId), + ), ), - ), - ) + ) : undefined, input.listId !== undefined ? exists( - ctx.db - .select() - .from(bookmarksInLists) - .where( - and( - eq(bookmarksInLists.bookmarkId, bookmarks.id), - eq(bookmarksInLists.listId, input.listId), + ctx.db + .select() + .from(bookmarksInLists) + .where( + and( + eq(bookmarksInLists.bookmarkId, bookmarks.id), + eq(bookmarksInLists.listId, input.listId), + ), ), - ), - ) + ) : undefined, input.cursor ? lte(bookmarks.createdAt, input.cursor) : undefined, ), diff --git a/packages/trpc/routers/lists.ts b/packages/trpc/routers/lists.ts index db5bb38e..fb6d8637 100644 --- a/packages/trpc/routers/lists.ts +++ b/packages/trpc/routers/lists.ts @@ -5,7 +5,8 @@ import { z } from "zod"; import { SqliteError } from "@hoarder/db"; import { bookmarkLists, bookmarksInLists } from "@hoarder/db/schema"; -import { authedProcedure, Context, router } from "../index"; +import type { Context } from "../index"; +import { authedProcedure, router } from "../index"; import { zBookmarkListSchema } from "../types/lists"; import { ensureBookmarkOwnership } from "./bookmarks"; diff --git a/packages/trpc/routers/users.test.ts b/packages/trpc/routers/users.test.ts index 87814407..ea342d33 100644 --- a/packages/trpc/routers/users.test.ts +++ b/packages/trpc/routers/users.test.ts @@ -1,9 +1,7 @@ -import { - CustomTestContext, - defaultBeforeEach, - getApiCaller, -} from "../testUtils"; -import { expect, describe, test, beforeEach, assert } from "vitest"; +import { assert, beforeEach, describe, expect, test } from "vitest"; + +import type { CustomTestContext } from "../testUtils"; +import { defaultBeforeEach, getApiCaller } from "../testUtils"; beforeEach<CustomTestContext>(defaultBeforeEach(false)); |
