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()
|
const app = new Hono()
|
||||||
// Public endpoints (no auth required for OAuth flow)
|
// 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)
|
.get('/auth/callback', handleOAuthCallbackHandler)
|
||||||
// Protected endpoints
|
// Protected endpoints
|
||||||
.get('/integration', requireAuth, getIntegrationHandler)
|
.get('/integration', requireAuth, getIntegrationHandler)
|
||||||
|
|
|
@ -46,7 +46,7 @@ export async function initiateOAuthHandler(c: Context): Promise<Response> {
|
||||||
throw new HTTPException(400, { message: 'Organization not found' });
|
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 metadata = request?.metadata;
|
||||||
|
|
||||||
const enrichedMetadata = {
|
const enrichedMetadata = {
|
||||||
|
|
|
@ -23,7 +23,7 @@ export async function updateIntegrationHandler(c: Context): Promise<Response> {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const request = c.req.valid('json') as UpdateIntegrationRequest;
|
const request = c.req.valid('json');
|
||||||
|
|
||||||
const updateData: {
|
const updateData: {
|
||||||
defaultChannel?: { id: string; name: string };
|
defaultChannel?: { id: string; name: string };
|
||||||
|
|
|
@ -11,8 +11,7 @@ const SlackSharingPermissionEnum: Record<SlackSharingPermissionBase, SlackSharin
|
||||||
});
|
});
|
||||||
|
|
||||||
// POST /api/v2/slack/auth/init
|
// POST /api/v2/slack/auth/init
|
||||||
export const InitiateOAuthSchema = z
|
export const InitiateOAuthSchema = z.object({
|
||||||
.object({
|
|
||||||
metadata: z
|
metadata: z
|
||||||
.object({
|
.object({
|
||||||
return_url: z.string().optional(),
|
return_url: z.string().optional(),
|
||||||
|
@ -20,8 +19,7 @@ export const InitiateOAuthSchema = z
|
||||||
project_id: z.string().uuid().optional(),
|
project_id: z.string().uuid().optional(),
|
||||||
})
|
})
|
||||||
.optional(),
|
.optional(),
|
||||||
})
|
});
|
||||||
.optional();
|
|
||||||
|
|
||||||
export type InitiateOAuthRequest = z.infer<typeof InitiateOAuthSchema>;
|
export type InitiateOAuthRequest = z.infer<typeof InitiateOAuthSchema>;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue