mirror of https://github.com/buster-so/buster.git
fix: update InitiateOAuthSchema to be non-optional for proper zValidator typing
Co-Authored-By: Dallin Bentley <dallinbentley98@gmail.com>
This commit is contained in:
parent
e45c253344
commit
eeb2959920
|
@ -19,7 +19,7 @@ import { updateIntegrationHandler } from './update-integration';
|
|||
|
||||
const app = new Hono()
|
||||
// Public endpoints (no auth required for OAuth flow)
|
||||
.post('/auth/init', requireAuth, zValidator('json', z.object({}).merge(InitiateOAuthSchema.unwrap())), initiateOAuthHandler)
|
||||
.post('/auth/init', requireAuth, zValidator('json', InitiateOAuthSchema), initiateOAuthHandler)
|
||||
.get('/auth/callback', handleOAuthCallbackHandler)
|
||||
// Protected endpoints
|
||||
.get('/integration', requireAuth, getIntegrationHandler)
|
||||
|
|
|
@ -46,7 +46,7 @@ export async function initiateOAuthHandler(c: Context): Promise<Response> {
|
|||
throw new HTTPException(400, { message: 'Organization not found' });
|
||||
}
|
||||
|
||||
const request = c.req.valid('json') as InitiateOAuthRequest;
|
||||
const request = c.req.valid('json');
|
||||
const metadata = request?.metadata;
|
||||
|
||||
const enrichedMetadata = {
|
||||
|
|
|
@ -23,7 +23,7 @@ export async function updateIntegrationHandler(c: Context): Promise<Response> {
|
|||
}
|
||||
|
||||
try {
|
||||
const request = c.req.valid('json') as UpdateIntegrationRequest;
|
||||
const request = c.req.valid('json');
|
||||
|
||||
const updateData: {
|
||||
defaultChannel?: { id: string; name: string };
|
||||
|
|
|
@ -11,17 +11,15 @@ const SlackSharingPermissionEnum: Record<SlackSharingPermissionBase, SlackSharin
|
|||
});
|
||||
|
||||
// POST /api/v2/slack/auth/init
|
||||
export const InitiateOAuthSchema = z
|
||||
.object({
|
||||
metadata: z
|
||||
.object({
|
||||
return_url: z.string().optional(),
|
||||
source: z.string().optional(),
|
||||
project_id: z.string().uuid().optional(),
|
||||
})
|
||||
.optional(),
|
||||
})
|
||||
.optional();
|
||||
export const InitiateOAuthSchema = z.object({
|
||||
metadata: z
|
||||
.object({
|
||||
return_url: z.string().optional(),
|
||||
source: z.string().optional(),
|
||||
project_id: z.string().uuid().optional(),
|
||||
})
|
||||
.optional(),
|
||||
});
|
||||
|
||||
export type InitiateOAuthRequest = z.infer<typeof InitiateOAuthSchema>;
|
||||
|
||||
|
|
Loading…
Reference in New Issue