From 1c9f8994c1144fe629249b7c4b7dfb93d71cba96 Mon Sep 17 00:00:00 2001 From: James Perkins Date: Thu, 13 Feb 2025 08:33:24 -0500 Subject: [PATCH 1/5] Fix prefix both client and server Prefix allowed for whitespaces - Refined them - Fixed errors - Removed redudant errors - Made all the errors the same --- .../keys/[keyAuthId]/new/validation.ts | 15 ++++++++---- .../apis/[apiId]/settings/default-prefix.tsx | 23 +++++++++++++------ .../lib/trpc/routers/api/setDefaultPrefix.ts | 11 ++++++--- apps/dashboard/lib/trpc/routers/key/create.ts | 15 +++++++++--- 4 files changed, 47 insertions(+), 17 deletions(-) diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/new/validation.ts b/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/new/validation.ts index dea35535dc..415bb0cf3e 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/new/validation.ts +++ b/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/new/validation.ts @@ -15,7 +15,10 @@ export const formSchema = z.object({ prefix: z .string() .trim() - .max(8, { message: "Please limit the prefix to under 8 characters." }) + .max(8, { message: "Prefixes cannot be longer than 8 characters" }) + .refine((prefix) => !prefix.includes(" "), { + message: "Prefixes cannot contain spaces.", + }) .optional(), ownerId: z.string().trim().optional(), name: z.string().trim().optional(), @@ -33,7 +36,7 @@ export const formSchema = z.object({ }, { message: "Must be valid json", - }, + } ) .optional(), limitEnabled: z.boolean().default(false), @@ -96,7 +99,9 @@ export const formSchema = z.object({ .number({ errorMap: (issue, { defaultError }) => ({ message: - issue.code === "invalid_type" ? "Duration must be greater than 0" : defaultError, + issue.code === "invalid_type" + ? "Duration must be greater than 0" + : defaultError, }), }) .positive({ message: "Refill interval must be greater than 0" }), @@ -104,7 +109,9 @@ export const formSchema = z.object({ .number({ errorMap: (issue, { defaultError }) => ({ message: - issue.code === "invalid_type" ? "Refill limit must be greater than 0" : defaultError, + issue.code === "invalid_type" + ? "Refill limit must be greater than 0" + : defaultError, }), }) .positive({ message: "Limit must be greater than 0" }), diff --git a/apps/dashboard/app/(app)/apis/[apiId]/settings/default-prefix.tsx b/apps/dashboard/app/(app)/apis/[apiId]/settings/default-prefix.tsx index 89af88491a..1d9a24f821 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/settings/default-prefix.tsx +++ b/apps/dashboard/app/(app)/apis/[apiId]/settings/default-prefix.tsx @@ -19,7 +19,13 @@ import { z } from "zod"; const formSchema = z.object({ keyAuthId: z.string(), - defaultPrefix: z.string(), + defaultPrefix: z + .string() + .trim() + .max(8, { message: "Prefixes cannot be longer than 8 characters" }) + .refine((prefix) => !prefix.includes(" "), { + message: "Prefixes cannot contain spaces.", + }), }); type Props = { @@ -50,11 +56,10 @@ export const DefaultPrefix: React.FC = ({ keyAuth }) => { }, }); async function onSubmit(values: z.infer) { - if (values.defaultPrefix.length > 8) { - return toast.error("Default prefix is too long, maximum length is 8 characters."); - } if (values.defaultPrefix === keyAuth.defaultPrefix) { - return toast.error("Please provide a different prefix than already existing one as default"); + return toast.error( + "Please provide a different prefix than already existing one as default" + ); } await setDefaultPrefix.mutateAsync(values); } @@ -64,7 +69,9 @@ export const DefaultPrefix: React.FC = ({ keyAuth }) => { Default Prefix - Set default prefix for the keys under this API. + + Set default prefix for the keys under this API. +
@@ -73,7 +80,9 @@ export const DefaultPrefix: React.FC = ({ keyAuth }) => { } + render={({ field }) => ( + + )} />
diff --git a/apps/dashboard/lib/trpc/routers/api/setDefaultPrefix.ts b/apps/dashboard/lib/trpc/routers/api/setDefaultPrefix.ts index 1fd0dea302..8613a93c5f 100644 --- a/apps/dashboard/lib/trpc/routers/api/setDefaultPrefix.ts +++ b/apps/dashboard/lib/trpc/routers/api/setDefaultPrefix.ts @@ -9,9 +9,14 @@ export const setDefaultApiPrefix = t.procedure .use(auth) .input( z.object({ - defaultPrefix: z.string().max(8, "Prefix can be a maximum of 8 characters"), + defaultPrefix: z + .string() + .max(8, { message: "Prefixes cannot be longer than 8 characters" }) + .refine((prefix) => !prefix.includes(" "), { + message: "Prefixes cannot contain spaces.", + }), keyAuthId: z.string(), - }), + }) ) .mutation(async ({ ctx, input }) => { const keyAuth = await db.query.keyAuth @@ -20,7 +25,7 @@ export const setDefaultApiPrefix = t.procedure and( eq(table.workspaceId, ctx.workspace.id), eq(table.id, input.keyAuthId), - isNull(table.deletedAt), + isNull(table.deletedAt) ), }) .catch((_err) => { diff --git a/apps/dashboard/lib/trpc/routers/key/create.ts b/apps/dashboard/lib/trpc/routers/key/create.ts index 692d3ee4f8..9d4b129414 100644 --- a/apps/dashboard/lib/trpc/routers/key/create.ts +++ b/apps/dashboard/lib/trpc/routers/key/create.ts @@ -10,7 +10,13 @@ export const createKey = t.procedure .use(auth) .input( z.object({ - prefix: z.string().optional(), + prefix: z + .string() + .max(8, { message: "Prefixes cannot be longer than 8 characters" }) + .refine((prefix) => !prefix.includes(" "), { + message: "Prefixes cannot contain spaces.", + }) + .optional(), bytes: z.number().int().gte(16).default(16), keyAuthId: z.string(), ownerId: z.string().nullish(), @@ -33,13 +39,16 @@ export const createKey = t.procedure .optional(), enabled: z.boolean().default(true), environment: z.string().optional(), - }), + }) ) .mutation(async ({ input, ctx }) => { const keyAuth = await db.query.keyAuth .findFirst({ where: (table, { and, eq }) => - and(eq(table.workspaceId, ctx.workspace.id), eq(table.id, input.keyAuthId)), + and( + eq(table.workspaceId, ctx.workspace.id), + eq(table.id, input.keyAuthId) + ), with: { api: true, }, From 3aba8e2c2fad92183080184a87e710f5170203d9 Mon Sep 17 00:00:00 2001 From: James Perkins Date: Thu, 13 Feb 2025 08:46:44 -0500 Subject: [PATCH 2/5] Fix check --- .../app/(app)/apis/[apiId]/keys/[keyAuthId]/new/validation.ts | 2 +- .../app/(app)/apis/[apiId]/settings/default-prefix.tsx | 2 +- apps/dashboard/lib/trpc/routers/api/setDefaultPrefix.ts | 2 +- apps/dashboard/lib/trpc/routers/key/create.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/new/validation.ts b/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/new/validation.ts index 415bb0cf3e..768d4de6e0 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/new/validation.ts +++ b/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/new/validation.ts @@ -16,7 +16,7 @@ export const formSchema = z.object({ .string() .trim() .max(8, { message: "Prefixes cannot be longer than 8 characters" }) - .refine((prefix) => !prefix.includes(" "), { + .refine((prefix) => prefix.includes(" "), { message: "Prefixes cannot contain spaces.", }) .optional(), diff --git a/apps/dashboard/app/(app)/apis/[apiId]/settings/default-prefix.tsx b/apps/dashboard/app/(app)/apis/[apiId]/settings/default-prefix.tsx index 1d9a24f821..6f234d1900 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/settings/default-prefix.tsx +++ b/apps/dashboard/app/(app)/apis/[apiId]/settings/default-prefix.tsx @@ -23,7 +23,7 @@ const formSchema = z.object({ .string() .trim() .max(8, { message: "Prefixes cannot be longer than 8 characters" }) - .refine((prefix) => !prefix.includes(" "), { + .refine((prefix) => prefix.includes(" "), { message: "Prefixes cannot contain spaces.", }), }); diff --git a/apps/dashboard/lib/trpc/routers/api/setDefaultPrefix.ts b/apps/dashboard/lib/trpc/routers/api/setDefaultPrefix.ts index 8613a93c5f..941cbd0871 100644 --- a/apps/dashboard/lib/trpc/routers/api/setDefaultPrefix.ts +++ b/apps/dashboard/lib/trpc/routers/api/setDefaultPrefix.ts @@ -12,7 +12,7 @@ export const setDefaultApiPrefix = t.procedure defaultPrefix: z .string() .max(8, { message: "Prefixes cannot be longer than 8 characters" }) - .refine((prefix) => !prefix.includes(" "), { + .refine((prefix) => prefix.includes(" "), { message: "Prefixes cannot contain spaces.", }), keyAuthId: z.string(), diff --git a/apps/dashboard/lib/trpc/routers/key/create.ts b/apps/dashboard/lib/trpc/routers/key/create.ts index 9d4b129414..189ef87346 100644 --- a/apps/dashboard/lib/trpc/routers/key/create.ts +++ b/apps/dashboard/lib/trpc/routers/key/create.ts @@ -13,7 +13,7 @@ export const createKey = t.procedure prefix: z .string() .max(8, { message: "Prefixes cannot be longer than 8 characters" }) - .refine((prefix) => !prefix.includes(" "), { + .refine((prefix) => prefix.includes(" "), { message: "Prefixes cannot contain spaces.", }) .optional(), From 2e67791070acd6ce1c92b7bdc85b36f91dd07101 Mon Sep 17 00:00:00 2001 From: James Perkins Date: Thu, 13 Feb 2025 09:27:27 -0500 Subject: [PATCH 3/5] fix form validation for bytes and prefix Form validation never worked on our default pages. This fixes that and also fixes white spaces anywhere with an error --- .../keys/[keyAuthId]/new/validation.ts | 3 +- .../apis/[apiId]/settings/default-bytes.tsx | 104 +++++++++++------- .../apis/[apiId]/settings/default-prefix.tsx | 103 ++++++++++------- .../lib/trpc/routers/api/setDefaultPrefix.ts | 2 +- apps/dashboard/lib/trpc/routers/key/create.ts | 2 +- 5 files changed, 132 insertions(+), 82 deletions(-) diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/new/validation.ts b/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/new/validation.ts index 768d4de6e0..d4e282c0fa 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/new/validation.ts +++ b/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/new/validation.ts @@ -14,9 +14,8 @@ export const formSchema = z.object({ .default(16), prefix: z .string() - .trim() .max(8, { message: "Prefixes cannot be longer than 8 characters" }) - .refine((prefix) => prefix.includes(" "), { + .refine((prefix) => !prefix.includes(" "), { message: "Prefixes cannot contain spaces.", }) .optional(), diff --git a/apps/dashboard/app/(app)/apis/[apiId]/settings/default-bytes.tsx b/apps/dashboard/app/(app)/apis/[apiId]/settings/default-bytes.tsx index a57cafb9da..405de46473 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/settings/default-bytes.tsx +++ b/apps/dashboard/app/(app)/apis/[apiId]/settings/default-bytes.tsx @@ -8,7 +8,13 @@ import { CardHeader, CardTitle, } from "@/components/ui/card"; -import { FormField } from "@/components/ui/form"; +import { + Form, + FormControl, + FormField, + FormItem, + FormMessage, +} from "@/components/ui/form"; import { Input } from "@/components/ui/input"; import { toast } from "@/components/ui/toaster"; import { trpc } from "@/lib/trpc/client"; @@ -36,7 +42,12 @@ type Props = { export const DefaultBytes: React.FC = ({ keyAuth }) => { const router = useRouter(); const form = useForm>({ - resolver: zodResolver(formSchema), + resolver: async (data, context, options) => { + return zodResolver(formSchema)(data, context, options); + }, + mode: "all", + shouldFocusError: true, + delayError: 100, defaultValues: { defaultBytes: keyAuth.defaultBytes ?? undefined, keyAuthId: keyAuth.id, @@ -57,50 +68,61 @@ export const DefaultBytes: React.FC = ({ keyAuth }) => { async function onSubmit(values: z.infer) { if (values.defaultBytes === keyAuth.defaultBytes || !values.defaultBytes) { return toast.error( - "Please provide a different byte-size than already existing one as default", + "Please provide a different byte-size than already existing one as default" ); } await setDefaultBytes.mutateAsync(values); } return ( -
- - - Default Bytes - - Set default Bytes for the keys under this API. Default byte size must be between{" "} - 8 to 255 - - - -
- - - ( - field.onChange(Number(e.target.value.replace(/\D/g, "")))} - /> - )} - /> -
-
- - - -
-
+
+ + + + Default Bytes + + Set default Bytes for the keys under this API. Default byte size + must be between 8 to 255 + + + +
+ + + ( + + + + field.onChange( + Number(e.target.value.replace(/\D/g, "")) + ) + } + /> + + + + )} + /> +
+
+ + + +
+
+ ); }; diff --git a/apps/dashboard/app/(app)/apis/[apiId]/settings/default-prefix.tsx b/apps/dashboard/app/(app)/apis/[apiId]/settings/default-prefix.tsx index 6f234d1900..d683a5744d 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/settings/default-prefix.tsx +++ b/apps/dashboard/app/(app)/apis/[apiId]/settings/default-prefix.tsx @@ -1,4 +1,5 @@ "use client"; +import { Badge } from "@/components/ui/badge"; import { Card, CardContent, @@ -7,7 +8,15 @@ import { CardHeader, CardTitle, } from "@/components/ui/card"; -import { FormField } from "@/components/ui/form"; +import { + Form, + FormControl, + FormDescription, + FormField, + FormItem, + FormLabel, + FormMessage, +} from "@/components/ui/form"; import { Input } from "@/components/ui/input"; import { toast } from "@/components/ui/toaster"; import { trpc } from "@/lib/trpc/client"; @@ -21,9 +30,8 @@ const formSchema = z.object({ keyAuthId: z.string(), defaultPrefix: z .string() - .trim() .max(8, { message: "Prefixes cannot be longer than 8 characters" }) - .refine((prefix) => prefix.includes(" "), { + .refine((prefix) => !prefix.includes(" "), { message: "Prefixes cannot contain spaces.", }), }); @@ -38,7 +46,12 @@ type Props = { export const DefaultPrefix: React.FC = ({ keyAuth }) => { const router = useRouter(); const form = useForm>({ - resolver: zodResolver(formSchema), + resolver: async (data, context, options) => { + return zodResolver(formSchema)(data, context, options); + }, + mode: "all", + shouldFocusError: true, + delayError: 100, defaultValues: { defaultPrefix: keyAuth.defaultPrefix ?? undefined, keyAuthId: keyAuth.id, @@ -65,38 +78,54 @@ export const DefaultPrefix: React.FC = ({ keyAuth }) => { } return ( -
- - - Default Prefix - - Set default prefix for the keys under this API. - - - -
- - - ( - - )} - /> -
-
- - - -
-
+
+ + + + Default Prefix + + Set default prefix for the keys under this API. Don't add a + trailing underscore, we'll do that automatically + + + +
+ + + ( + + + { + if (e.target.value === "") { + return; + } + }} + /> + + + + )} + /> +
+
+ + + +
+
+ ); }; diff --git a/apps/dashboard/lib/trpc/routers/api/setDefaultPrefix.ts b/apps/dashboard/lib/trpc/routers/api/setDefaultPrefix.ts index 941cbd0871..8613a93c5f 100644 --- a/apps/dashboard/lib/trpc/routers/api/setDefaultPrefix.ts +++ b/apps/dashboard/lib/trpc/routers/api/setDefaultPrefix.ts @@ -12,7 +12,7 @@ export const setDefaultApiPrefix = t.procedure defaultPrefix: z .string() .max(8, { message: "Prefixes cannot be longer than 8 characters" }) - .refine((prefix) => prefix.includes(" "), { + .refine((prefix) => !prefix.includes(" "), { message: "Prefixes cannot contain spaces.", }), keyAuthId: z.string(), diff --git a/apps/dashboard/lib/trpc/routers/key/create.ts b/apps/dashboard/lib/trpc/routers/key/create.ts index 189ef87346..9d4b129414 100644 --- a/apps/dashboard/lib/trpc/routers/key/create.ts +++ b/apps/dashboard/lib/trpc/routers/key/create.ts @@ -13,7 +13,7 @@ export const createKey = t.procedure prefix: z .string() .max(8, { message: "Prefixes cannot be longer than 8 characters" }) - .refine((prefix) => prefix.includes(" "), { + .refine((prefix) => !prefix.includes(" "), { message: "Prefixes cannot contain spaces.", }) .optional(), From 2c2726f0bb4c47d45220a4aa1903bc0ca1e481d5 Mon Sep 17 00:00:00 2001 From: James Perkins Date: Thu, 13 Feb 2025 09:38:14 -0500 Subject: [PATCH 4/5] Add labels and ids --- .../app/(app)/apis/[apiId]/settings/default-bytes.tsx | 5 ++++- .../app/(app)/apis/[apiId]/settings/default-prefix.tsx | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/dashboard/app/(app)/apis/[apiId]/settings/default-bytes.tsx b/apps/dashboard/app/(app)/apis/[apiId]/settings/default-bytes.tsx index 405de46473..c5653822c9 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/settings/default-bytes.tsx +++ b/apps/dashboard/app/(app)/apis/[apiId]/settings/default-bytes.tsx @@ -88,7 +88,9 @@ export const DefaultBytes: React.FC = ({ keyAuth }) => {
- + = ({ keyAuth }) => { = ({ keyAuth }) => {
- + = ({ keyAuth }) => { { From 8f152c57d3ef8375ac370223d6e297f030b55f11 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Thu, 13 Feb 2025 14:40:19 +0000 Subject: [PATCH 5/5] [autofix.ci] apply automated fixes --- .../keys/[keyAuthId]/new/validation.ts | 10 +++------- .../apis/[apiId]/settings/default-bytes.tsx | 20 +++++-------------- .../apis/[apiId]/settings/default-prefix.tsx | 19 ++++-------------- .../lib/trpc/routers/api/setDefaultPrefix.ts | 4 ++-- apps/dashboard/lib/trpc/routers/key/create.ts | 7 ++----- 5 files changed, 16 insertions(+), 44 deletions(-) diff --git a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/new/validation.ts b/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/new/validation.ts index d4e282c0fa..0fc54c74d4 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/new/validation.ts +++ b/apps/dashboard/app/(app)/apis/[apiId]/keys/[keyAuthId]/new/validation.ts @@ -35,7 +35,7 @@ export const formSchema = z.object({ }, { message: "Must be valid json", - } + }, ) .optional(), limitEnabled: z.boolean().default(false), @@ -98,9 +98,7 @@ export const formSchema = z.object({ .number({ errorMap: (issue, { defaultError }) => ({ message: - issue.code === "invalid_type" - ? "Duration must be greater than 0" - : defaultError, + issue.code === "invalid_type" ? "Duration must be greater than 0" : defaultError, }), }) .positive({ message: "Refill interval must be greater than 0" }), @@ -108,9 +106,7 @@ export const formSchema = z.object({ .number({ errorMap: (issue, { defaultError }) => ({ message: - issue.code === "invalid_type" - ? "Refill limit must be greater than 0" - : defaultError, + issue.code === "invalid_type" ? "Refill limit must be greater than 0" : defaultError, }), }) .positive({ message: "Limit must be greater than 0" }), diff --git a/apps/dashboard/app/(app)/apis/[apiId]/settings/default-bytes.tsx b/apps/dashboard/app/(app)/apis/[apiId]/settings/default-bytes.tsx index c5653822c9..0616810663 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/settings/default-bytes.tsx +++ b/apps/dashboard/app/(app)/apis/[apiId]/settings/default-bytes.tsx @@ -8,13 +8,7 @@ import { CardHeader, CardTitle, } from "@/components/ui/card"; -import { - Form, - FormControl, - FormField, - FormItem, - FormMessage, -} from "@/components/ui/form"; +import { Form, FormControl, FormField, FormItem, FormMessage } from "@/components/ui/form"; import { Input } from "@/components/ui/input"; import { toast } from "@/components/ui/toaster"; import { trpc } from "@/lib/trpc/client"; @@ -68,7 +62,7 @@ export const DefaultBytes: React.FC = ({ keyAuth }) => { async function onSubmit(values: z.infer) { if (values.defaultBytes === keyAuth.defaultBytes || !values.defaultBytes) { return toast.error( - "Please provide a different byte-size than already existing one as default" + "Please provide a different byte-size than already existing one as default", ); } await setDefaultBytes.mutateAsync(values); @@ -81,8 +75,8 @@ export const DefaultBytes: React.FC = ({ keyAuth }) => { Default Bytes - Set default Bytes for the keys under this API. Default byte size - must be between 8 to 255 + Set default Bytes for the keys under this API. Default byte size must be between{" "} + 8 to 255 @@ -102,11 +96,7 @@ export const DefaultBytes: React.FC = ({ keyAuth }) => { className="max-w-sm" {...field} autoComplete="off" - onChange={(e) => - field.onChange( - Number(e.target.value.replace(/\D/g, "")) - ) - } + onChange={(e) => field.onChange(Number(e.target.value.replace(/\D/g, "")))} /> diff --git a/apps/dashboard/app/(app)/apis/[apiId]/settings/default-prefix.tsx b/apps/dashboard/app/(app)/apis/[apiId]/settings/default-prefix.tsx index 9586174b6f..a253e42c60 100644 --- a/apps/dashboard/app/(app)/apis/[apiId]/settings/default-prefix.tsx +++ b/apps/dashboard/app/(app)/apis/[apiId]/settings/default-prefix.tsx @@ -1,5 +1,4 @@ "use client"; -import { Badge } from "@/components/ui/badge"; import { Card, CardContent, @@ -8,15 +7,7 @@ import { CardHeader, CardTitle, } from "@/components/ui/card"; -import { - Form, - FormControl, - FormDescription, - FormField, - FormItem, - FormLabel, - FormMessage, -} from "@/components/ui/form"; +import { Form, FormControl, FormField, FormItem, FormMessage } from "@/components/ui/form"; import { Input } from "@/components/ui/input"; import { toast } from "@/components/ui/toaster"; import { trpc } from "@/lib/trpc/client"; @@ -70,9 +61,7 @@ export const DefaultPrefix: React.FC = ({ keyAuth }) => { }); async function onSubmit(values: z.infer) { if (values.defaultPrefix === keyAuth.defaultPrefix) { - return toast.error( - "Please provide a different prefix than already existing one as default" - ); + return toast.error("Please provide a different prefix than already existing one as default"); } await setDefaultPrefix.mutateAsync(values); } @@ -84,8 +73,8 @@ export const DefaultPrefix: React.FC = ({ keyAuth }) => { Default Prefix - Set default prefix for the keys under this API. Don't add a - trailing underscore, we'll do that automatically + Set default prefix for the keys under this API. Don't add a trailing underscore, we'll + do that automatically diff --git a/apps/dashboard/lib/trpc/routers/api/setDefaultPrefix.ts b/apps/dashboard/lib/trpc/routers/api/setDefaultPrefix.ts index 8613a93c5f..718a056185 100644 --- a/apps/dashboard/lib/trpc/routers/api/setDefaultPrefix.ts +++ b/apps/dashboard/lib/trpc/routers/api/setDefaultPrefix.ts @@ -16,7 +16,7 @@ export const setDefaultApiPrefix = t.procedure message: "Prefixes cannot contain spaces.", }), keyAuthId: z.string(), - }) + }), ) .mutation(async ({ ctx, input }) => { const keyAuth = await db.query.keyAuth @@ -25,7 +25,7 @@ export const setDefaultApiPrefix = t.procedure and( eq(table.workspaceId, ctx.workspace.id), eq(table.id, input.keyAuthId), - isNull(table.deletedAt) + isNull(table.deletedAt), ), }) .catch((_err) => { diff --git a/apps/dashboard/lib/trpc/routers/key/create.ts b/apps/dashboard/lib/trpc/routers/key/create.ts index 9d4b129414..afe0e9ae18 100644 --- a/apps/dashboard/lib/trpc/routers/key/create.ts +++ b/apps/dashboard/lib/trpc/routers/key/create.ts @@ -39,16 +39,13 @@ export const createKey = t.procedure .optional(), enabled: z.boolean().default(true), environment: z.string().optional(), - }) + }), ) .mutation(async ({ input, ctx }) => { const keyAuth = await db.query.keyAuth .findFirst({ where: (table, { and, eq }) => - and( - eq(table.workspaceId, ctx.workspace.id), - eq(table.id, input.keyAuthId) - ), + and(eq(table.workspaceId, ctx.workspace.id), eq(table.id, input.keyAuthId)), with: { api: true, },