MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / registerAutomationRoutes

Function registerAutomationRoutes

apps/cli/src/sync/routes.ts:17–145  ·  view source on GitHub ↗
(server: FastifyInstance, ctx: SyncRouteContext)

Source from the content-addressed store, hash-verified

15import type { SyncRouteContext } from './index'
16
17export function registerAutomationRoutes(server: FastifyInstance, ctx: SyncRouteContext): void {
18 const { dsManager, pullEngine, dbManager, serverInfo } = ctx
19
20 // ==================== Config (read-only in CLI mode) ====================
21
22 server.get('/_web/automation/config', async () => {
23 return {
24 enabled: true,
25 port: serverInfo.port,
26 token: serverInfo.token,
27 host: serverInfo.host,
28 }
29 })
30
31 // ==================== Data Sources ====================
32
33 server.get('/_web/automation/data-sources', async () => {
34 return dsManager.loadAll()
35 })
36
37 server.post<{
38 Body: { name?: string; baseUrl: string; token: string; intervalMinutes: number; pullLimit?: number }
39 }>('/_web/automation/data-sources', async (request) => {
40 const ds = dsManager.add(request.body)
41 reloadTimer(ds.id)
42 return ds
43 })
44
45 server.patch<{
46 Params: { id: string }
47 Body: {
48 name?: string
49 baseUrl?: string
50 token?: string
51 intervalMinutes?: number
52 pullLimit?: number
53 enabled?: boolean
54 }
55 }>('/_web/automation/data-sources/:id', async (request, reply) => {
56 const ds = dsManager.update(request.params.id, request.body)
57 if (!ds) return reply.code(404).send({ error: 'Data source not found' })
58 reloadTimer(ds.id)
59 return ds
60 })
61
62 server.delete<{ Params: { id: string } }>('/_web/automation/data-sources/:id', async (request, reply) => {
63 stopTimer(request.params.id)
64 const ok = dsManager.delete(request.params.id)
65 if (!ok) return reply.code(404).send({ error: 'Data source not found' })
66 return { success: true }
67 })
68
69 // ==================== Import Sessions ====================
70
71 server.post<{
72 Params: { id: string }
73 Body: { sessions: Array<{ name: string; remoteSessionId: string }> }
74 }>('/_web/automation/data-sources/:id/sessions', async (request, reply) => {

Callers 2

initSyncFunction · 0.90
routes.test.tsFile · 0.90

Calls 15

reloadTimerFunction · 0.90
stopTimerFunction · 0.90
normalizeBaseUrlFunction · 0.90
buildRemoteSessionsUrlFunction · 0.90
addSessionsMethod · 0.80
removeSessionMethod · 0.80
getProgressMethod · 0.80
textMethod · 0.80
getMethod · 0.65
updateMethod · 0.65

Tested by

no test coverage detected