Spaces:
Running
Running
Download apps/api/src/integrations/integrations.controller.ts from Benaah/MicProtocol: direct link, hf CLI and curl.
- Browser
- Download file 4.55 kB
-
https://huggingface.co/spaces/Benaah/MicProtocol/resolve/main/apps/api/src/integrations/integrations.controller.ts
- Command line
-
hf download hf://spaces/Benaah/MicProtocol/apps/api/src/integrations/integrations.controller.ts
-
curl -L -o integrations.controller.ts https://huggingface.co/spaces/Benaah/MicProtocol/resolve/main/apps/api/src/integrations/integrations.controller.ts
4.55 kB
| import { Controller, Get, Query, Res, Logger } from "@nestjs/common"; | |
| import { Response } from "express"; | |
| import { IntegrationsService } from "./integrations.service"; | |
| ("api/integrations") | |
| export class IntegrationsController { | |
| private readonly logger = new Logger(IntegrationsController.name); | |
| constructor(private readonly integrationsService: IntegrationsService) {} | |
| ("google/callback") | |
| async googleCallback( | |
| ("code") code: string, | |
| ("state") state: string, | |
| ("error") error: string, | |
| () res: Response, | |
| ) { | |
| if (error) { | |
| this.logger.warn(`Google OAuth error: ${error}`); | |
| return res.redirect(`${process.env.WEBAPP_URL || "http://localhost:3000"}/settings?integration=google_calendar&status=error`); | |
| } | |
| try { | |
| const result = await this.integrationsService.handleOAuthCallback(code, state); | |
| return res.redirect( | |
| `${process.env.WEBAPP_URL || "http://localhost:3000"}/settings?integration=${result.provider}&status=${result.success ? "connected" : "error"}`, | |
| ); | |
| } catch (err: any) { | |
| this.logger.error(`Google OAuth callback failed: ${err.message}`); | |
| return res.redirect( | |
| `${process.env.WEBAPP_URL || "http://localhost:3000"}/settings?integration=google_calendar&status=error`, | |
| ); | |
| } | |
| } | |
| ("outlook/callback") | |
| async outlookCallback( | |
| ("code") code: string, | |
| ("state") state: string, | |
| ("error") error: string, | |
| () res: Response, | |
| ) { | |
| if (error) { | |
| this.logger.warn(`Outlook OAuth error: ${error}`); | |
| return res.redirect(`${process.env.WEBAPP_URL || "http://localhost:3000"}/settings?integration=outlook&status=error`); | |
| } | |
| try { | |
| const result = await this.integrationsService.handleOAuthCallback(code, state); | |
| return res.redirect( | |
| `${process.env.WEBAPP_URL || "http://localhost:3000"}/settings?integration=${result.provider}&status=${result.success ? "connected" : "error"}`, | |
| ); | |
| } catch (err: any) { | |
| this.logger.error(`Outlook OAuth callback failed: ${err.message}`); | |
| return res.redirect( | |
| `${process.env.WEBAPP_URL || "http://localhost:3000"}/settings?integration=outlook&status=error`, | |
| ); | |
| } | |
| } | |
| ("zoom/callback") | |
| async zoomCallback( | |
| ("code") code: string, | |
| ("state") state: string, | |
| ("error") error: string, | |
| () res: Response, | |
| ) { | |
| if (error) { | |
| this.logger.warn(`Zoom OAuth error: ${error}`); | |
| return res.redirect(`${process.env.WEBAPP_URL || "http://localhost:3000"}/settings?integration=zoom&status=error`); | |
| } | |
| try { | |
| const result = await this.integrationsService.handleOAuthCallback(code, state); | |
| return res.redirect( | |
| `${process.env.WEBAPP_URL || "http://localhost:3000"}/settings?integration=${result.provider}&status=${result.success ? "connected" : "error"}`, | |
| ); | |
| } catch (err: any) { | |
| this.logger.error(`Zoom OAuth callback failed: ${err.message}`); | |
| return res.redirect( | |
| `${process.env.WEBAPP_URL || "http://localhost:3000"}/settings?integration=zoom&status=error`, | |
| ); | |
| } | |
| } | |
| ("riverside/callback") | |
| async riversideCallback( | |
| ("code") code: string, | |
| ("state") state: string, | |
| ("error") error: string, | |
| () res: Response, | |
| ) { | |
| if (error) { | |
| this.logger.warn(`Riverside OAuth error: ${error}`); | |
| return res.redirect(`${process.env.WEBAPP_URL || "http://localhost:3000"}/settings?integration=riverside&status=error`); | |
| } | |
| try { | |
| const result = await this.integrationsService.handleOAuthCallback(code, state); | |
| return res.redirect( | |
| `${process.env.WEBAPP_URL || "http://localhost:3000"}/settings?integration=${result.provider}&status=${result.success ? "connected" : "error"}`, | |
| ); | |
| } catch (err: any) { | |
| this.logger.error(`Riverside OAuth callback failed: ${err.message}`); | |
| return res.redirect( | |
| `${process.env.WEBAPP_URL || "http://localhost:3000"}/settings?integration=riverside&status=error`, | |
| ); | |
| } | |
| } | |
| } | |