Merge pull request #4107 from mempool/mononaut/unfurler-fixes

Quick fixes for unfurler/seo renderer
This commit is contained in:
wiz 2023-08-13 15:40:22 +09:00 committed by GitHub
commit e9165e5dd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 14 additions and 13 deletions

View File

@ -72,11 +72,9 @@ export class SeoService {
clearSoft404() { clearSoft404() {
window['soft404'] = false; window['soft404'] = false;
console.log('cleared soft 404');
} }
logSoft404() { logSoft404() {
window['soft404'] = true; window['soft404'] = true;
console.log('set soft 404');
} }
} }

View File

@ -9,7 +9,7 @@
"main": "index.ts", "main": "index.ts",
"scripts": { "scripts": {
"tsc": "./node_modules/typescript/bin/tsc", "tsc": "./node_modules/typescript/bin/tsc",
"build": "npm run tsc", "build": "npm run tsc && cp -r src/resources dist/resources",
"start": "node --max-old-space-size=2048 dist/index.js", "start": "node --max-old-space-size=2048 dist/index.js",
"unfurler": "node --max-old-space-size=4096 dist/index.js", "unfurler": "node --max-old-space-size=4096 dist/index.js",
"lint": "./node_modules/.bin/eslint . --ext .ts", "lint": "./node_modules/.bin/eslint . --ext .ts",

View File

@ -8,6 +8,7 @@ import ReusablePage from './concurrency/ReusablePage';
import ReusableSSRPage from './concurrency/ReusablePage'; import ReusableSSRPage from './concurrency/ReusablePage';
import { parseLanguageUrl } from './language/lang'; import { parseLanguageUrl } from './language/lang';
import { matchRoute } from './routes'; import { matchRoute } from './routes';
import nodejsPath from 'path';
import logger from './logger'; import logger from './logger';
import { TimeoutError } from "puppeteer"; import { TimeoutError } from "puppeteer";
const puppeteerConfig = require('../puppeteer.config.json'); const puppeteerConfig = require('../puppeteer.config.json');
@ -50,6 +51,12 @@ class Server {
this.canonicalHost = canonical; this.canonicalHost = canonical;
this.startServer(); this.startServer();
setTimeout(async () => {
logger.info(`killing myself now`);
await this.stopServer();
process.exit(0);
}, 3600_000 * (1 + Math.random()))
} }
async startServer() { async startServer() {
@ -222,11 +229,7 @@ class Server {
if (!img) { if (!img) {
// proxy fallback image from the frontend // proxy fallback image from the frontend
if (this.secureHost) { res.sendFile(nodejsPath.join(__dirname, matchedRoute.fallbackImg));
https.get(config.SERVER.HOST + matchedRoute.fallbackImg, (got) => got.pipe(res));
} else {
http.get(config.SERVER.HOST + matchedRoute.fallbackImg, (got) => got.pipe(res));
}
} else { } else {
res.contentType('image/png'); res.contentType('image/png');
res.send(img); res.send(img);

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 289 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 289 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 607 KiB

View File

@ -30,7 +30,7 @@ const routes = {
}, },
lightning: { lightning: {
title: "Lightning", title: "Lightning",
fallbackImg: '/resources/previews/lightning.png', fallbackImg: '/resources/img/lightning.png',
routes: { routes: {
node: { node: {
render: true, render: true,
@ -68,7 +68,7 @@ const routes = {
}, },
mining: { mining: {
title: "Mining", title: "Mining",
fallbackImg: '/resources/previews/mining.png', fallbackImg: '/resources/img/mining.png',
routes: { routes: {
pool: { pool: {
render: true, render: true,
@ -83,13 +83,13 @@ const routes = {
const networks = { const networks = {
bitcoin: { bitcoin: {
fallbackImg: '/resources/previews/dashboard.png', fallbackImg: '/resources/img/dashboard.png',
routes: { routes: {
...routes // all routes supported ...routes // all routes supported
} }
}, },
liquid: { liquid: {
fallbackImg: '/resources/liquid/liquid-network-preview.png', fallbackImg: '/resources/img/liquid.png',
routes: { // only block, address & tx routes supported routes: { // only block, address & tx routes supported
block: routes.block, block: routes.block,
address: routes.address, address: routes.address,
@ -97,7 +97,7 @@ const networks = {
} }
}, },
bisq: { bisq: {
fallbackImg: '/resources/bisq/bisq-markets-preview.png', fallbackImg: '/resources/img/bisq.png',
routes: {} // no routes supported routes: {} // no routes supported
} }
}; };