Either google apis is the most scuffed thing ever, or it's too genius for my puny mind

This commit is contained in:
Eclypsed
2024-02-11 01:03:49 -05:00
parent 09a23fe363
commit cb03d2661b
12 changed files with 548 additions and 33 deletions

View File

@@ -17,7 +17,11 @@ const newConnectionSchema = z.object({
userId: z.string(),
urlOrigin: z.string().refine((val) => isValidURL(val)),
}),
accessToken: z.string(),
tokens: z.object({
accessToken: z.string(),
refreshToken: z.string().optional(),
expiry: z.number().optional(),
}),
})
export const POST: RequestHandler = async ({ params, request }) => {
@@ -28,8 +32,8 @@ export const POST: RequestHandler = async ({ params, request }) => {
const connectionValidation = newConnectionSchema.safeParse(connection)
if (!connectionValidation.success) return new Response(connectionValidation.error.message, { status: 400 })
const { service, accessToken } = connection
const newConnection = Connections.addConnection(userId, service, accessToken)
const { service, tokens } = connection
const newConnection = Connections.addConnection(userId, service, tokens)
return Response.json(newConnection)
}