Send unfurler fallback imgs directly
This commit is contained in:
		
							parent
							
								
									9aa778e44e
								
							
						
					
					
						commit
						8dbf9f29cf
					
				@ -9,7 +9,7 @@
 | 
			
		||||
  "main": "index.ts",
 | 
			
		||||
  "scripts": {
 | 
			
		||||
    "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",
 | 
			
		||||
    "unfurler": "node --max-old-space-size=4096 dist/index.js",
 | 
			
		||||
    "lint": "./node_modules/.bin/eslint . --ext .ts",
 | 
			
		||||
 | 
			
		||||
@ -8,6 +8,7 @@ import ReusablePage from './concurrency/ReusablePage';
 | 
			
		||||
import ReusableSSRPage from './concurrency/ReusablePage';
 | 
			
		||||
import { parseLanguageUrl } from './language/lang';
 | 
			
		||||
import { matchRoute } from './routes';
 | 
			
		||||
import nodejsPath from 'path';
 | 
			
		||||
import logger from './logger';
 | 
			
		||||
import { TimeoutError } from "puppeteer";
 | 
			
		||||
const puppeteerConfig = require('../puppeteer.config.json');
 | 
			
		||||
@ -228,11 +229,7 @@ class Server {
 | 
			
		||||
 | 
			
		||||
      if (!img) {
 | 
			
		||||
        // proxy fallback image from the frontend
 | 
			
		||||
        if (this.secureHost) {
 | 
			
		||||
          https.get(config.SERVER.HOST + matchedRoute.fallbackImg, (got) => got.pipe(res));
 | 
			
		||||
        } else {
 | 
			
		||||
          http.get(config.SERVER.HOST + matchedRoute.fallbackImg, (got) => got.pipe(res));
 | 
			
		||||
        }
 | 
			
		||||
        res.sendFile(nodejsPath.join(__dirname, matchedRoute.fallbackImg));
 | 
			
		||||
      } else {
 | 
			
		||||
        res.contentType('image/png');
 | 
			
		||||
        res.send(img);
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								unfurler/src/resources/img/bisq.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								unfurler/src/resources/img/bisq.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 94 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								unfurler/src/resources/img/dashboard.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								unfurler/src/resources/img/dashboard.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 289 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								unfurler/src/resources/img/lightning.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								unfurler/src/resources/img/lightning.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 1.8 MiB  | 
							
								
								
									
										
											BIN
										
									
								
								unfurler/src/resources/img/liquid.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								unfurler/src/resources/img/liquid.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 96 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								unfurler/src/resources/img/mempool.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								unfurler/src/resources/img/mempool.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 289 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								unfurler/src/resources/img/mining.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								unfurler/src/resources/img/mining.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 607 KiB  | 
@ -30,7 +30,7 @@ const routes = {
 | 
			
		||||
  },
 | 
			
		||||
  lightning: {
 | 
			
		||||
    title: "Lightning",
 | 
			
		||||
    fallbackImg: '/resources/previews/lightning.png',
 | 
			
		||||
    fallbackImg: '/resources/img/lightning.png',
 | 
			
		||||
    routes: {
 | 
			
		||||
      node: {
 | 
			
		||||
        render: true,
 | 
			
		||||
@ -68,7 +68,7 @@ const routes = {
 | 
			
		||||
  },
 | 
			
		||||
  mining: {
 | 
			
		||||
    title: "Mining",
 | 
			
		||||
    fallbackImg: '/resources/previews/mining.png',
 | 
			
		||||
    fallbackImg: '/resources/img/mining.png',
 | 
			
		||||
    routes: {
 | 
			
		||||
      pool: {
 | 
			
		||||
        render: true,
 | 
			
		||||
@ -83,13 +83,13 @@ const routes = {
 | 
			
		||||
 | 
			
		||||
const networks = {
 | 
			
		||||
  bitcoin: {
 | 
			
		||||
    fallbackImg: '/resources/previews/dashboard.png',
 | 
			
		||||
    fallbackImg: '/resources/img/dashboard.png',
 | 
			
		||||
    routes: {
 | 
			
		||||
      ...routes // all routes supported
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  liquid: {
 | 
			
		||||
    fallbackImg: '/resources/liquid/liquid-network-preview.png',
 | 
			
		||||
    fallbackImg: '/resources/img/liquid.png',
 | 
			
		||||
    routes: { // only block, address & tx routes supported
 | 
			
		||||
      block: routes.block,
 | 
			
		||||
      address: routes.address,
 | 
			
		||||
@ -97,7 +97,7 @@ const networks = {
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  bisq: {
 | 
			
		||||
    fallbackImg: '/resources/bisq/bisq-markets-preview.png',
 | 
			
		||||
    fallbackImg: '/resources/img/bisq.png',
 | 
			
		||||
    routes: {} // no routes supported
 | 
			
		||||
  }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user