@@ -117,6 +117,30 @@ bedrock.events.on('bedrock-express.configure.routes', app => {
117117 res . status ( 201 ) . location ( id ) . json ( record . config ) ;
118118 } ) ) ;
119119
120+ // get all keystores by controller query
121+ app . get (
122+ routes . keystores ,
123+ cors ( ) ,
124+ validate ( { querySchema : getConfigsQuery } ) ,
125+ middleware . authorizeZcapInvocation ( {
126+ async getExpectedValues ( ) {
127+ const { baseUri, host} = bedrock . config . server ;
128+ return {
129+ host,
130+ rootInvocationTarget : `${ baseUri } ${ routes . keystores } `
131+ } ;
132+ } ,
133+ async getRootController ( { req} ) {
134+ return req . query . controller ;
135+ }
136+ } ) ,
137+ asyncHandler ( async ( req , res ) => {
138+ const controller = req . query . controller ;
139+ const options = { projection : { _id : 0 , config : 1 } , limit : 100 } ;
140+ const results = await storage . getAll ( { controller, req, options} ) ;
141+ res . json ( { results} ) ;
142+ } ) ) ;
143+
120144 // update keystore config
121145 app . options ( routes . keystore , cors ( ) ) ;
122146 app . post (
@@ -175,30 +199,6 @@ bedrock.events.on('bedrock-express.configure.routes', app => {
175199 reportOperationUsage ( { req} ) ;
176200 } ) ) ;
177201
178- // get all keystores with root controller
179- app . get (
180- routes . keystores ,
181- cors ( ) ,
182- validate ( { querySchema : getConfigsQuery } ) ,
183- middleware . authorizeZcapInvocation ( {
184- async getExpectedValues ( ) {
185- const { baseUri, host} = bedrock . config . server ;
186- return {
187- host,
188- rootInvocationTarget : `${ baseUri } ${ routes . keystores } `
189- } ;
190- } ,
191- async getRootController ( { req} ) {
192- return req . query . controller ;
193- }
194- } ) ,
195- asyncHandler ( async ( req , res ) => {
196- const controller = req . query . controller ;
197- const options = { projection : { _id : 0 , config : 1 } , limit : 100 } ;
198- const results = await storage . getAll ( { controller, req, options} ) ;
199- res . json ( { results} ) ;
200- } ) ) ;
201-
202202 // get a keystore config
203203 app . get (
204204 routes . keystore ,
0 commit comments