diff --git a/routes/index.js b/routes/index.js index e044d9b..6f44022 100644 --- a/routes/index.js +++ b/routes/index.js @@ -37,6 +37,24 @@ router.get('/', function(req, res, next) { res.render('index', { title: 'Grafana SimpleJSON Value Mapper' }); }); +/** + * Reload data.json + */ +router.post('/reload', isAuthorized, function(req, res, next) { + + for (var k in require.cache) { + + if (! k.match(/\/server\/data.json$/)) continue; + + delete require.cache[k]; + break; + } + + data = require('../server/data.json'); + res.end(); + return; +}); + /** * This is the API endpoint that Grafana Simple JSON Datasources uses for metrics and template variables. */