Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

2.8 KB
Raw Blame
import { Hono } from 'hono';

import { casdoorWebhook } from './handlers/casdoor';
import { githubWebhook } from './handlers/github';
import { githubInstall } from './handlers/githubInstall';
import { githubSetup } from './handlers/githubSetup';
import { inboundWebhook, inboundWebhookBodyLimit } from './handlers/inbound';
import { linearCallback } from './handlers/linearCallback';
import { linearInstall } from './handlers/linearInstall';
import { logtoWebhook } from './handlers/logto';
import { memoryExtractionWebhook } from './handlers/memoryExtraction';
import { memoryExtractionBenchmarkLocomo } from './handlers/memoryExtractionBenchmarkLocomo';
import { memoryUserMemoryChatTopicCancel } from './handlers/memoryUserMemoryChatTopicCancel';
import { memoryUserMemoryConsolidation } from './handlers/memoryUserMemoryConsolidation';
import { memoryUserMemoryPersonaUpdateWriting } from './handlers/memoryUserMemoryPersonaUpdateWriting';
import { musicWebhook } from './handlers/music';
import { videoWebhook } from './handlers/video';
import { memoryWebhookAuth } from './middlewares/memoryWebhookAuth';

const app = new Hono().basePath('/api/webhooks');

// Identity provider webhooks — each verifies its own provider signature.
app.post('/casdoor', casdoorWebhook);
app.post('/logto', logtoWebhook);
app.post('/inbound/:id', inboundWebhookBodyLimit, inboundWebhook);

// Memory pipeline webhooks — share the configured static-header guard.
app.post('/memory-extraction', memoryWebhookAuth(), memoryExtractionWebhook);
app.post(
  '/memory-extraction/benchmark-locomo',
  memoryWebhookAuth(),
  memoryExtractionBenchmarkLocomo,
);
app.post('/memory-user-memory/consolidation', memoryWebhookAuth(), memoryUserMemoryConsolidation);
app.post(
  '/memory-user-memory/persona/update-writing',
  memoryWebhookAuth(),
  memoryUserMemoryPersonaUpdateWriting,
);
app.post(
  '/memory-user-memory/pipelines/extract/chat-topic/cancel',
  memoryWebhookAuth(),
  memoryUserMemoryChatTopicCancel,
);

// Async video generation callback; the token is verified per asyncTask.
app.post('/video/:provider', videoWebhook);

// Music gateway callback; acknowledged only, completion is polled by the async music router.
app.post('/music/:provider', musicWebhook);

// GitHub App: signed event ingress plus the install / setup redirects GitHub
// sends the user through. The GET routes share the prefix because the App's
// Callback URL and Setup URL are registered on GitHub next to the webhook URL.
app.post('/github', githubWebhook);
app.get('/github/install', githubInstall);
app.get('/github/setup', githubSetup);
app.get('/github/oauth/callback', githubSetup);

// Linear OAuth application: the connect redirect and its OAuth callback.
app.get('/linear/install', linearInstall);
app.get('/linear/oauth/callback', linearCallback);

export default app;