@@ -8,46 +8,18 @@ export const auth = new Auth();
8
8
auth . init ( ) ;
9
9
export const authMiddleware = auth . getAuthMiddleware ( ) ;
10
10
export 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
- */
41
11
42
12
// 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 ) {
44
14
// #swagger.tags = ['UI']
45
15
// #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' }
46
18
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' ) ;
49
21
50
- const template = await axios . get ( templateBasePath + templateName + '/app.yaml' )
22
+ const template = await axios . get ( templateUrl )
51
23
. catch ( ( err ) => {
52
24
res
53
25
. status ( 500 )
@@ -58,15 +30,3 @@ Router.get('/templates/:catalogId/:template', authMiddleware, async function (re
58
30
res . send ( ret . spec ) ;
59
31
}
60
32
} ) ;
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