UNPKG

@gasket/plugin-service-worker

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