2018-07-12 16:35:35 +03:00
|
|
|
const debug = require('ghost-ignition').debug('admin:serviceworker'),
|
2017-12-06 19:37:54 +03:00
|
|
|
path = require('path');
|
2017-02-11 17:43:09 +03:00
|
|
|
|
|
|
|
// Route: index
|
|
|
|
// Path: /ghost/sw.js|sw-registration.js
|
|
|
|
// Method: GET
|
|
|
|
module.exports = function adminController(req, res) {
|
|
|
|
debug('serviceworker called');
|
|
|
|
|
2018-07-12 16:35:35 +03:00
|
|
|
const sw = path.join(__dirname, '..', '..', '..', 'built', 'assets', 'sw.js'),
|
2017-12-06 19:37:54 +03:00
|
|
|
swr = path.join(__dirname, '..', '..', '..', 'built', 'assets', 'sw-registration.js'),
|
2017-02-11 17:43:09 +03:00
|
|
|
fileToSend = req.url === '/sw.js' ? sw : swr;
|
|
|
|
|
|
|
|
res.sendFile(fileToSend);
|
|
|
|
};
|