@gasket/plugin-service-worker
Version:
Gasket Service Worker Plugin
14 lines (12 loc) • 489 B
JavaScript
/// <reference types="@gasket/plugin-express" />
const { getSWConfig } = require('./utils/utils');
const configureEndpoint = require('./utils/configure-endpoint');
/**
* Express lifecycle to add an endpoint to serve service worker script
* @type {import('@gasket/core').HookHandler<'express'>}
*/
module.exports = async function express(gasket, app) {
const { staticOutput, url } = getSWConfig(gasket);
if (staticOutput) return;
app.get(url, await configureEndpoint(gasket));
};