Skip to content

Commit fc09ba5

Browse files
committed
feat: 添加系统发现 API 和元数据发现 API,返回服务信息和可用元数据类型列表
1 parent 86fc690 commit fc09ba5

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

examples/server/src/index.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,42 @@ console.log('--- Plugins Loaded ---');
2020

2121
// 3. Define Unified Routes
2222

23+
/**
24+
* System Discovery API
25+
* GET /api/v1
26+
*/
27+
app.get('/api/v1', (c) => {
28+
return c.json({
29+
name: 'ObjectOS Local Server',
30+
version: '1.0.0',
31+
environment: 'development',
32+
routes: {
33+
discovery: '/api/v1',
34+
metadata: '/api/v1/meta',
35+
data: '/api/v1/data',
36+
auth: '/api/v1/auth'
37+
},
38+
capabilities: {
39+
search: true,
40+
files: true
41+
}
42+
});
43+
});
44+
45+
/**
46+
* Metadata Discovery API: List all available metadata types
47+
* GET /api/v1/meta
48+
*/
49+
app.get('/api/v1/meta', (c) => {
50+
const types = SchemaRegistry.getRegisteredTypes();
51+
const summary = types.map(type => ({
52+
type: type,
53+
href: `/api/v1/meta/${type}`,
54+
count: SchemaRegistry.listItems(type).length
55+
}));
56+
return c.json({ data: summary });
57+
});
58+
2359
/**
2460
* Unified Metadata API: List Items by Type
2561
* GET /api/v1/meta/objects

examples/server/src/kernel/registry.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ export class SchemaRegistry {
4242
return Array.from(this.metadata.get(type)?.values() || []) as T[];
4343
}
4444

45+
/**
46+
* Get all registered metadata types (Kinds)
47+
*/
48+
static getRegisteredTypes(): string[] {
49+
return Array.from(this.metadata.keys());
50+
}
51+
4552
// ==========================================
4653
// Typed Helper Methods (Shortcuts)
4754
// ==========================================

0 commit comments

Comments
 (0)