Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3512335
D6716.id22817.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D6716.id22817.diff
View Options
diff --git a/keyserver/src/keyserver.js b/keyserver/src/keyserver.js
--- a/keyserver/src/keyserver.js
+++ b/keyserver/src/keyserver.js
@@ -24,6 +24,7 @@
markVersionDeployedResponder,
} from './responders/version-responders.js';
import { websiteResponder } from './responders/website-responders.js';
+import { webWorkerResponder } from './responders/webworker-responders.js';
import { onConnection } from './socket/socket.js';
import {
multerProcessor,
@@ -119,6 +120,7 @@
// $FlowFixMe express-ws has side effects that can't be typed
router.ws('/ws', onConnection);
+ router.get('/worker/:worker', webWorkerResponder);
router.get('*', htmlHandler(websiteResponder));
router.post(
diff --git a/keyserver/src/responders/webworker-responders.js b/keyserver/src/responders/webworker-responders.js
new file mode 100644
--- /dev/null
+++ b/keyserver/src/responders/webworker-responders.js
@@ -0,0 +1,29 @@
+// @flow
+
+import type { $Request, $Response } from 'express';
+import path from 'path';
+
+function webWorkerResponder(req: $Request, res: $Response): void {
+ let workerPath;
+ let headers = { 'Content-Type': 'application/javascript' };
+
+ if (req.params.worker === 'notif') {
+ workerPath = 'pushNotif.build.js';
+ headers = {
+ ...headers,
+ 'Service-Worker-Allowed': '/',
+ };
+ }
+
+ if (!workerPath) {
+ res.sendStatus(404);
+ return;
+ }
+
+ const filePath = path.resolve('app_compiled', 'webworkers', workerPath);
+ res.sendFile(filePath, {
+ headers,
+ });
+}
+
+export { webWorkerResponder };
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 22, 7:20 PM (17 h, 50 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2692233
Default Alt Text
D6716.id22817.diff (1 KB)
Attached To
Mode
D6716: [keyserver] Serve web worker files
Attached
Detach File
Event Timeline
Log In to Comment