MCPcopy Create free account
hub / github.com/ChatLab/ChatLab / registerSystemRoutes

Function registerSystemRoutes

apps/desktop/main/api/routes/system.ts:13–91  ·  view source on GitHub ↗
(server: FastifyInstance)

Source from the content-addressed store, hash-verified

11import { getDesktopAppVersion } from '../../runtime-compat'
12
13export function registerSystemRoutes(server: FastifyInstance): void {
14 server.get('/api/v1/status', async () => {
15 let sessionCount = 0
16 try {
17 const sessions = await worker.getAllSessions()
18 sessionCount = sessions.length
19 } catch {
20 // ignore when worker not ready
21 }
22
23 return successResponse({
24 name: 'ChatLab API',
25 version: getDesktopAppVersion(app.getVersion()),
26 uptime: Math.floor(process.uptime()),
27 sessionCount,
28 })
29 })
30
31 server.get('/api/v1/schema', async () => {
32 return successResponse({
33 format: 'ChatLab Format',
34 version: '0.0.2',
35 spec: {
36 chatlab: {
37 type: 'object',
38 required: ['version'],
39 properties: {
40 version: { type: 'string' },
41 exportedAt: { type: 'number' },
42 generator: { type: 'string' },
43 },
44 },
45 meta: {
46 type: 'object',
47 required: ['name', 'platform', 'type'],
48 properties: {
49 name: { type: 'string' },
50 platform: {
51 type: 'string',
52 enum: ['qq', 'wechat', 'telegram', 'discord', 'line', 'whatsapp', 'instagram', 'unknown'],
53 },
54 type: { type: 'string', enum: ['group', 'private'] },
55 groupId: { type: 'string' },
56 },
57 },
58 members: {
59 type: 'array',
60 items: {
61 type: 'object',
62 required: ['platformId', 'accountName'],
63 properties: {
64 platformId: { type: 'string' },
65 accountName: { type: 'string' },
66 groupNickname: { type: 'string' },
67 avatar: { type: 'string' },
68 },
69 },
70 },

Callers 1

startFunction · 0.90

Calls 4

successResponseFunction · 0.90
getDesktopAppVersionFunction · 0.90
getMethod · 0.65
getVersionMethod · 0.65

Tested by

no test coverage detected