don't read html file on every html request

This commit is contained in:
Sean Yesmunt 2020-07-08 14:09:06 -04:00
parent d6f198afca
commit 6a38f944a6

View file

@ -152,10 +152,13 @@ async function getClaimFromChainquery(url) {
return undefined;
}
let html;
async function getHtml(ctx) {
const html = fs.readFileSync(path.join(__dirname, '/../dist/index.html'), 'utf8');
const requestPath = decodeURIComponent(ctx.path);
if (!html) {
html = fs.readFileSync(path.join(__dirname, '/../dist/index.html'), 'utf8');
}
const requestPath = decodeURIComponent(ctx.path);
if (requestPath.length === 0) {
const ogMetadata = buildBasicOgMetadata();
return insertToHead(html, ogMetadata);