| 64 | const cookieSessionName = getCookieSessionName(args["cookie-suffix"]) |
| 65 | |
| 66 | const common: express.RequestHandler = (req, _, next) => { |
| 67 | // /healthz|/healthz/ needs to be excluded otherwise health checks will make |
| 68 | // it look like code-server is always in use. |
| 69 | if (!/^\/healthz\/?$/.test(req.url)) { |
| 70 | // NOTE@jsjoeio - intentionally not awaiting the .beat() call here because |
| 71 | // we don't want to slow down the request. |
| 72 | heart.beat() |
| 73 | } |
| 74 | |
| 75 | // Add common variables routes can use. |
| 76 | req.args = args |
| 77 | req.heart = heart |
| 78 | req.settings = settings |
| 79 | req.updater = updater |
| 80 | req.cookieSessionName = cookieSessionName |
| 81 | |
| 82 | next() |
| 83 | } |
| 84 | |
| 85 | app.router.use(common) |
| 86 | app.wsRouter.use(common) |