25 lines
599 B
JavaScript
25 lines
599 B
JavaScript
import express from 'express'
|
|
import { Eta } from 'eta'
|
|
import render from './lib/render.js'
|
|
const eta = new Eta({
|
|
views: 'views',
|
|
cache: false
|
|
})
|
|
|
|
const app = express()
|
|
|
|
app.get('/', function (req, res) {
|
|
res.redirect('https://git.gay/gitgay/og.git')
|
|
})
|
|
|
|
app.get('/:owner/:repo', async function (req, res) {
|
|
const repoResp = await fetch(
|
|
`https://git.gay/api/v1/repos/${req.params.owner}/${req.params.repo}`
|
|
)
|
|
const repo = await repoResp.json()
|
|
res.type('png')
|
|
res.set('Content-Disposition', 'inline')
|
|
res.send(await render(await eta.renderAsync('repo', { repo })))
|
|
})
|
|
|
|
app.listen(8085)
|