CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/hub/primus-client.ts
Views: 687
1
/* add endpoint that serves the primus client js code. */
2
3
const UglifyJS = require("uglify-js");
4
5
export default function setupPrimusClient(router, primus): void {
6
const primus_js = primus.library();
7
const primus_min_js: string = UglifyJS.minify(primus_js).code;
8
router.get("/primus.js", (_, res) => {
9
res.header("Content-Type", "text/javascript");
10
res.header("Cache-Control", `private, max-age=${60 * 60}, must-revalidate`);
11
res.send(primus_js);
12
});
13
router.get("/primus.min.js", (_, res) => {
14
res.header("Content-Type", "text/javascript");
15
res.header("Cache-Control", `private, max-age=${60 * 60}, must-revalidate`);
16
res.send(primus_min_js);
17
});
18
}
19
20