From 141739966316ecef2657e651377b9b977590a9d5 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 23 Oct 2024 10:23:48 -0500 Subject: [PATCH] Add applicationSchema --- src/schemas/application.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/schemas/application.ts diff --git a/src/schemas/application.ts b/src/schemas/application.ts new file mode 100644 index 000000000..a94ee1066 --- /dev/null +++ b/src/schemas/application.ts @@ -0,0 +1,22 @@ +import { z } from 'zod'; + +const applicationSchema = z.object({ + name: z.string(), + website: z.string().url().nullable().catch(null), + scopes: z.string().array().catch([]), + redirect_uris: z.string().url().array().optional().catch(undefined), + redirect_uri: z.string().url().optional().catch(undefined), +}).transform((app) => { + const { name, website, scopes, redirect_uris, redirect_uri } = app; + + return { + name, + website, + scopes, + redirect_uris: redirect_uris || (redirect_uri ? [redirect_uri] : []), + }; +}); + +type Application = z.infer; + +export { applicationSchema, Application }; \ No newline at end of file