Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
17 lines
792 B
JavaScript
17 lines
792 B
JavaScript
import { readFileSync } from 'node:fs'
|
|
|
|
const source = readFileSync(new URL('../public/sw.js', import.meta.url), 'utf8')
|
|
const required = ["event.request.mode === 'navigate'", "caches.match('/offline.html')", "url.pathname.startsWith('/api/')"]
|
|
const forbidden = ["PRECACHE_URLS = ['/'", "cache.put(event.request, responseClone);\n return response;\n })\n .catch(() => caches.match('/'))"]
|
|
const failures = [
|
|
...required.filter((value) => !source.includes(value)).map((value) => `missing policy: ${value}`),
|
|
...forbidden.filter((value) => source.includes(value)).map((value) => `unsafe policy: ${value}`),
|
|
]
|
|
|
|
if (failures.length) {
|
|
console.error(failures.join('\n'))
|
|
process.exit(1)
|
|
}
|
|
|
|
console.log('Service worker policy: private documents/API are not cached')
|