@@ -8,46 +8,18 @@ export const auth = new Auth();
88auth . init ( ) ;
99export const authMiddleware = auth . getAuthMiddleware ( ) ;
1010export const bearerMiddleware = auth . getBearerMiddleware ( ) ;
11- /*
12- // load all services from github repo
13- Router.get('/services', authMiddleware, async function (req: Request, res: Response) {
14- // #swagger.tags = ['UI']
15- // #swagger.summary = 'Get all services'
16-
17- axios.get('https://raw.githubusercontent.com/kubero-dev/kubero/main/services/index.yaml')
18- });
19-
20-
21- // load a specific service from github repo
22- Router.get('/services/:name', authMiddleware, async function (req: Request, res: Response) {
23- // #swagger.tags = ['UI']
24- // #swagger.summary = 'Get a specific service'
25- // #deprecated = true // since v1.11.0
26-
27- const serviceName = req.params.name.replace(/[^\w.-]+/g, '');
28-
29- const service = await axios.get('https://raw.githubusercontent.com/kubero-dev/kubero/main/services/' + serviceName + '/app.yaml')
30- .catch((err) => {
31- res
32- .status(500)
33- .send(err);
34- });
35- if (service) {
36- const ret = YAML.parse(service.data);
37- res.send(ret.spec);
38- }
39- });
40- */
4111
4212// load a specific service from github repo
43- Router . get ( '/templates/:catalogId/: template' , authMiddleware , async function ( req : Request , res : Response ) {
13+ Router . get ( '/templates/:template' , authMiddleware , async function ( req : Request , res : Response ) {
4414 // #swagger.tags = ['UI']
4515 // #swagger.summary = 'Get a specific template'
16+ // #swagger.description = 'Get a specific template from a catalog'
17+ // #swagger.parameters['template'] = { description: 'A base64 encoded URL', type: 'string' }
4618
47- const templateName = req . params . template . replace ( / [ ^ \w . - ] + / g , '' ) ;
48- const templateBasePath = await req . app . locals . kubero . getTemplateBasePath ( parseInt ( req . params . catalogId ) ) ;
19+ // decode the base64 encoded URL
20+ const templateUrl = Buffer . from ( req . params . template , 'base64' ) . toString ( 'ascii' ) ;
4921
50- const template = await axios . get ( templateBasePath + templateName + '/app.yaml' )
22+ const template = await axios . get ( templateUrl )
5123 . catch ( ( err ) => {
5224 res
5325 . status ( 500 )
@@ -58,15 +30,3 @@ Router.get('/templates/:catalogId/:template', authMiddleware, async function (re
5830 res . send ( ret . spec ) ;
5931 }
6032} ) ;
61-
62- // load a specific service from github repo
63- Router . get ( '/templates/:catalogId' , authMiddleware , async function ( req : Request , res : Response ) {
64- // #swagger.tags = ['UI']
65- // #swagger.summary = 'Get a specific template'
66-
67- const templateBasePath = await req . app . locals . kubero . getTemplateBasePath ( parseInt ( req . params . catalogId ) ) ;
68-
69-
70- axios . get ( templateBasePath + '/index.yaml' )
71- } ) ;
72-
0 commit comments