aboutsummaryrefslogtreecommitdiffstats
path: root/packages/web/server/api/routers/apiKeys.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/web/server/api/routers/apiKeys.ts')
-rw-r--r--packages/web/server/api/routers/apiKeys.ts61
1 files changed, 0 insertions, 61 deletions
diff --git a/packages/web/server/api/routers/apiKeys.ts b/packages/web/server/api/routers/apiKeys.ts
deleted file mode 100644
index 9eb36974..00000000
--- a/packages/web/server/api/routers/apiKeys.ts
+++ /dev/null
@@ -1,61 +0,0 @@
-import { generateApiKey } from "@/server/auth";
-import { authedProcedure, router } from "../trpc";
-import { z } from "zod";
-import { apiKeys } from "@hoarder/db/schema";
-import { eq, and } from "drizzle-orm";
-
-export const apiKeysAppRouter = router({
- create: authedProcedure
- .input(
- z.object({
- name: z.string(),
- }),
- )
- .output(
- z.object({
- id: z.string(),
- name: z.string(),
- key: z.string(),
- createdAt: z.date(),
- }),
- )
- .mutation(async ({ input, ctx }) => {
- return await generateApiKey(input.name, ctx.user.id);
- }),
- revoke: authedProcedure
- .input(
- z.object({
- id: z.string(),
- }),
- )
- .mutation(async ({ input, ctx }) => {
- await ctx.db
- .delete(apiKeys)
- .where(and(eq(apiKeys.id, input.id), eq(apiKeys.userId, ctx.user.id)));
- }),
- list: authedProcedure
- .output(
- z.object({
- keys: z.array(
- z.object({
- id: z.string(),
- name: z.string(),
- createdAt: z.date(),
- keyId: z.string(),
- }),
- ),
- }),
- )
- .query(async ({ ctx }) => {
- const resp = await ctx.db.query.apiKeys.findMany({
- where: eq(apiKeys.userId, ctx.user.id),
- columns: {
- id: true,
- name: true,
- createdAt: true,
- keyId: true,
- },
- });
- return { keys: resp };
- }),
-});