Archived
1
0
This repository has been archived on 2024-09-09. You can view files and clone it, but cannot push or open issues or pull requests.
code-server/src/node/routes/update.ts
2020-10-26 17:56:13 -05:00

35 lines
804 B
TypeScript

import { Router } from "express"
import { version } from "../constants"
import { ensureAuthenticated } from "../http"
import { UpdateProvider } from "../update"
export const router = Router()
const provider = new UpdateProvider()
router.use((req, _, next) => {
ensureAuthenticated(req)
next()
})
router.get("/", async (_, res) => {
const update = await provider.getUpdate()
res.json({
checked: update.checked,
latest: update.version,
current: version,
isLatest: provider.isLatestVersion(update),
})
})
// This route will force a check.
router.get("/check", async (_, res) => {
const update = await provider.getUpdate(true)
res.json({
checked: update.checked,
latest: update.version,
current: version,
isLatest: provider.isLatestVersion(update),
})
})