From b0c22efc230e4fbd0e0158d4609fc7562af6cd22 Mon Sep 17 00:00:00 2001 From: CataIana Date: Sat, 1 May 2021 17:11:20 +1000 Subject: [PATCH] Get / returns list of available templates --- index.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/index.js b/index.js index 4d2e7db..a160aa9 100644 --- a/index.js +++ b/index.js @@ -173,6 +173,23 @@ app.get('/debug/frame/', async (req, res) => { } }); +app.get('/', async (req, res) => { + try { + var templateList = []; + for (var key in templates) { + if(templates.hasOwnProperty(key)) { //to be safe + templateList.push(key); + } + } + console.log(templateList); + res.setHeader('Content-Type', 'application/json') + return res.end(JSON.stringify(templateList)); + } catch (err) { + console.log(err); + return res.status(400).end(err.message); + } +}); + app.get('/:templateName/', async (req, res) => { if (!templates[req.params.templateName]) return res.status(404).end(); try {