From a72e4402224742c17bf3005f39bbabadd81487e9 Mon Sep 17 00:00:00 2001 From: hazycora Date: Wed, 2 Aug 2023 17:17:21 -0500 Subject: [PATCH] format --- server.js | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/server.js b/server.js index 68e1bad..a9f449c 100644 --- a/server.js +++ b/server.js @@ -2,7 +2,7 @@ import html2png from '@besties/html2png' import express from 'express' import fs from 'node:fs' -const app = express(); +const app = express() const figtreeRegular = fs.readFileSync('./assets/Figtree-Regular.woff') const figtreeMedium = fs.readFileSync('./assets/Figtree-Medium.woff') @@ -10,8 +10,6 @@ const figtreeExtraBold = fs.readFileSync('./assets/Figtree-ExtraBold.woff') const ATTR_REGEX = /["&]/g const CONTENT_REGEX = /[&<]/g - - function escape(value, is_attr = false) { const str = String(value) const pattern = is_attr ? ATTR_REGEX : CONTENT_REGEX @@ -30,20 +28,31 @@ function escape(value, is_attr = false) { return escaped + str.slice(Math.max(0, last)) } -app.get('/', function(req, res) { - res.redirect("https://git.gay/gitgay/og.git"); -}); +app.get('/', function (req, res) { + res.redirect('https://git.gay/gitgay/og.git') +}) -app.get('/:owner/:repo', async function(req, res) { - let repo = await (await fetch(`https://git.gay/api/v1/repos/${req.params.owner}/${req.params.repo}`)).json(); - let infoHtml = ` -

${escape(repo.owner.full_name)} ${escape(`@${repo.owner.login}`)}

-

${escape(repo.name)}

- `; +app.get('/:owner/:repo', async function (req, res) { + let repo = await ( + await fetch( + `https://git.gay/api/v1/repos/${req.params.owner}/${req.params.repo}` + ) + ).json() + let infoHtml = ` +

${escape( + repo.owner.full_name + )} ${escape(`@${repo.owner.login}`)}

+

${escape( + repo.name + )}

+ ` - if (repo.description) infoHtml = `${infoHtml}

${escape(repo.description)}

`; + if (repo.description) + infoHtml = `${infoHtml}

${escape( + repo.description + )}

` - let img = await html2png( + let img = await html2png( `
@@ -117,9 +126,9 @@ app.get('/:owner/:repo', async function(req, res) { } ] } - ); + ) - res.send(img); + res.send(img) }) -app.listen(8085); \ No newline at end of file +app.listen(8085)