File tree Expand file tree Collapse file tree 3 files changed +54
-2
lines changed
Expand file tree Collapse file tree 3 files changed +54
-2
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,30 @@ app.get('/api/v1/meta/objects/:name', (c) => {
4343 return c . json ( schema ) ;
4444} ) ;
4545
46+ /**
47+ * Metadata API: Get All Apps
48+ */
49+ app . get ( '/api/v1/meta/apps' , ( c ) => {
50+ const apps = SchemaRegistry . getAllApps ( ) . map ( app => ( {
51+ name : app . name ,
52+ label : app . label ,
53+ icon : app . icon ,
54+ description : app . description ,
55+ path : `/api/v1/meta/apps/${ app . name } `
56+ } ) ) ;
57+ return c . json ( { data : apps } ) ;
58+ } ) ;
59+
60+ /**
61+ * Metadata API: Get Single App
62+ */
63+ app . get ( '/api/v1/meta/apps/:name' , ( c ) => {
64+ const name = c . req . param ( 'name' ) ;
65+ const app = SchemaRegistry . getApp ( name ) ;
66+ if ( ! app ) return c . json ( { error : 'Not found' } , 404 ) ;
67+ return c . json ( app ) ;
68+ } ) ;
69+
4670/**
4771 * Data API: Find
4872 */
@@ -120,7 +144,7 @@ app.delete('/api/v1/data/:object/:id', async (c) => {
120144} ) ;
121145
122146// 4. Start Server
123- const port = 3001 ;
147+ const port = 3003 ;
124148console . log ( `Server is running on http://localhost:${ port } ` ) ;
125149
126150serve ( {
Original file line number Diff line number Diff line change 1- import { ServiceObject } from '@objectstack/spec' ;
1+ import { ServiceObject , App } from '@objectstack/spec' ;
22
33/**
44 * Global Schema Registry
55 */
66export class SchemaRegistry {
77 private static objects = new Map < string , ServiceObject > ( ) ;
8+ private static apps = new Map < string , App > ( ) ;
89
10+ /**
11+ * Register a new object schema
12+ */
913 static register ( schema : ServiceObject ) {
1014 if ( this . objects . has ( schema . name ) ) {
1115 console . warn ( `[Registry] Overwriting object: ${ schema . name } ` ) ;
@@ -21,4 +25,23 @@ export class SchemaRegistry {
2125 static getAll ( ) : ServiceObject [ ] {
2226 return Array . from ( this . objects . values ( ) ) ;
2327 }
28+
29+ /**
30+ * Register a new app schema
31+ */
32+ static registerApp ( app : App ) {
33+ if ( this . apps . has ( app . name ) ) {
34+ console . warn ( `[Registry] Overwriting app: ${ app . name } ` ) ;
35+ }
36+ this . apps . set ( app . name , app ) ;
37+ console . log ( `[Registry] Registered app: ${ app . name } ` ) ;
38+ }
39+
40+ static getApp ( name : string ) : App | undefined {
41+ return this . apps . get ( name ) ;
42+ }
43+
44+ static getAllApps ( ) : App [ ] {
45+ return Array . from ( this . apps . values ( ) ) ;
46+ }
2447}
Original file line number Diff line number Diff line change 11import { SchemaRegistry } from './kernel/registry' ;
2+ import { AppSchema } from '@objectstack/spec' ;
23
34// In a real monorepo scenario, we might use path aliases or require.resolve
45// Here we use relative paths to demonstrate loading from the sibling packages
@@ -15,6 +16,10 @@ export function loadPlugins() {
1516
1617 console . log ( `[Loader] Loading App: ${ app . name } (${ app . label } )` ) ;
1718
19+ // 0. Register App
20+ const parsedApp = AppSchema . parse ( app ) ;
21+ SchemaRegistry . registerApp ( parsedApp ) ;
22+
1823 // 1. Register Objects
1924 if ( app . objects ) {
2025 app . objects . forEach ( ( obj : any ) => {
You can’t perform that action at this time.
0 commit comments