change default port, use for getting assets
This commit is contained in:
parent
996b596f96
commit
0c423c11da
3 changed files with 10 additions and 13 deletions
|
@ -1,6 +1,5 @@
|
|||
@import url('/assets/DMSans/style.css');
|
||||
body {
|
||||
font-family: 'DM Sans', sans-serif;
|
||||
font-family: 'DM Sans', Arial, Helvetica, sans-serif;
|
||||
margin: 0;
|
||||
}
|
||||
div {
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
import puppeteer from 'puppeteer'
|
||||
import fs from 'node:fs'
|
||||
|
||||
const style = fs.readFileSync('./assets/style.css', 'utf8')
|
||||
import { BASE_URL } from '../server.js'
|
||||
|
||||
const browser = await puppeteer.launch({
|
||||
defaultViewport: {
|
||||
|
@ -60,13 +58,11 @@ export async function renderPage(html) {
|
|||
}
|
||||
|
||||
export default async function (html, options = {}) {
|
||||
const fullHtml = `<link rel="stylesheet" href="${BASE_URL}/assets/style.css">
|
||||
<link rel="stylesheet" href="${BASE_URL}/assets/DMSans/style.css">
|
||||
${html}`
|
||||
if (options.format == 'html') {
|
||||
return await renderHtml(html)
|
||||
return fullHtml
|
||||
}
|
||||
return renderPage(`<style>${style}</style>${html}`)
|
||||
}
|
||||
|
||||
export async function renderHtml(html) {
|
||||
const styleNow = await fs.promises.readFile('./assets/style.css', 'utf8')
|
||||
return `<style>${styleNow}</style>${html}`
|
||||
return await renderPage(fullHtml)
|
||||
}
|
||||
|
|
|
@ -263,7 +263,9 @@ app.get('/:owner/:repo/pulls/:num', async function (req, res) {
|
|||
res.send(await render(html, app.locals.options))
|
||||
})
|
||||
|
||||
const [port, host] = [process.env.PORT ?? 9054, process.env.HOST ?? '127.0.0.1']
|
||||
const [port, host] = [process.env.PORT ?? 8000, process.env.HOST ?? '0.0.0.0']
|
||||
|
||||
export const BASE_URL = `http://${host}:${port}`
|
||||
|
||||
app.listen(port, host, () => {
|
||||
console.log(`Listening on http://${host}:${port}`)
|
||||
|
|
Loading…
Reference in a new issue