mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-02-01 20:06:43 +01:00
19 lines
528 B
TypeScript
19 lines
528 B
TypeScript
|
import { handleBulk } from './bulk';
|
||
|
import { handleDownload } from './download';
|
||
|
|
||
|
// Declarations for TypeScript
|
||
|
declare const self: ServiceWorkerGlobalScope;
|
||
|
export default null;
|
||
|
|
||
|
/**
|
||
|
* Performs routing under the ServiceWorker path scope.
|
||
|
*/
|
||
|
self.addEventListener('fetch', event => {
|
||
|
const url = new URL(event.request.url);
|
||
|
|
||
|
if (url.pathname === '/js/stream') return handleBulk(event, url);
|
||
|
if (url.pathname === '/js/download') return handleDownload(event, url);
|
||
|
|
||
|
return event.respondWith(fetch(event.request));
|
||
|
});
|