Ghost/core/server/web/admin/serviceworker.js
kirrg001 434a0435fd Optimised web/ debug logs
no issue

- optimised only for web/ folder, because it has used very general namespaces
- the debug namespace must be specific, otherwise i run `DEBUG=ghost:api:*` and i get web debug logs and api folder debug logs
- we can come up with a new namespace system, but for now it must be explicit enough
2018-10-04 17:43:08 +02:00

16 lines
533 B
JavaScript

const debug = require('ghost-ignition').debug('web:admin:serviceworker');
const path = require('path');
// Route: index
// Path: /ghost/sw.js|sw-registration.js
// Method: GET
module.exports = function adminController(req, res) {
debug('serviceworker called');
const sw = path.join(__dirname, '..', '..', '..', 'built', 'assets', 'sw.js'),
swr = path.join(__dirname, '..', '..', '..', 'built', 'assets', 'sw-registration.js'),
fileToSend = req.url === '/sw.js' ? sw : swr;
res.sendFile(fileToSend);
};