diff --git a/app.js b/app.js index b718e3772e9..16ee906007c 100644 --- a/app.js +++ b/app.js @@ -7,6 +7,7 @@ const bodyParser = require('body-parser'); const path = require('path'); const fs = require('fs'); +const ejs = require('ejs'); function create (env, ctx) { var app = express(); @@ -92,6 +93,15 @@ function create (env, ctx) { } app.locals.cachebuster = cacheBuster; + app.get("/sw.js", (req, res) => { + res.setHeader('Content-Type', 'application/javascript'); + res.send(ejs.render(fs.readFileSync( + require.resolve(`${__dirname}/views/service-worker.js`), + { encoding: 'utf-8' }), + { locals: app.locals} + )); + }); + if (ctx.bootErrors && ctx.bootErrors.length > 0) { app.get('*', require('./lib/server/booterror')(ctx)); return app; @@ -178,12 +188,6 @@ function create (env, ctx) { app.use("/clock", clockviews); - app.get("/appcache/*", (req, res) => { - res.render("nightscout.appcache", { - locals: app.locals - }); - }); - app.use('/api', bodyParser({ limit: 1048576 * 50 }), apiRoot); diff --git a/views/adminindex.html b/views/adminindex.html index c9bb631cfeb..9b4ff750d2e 100644 --- a/views/adminindex.html +++ b/views/adminindex.html @@ -26,10 +26,10 @@ - + - + <% include preloadCSS %>
@@ -39,8 +39,8 @@ <%- include('partials/authentication-status') %> - - - + + +