Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | import { readFileSync } from "fs"
import { join } from "path"
import { Request, Response } from "express"
const pkg = JSON.parse(readFileSync(join(process.cwd(), "package.json"), "utf-8")) as {
name: string
version: string
description?: string
author: string
license: string
repository?: string | { url: string }
}
function repositoryUrl(repo: typeof pkg.repository): string | undefined {
if (!repo) return undefined
const raw = typeof repo === "string" ? repo : repo.url
return raw.replace(/^git\+/, "").replace(/\.git$/, "")
}
export async function about(_req: Request, res: Response) {
res.render("about", {
name: pkg.name.charAt(0).toUpperCase() + pkg.name.slice(1),
version: pkg.version,
description: pkg.description ?? "",
author: pkg.author,
license: pkg.license,
repository: repositoryUrl(pkg.repository),
})
}
|