2018-10-04 18:43:08 +03:00
|
|
|
const debug = require('ghost-ignition').debug('web:admin:serviceworker');
|
2018-09-20 16:03:33 +03:00
|
|
|
const 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);
|
|
|
|
};
|