File tree Expand file tree Collapse file tree 3 files changed +54
-1
lines changed
Expand file tree Collapse file tree 3 files changed +54
-1
lines changed Original file line number Diff line number Diff line change 77 " examples/apps/*"
88 ],
99 "scripts" : {
10- "start" : " npm run start --workspace=@example/nestjs" ,
10+ "dev" : " npm run start:dev --workspace=@example/nestjs" ,
11+ "nestjs" : " npm run start --workspace=@example/nestjs" ,
1112 "express" : " npm run build --workspaces && npm start --workspace=@example/express" ,
1213 "build" : " npm run build --workspaces" ,
1314 "test" : " npm run test --workspaces" ,
Original file line number Diff line number Diff line change @@ -124,6 +124,25 @@ export function createObjectQLRouter(options: ObjectQLServerOptions): Router {
124124 }
125125 } ) ;
126126
127+ router . get ( '/_schema/:type' , async ( req : Request , res : Response ) => {
128+ try {
129+ const { type } = req . params ;
130+ const list = objectql . metadata . list ( type ) ;
131+ // Convert list to map for consistency
132+ const result : Record < string , any > = { } ;
133+ for ( const item of list ) {
134+ // assume item has id or name
135+ const key = item . id || item . name || item . code ;
136+ if ( key ) {
137+ result [ key ] = item ;
138+ }
139+ }
140+ res . json ( result ) ;
141+ } catch ( e : any ) {
142+ res . status ( 500 ) . json ( { error : e . message } ) ;
143+ }
144+ } ) ;
145+
127146 // NONE for now, as :objectName is the root.
128147 // However, we might want /:objectName/count or /:objectName/aggregate.
129148
Original file line number Diff line number Diff line change @@ -30,6 +30,39 @@ export function generateOpenApiSpec(objectql: IObjectQL) {
3030 }
3131 } ;
3232
33+ paths [ '/api/_schema/{type}' ] = {
34+ get : {
35+ summary : "Get Metadata by Type" ,
36+ tags : [ "System" ] ,
37+ parameters : [
38+ {
39+ name : "type" ,
40+ in : "path" ,
41+ required : true ,
42+ schema : {
43+ type : "string" ,
44+ enum : [ "object" , "app" ] ,
45+ example : "app"
46+ } ,
47+ description : "Metadata type"
48+ }
49+ ] ,
50+ responses : {
51+ 200 : {
52+ description : "Metadata configuration map" ,
53+ content : {
54+ 'application/json' : {
55+ schema : {
56+ type : 'object' ,
57+ additionalProperties : true
58+ }
59+ }
60+ }
61+ }
62+ }
63+ }
64+ } ;
65+
3366 Object . values ( configs ) . forEach ( ( config ) => {
3467 const objectName = config . name ;
3568 const schemaName = objectName ;
You can’t perform that action at this time.
0 commit comments