Merge branch 'master' into unfurler-refactor
This commit is contained in:
@@ -11,6 +11,7 @@ interface IConfig {
|
||||
NETWORK?: string;
|
||||
};
|
||||
PUPPETEER: {
|
||||
DISABLE: boolean;
|
||||
CLUSTER_SIZE: number;
|
||||
EXEC_PATH?: string;
|
||||
MAX_PAGE_AGE?: number;
|
||||
@@ -28,6 +29,7 @@ const defaults: IConfig = {
|
||||
'HTTP_PORT': 4200,
|
||||
},
|
||||
'PUPPETEER': {
|
||||
'DISABLE': false,
|
||||
'CLUSTER_SIZE': 1,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -39,12 +39,14 @@ class Server {
|
||||
.use(express.text())
|
||||
;
|
||||
|
||||
this.cluster = await Cluster.launch({
|
||||
concurrency: ReusablePage,
|
||||
maxConcurrency: config.PUPPETEER.CLUSTER_SIZE,
|
||||
puppeteerOptions: puppeteerConfig,
|
||||
});
|
||||
await this.cluster?.task(async (args) => { return this.clusterTask(args) });
|
||||
if (!config.PUPPETEER.DISABLE) {
|
||||
this.cluster = await Cluster.launch({
|
||||
concurrency: ReusablePage,
|
||||
maxConcurrency: config.PUPPETEER.CLUSTER_SIZE,
|
||||
puppeteerOptions: puppeteerConfig,
|
||||
});
|
||||
await this.cluster?.task(async (args) => { return this.clusterTask(args) });
|
||||
}
|
||||
|
||||
this.setUpRoutes();
|
||||
|
||||
@@ -66,7 +68,11 @@ class Server {
|
||||
}
|
||||
|
||||
setUpRoutes() {
|
||||
this.app.get('/render*', async (req, res) => { return this.renderPreview(req, res) })
|
||||
if (!config.PUPPETEER.DISABLE) {
|
||||
this.app.get('/render*', async (req, res) => { return this.renderPreview(req, res) })
|
||||
} else {
|
||||
this.app.get('/render*', async (req, res) => { return this.renderDisabled(req, res) })
|
||||
}
|
||||
this.app.get('*', (req, res) => { return this.renderHTML(req, res) })
|
||||
}
|
||||
|
||||
@@ -113,6 +119,10 @@ class Server {
|
||||
}
|
||||
}
|
||||
|
||||
async renderDisabled(req, res) {
|
||||
res.status(500).send("preview rendering disabled");
|
||||
}
|
||||
|
||||
async renderPreview(req, res) {
|
||||
try {
|
||||
const rawPath = req.params[0];
|
||||
@@ -169,7 +179,7 @@ class Server {
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>${ogTitle}</title>
|
||||
<meta name="description" content="The Mempool Open Source Project™ - our self-hosted explorer for the ${capitalize(this.network)} community."/>
|
||||
<meta name="description" content="The Mempool Open Source Project™ - Explore the full Bitcoin ecosystem with mempool.space™"/>
|
||||
<meta property="og:image" content="${ogImageUrl}"/>
|
||||
<meta property="og:image:type" content="image/png"/>
|
||||
<meta property="og:image:width" content="${matchedRoute.render ? 1200 : 1000}"/>
|
||||
@@ -179,7 +189,7 @@ class Server {
|
||||
<meta property="twitter:site" content="@mempool">
|
||||
<meta property="twitter:creator" content="@mempool">
|
||||
<meta property="twitter:title" content="${ogTitle}">
|
||||
<meta property="twitter:description" content="Our self-hosted mempool explorer for the ${capitalize(this.network)} community."/>
|
||||
<meta property="twitter:description" content="Explore the full Bitcoin ecosystem with mempool.space"/>
|
||||
<meta property="twitter:image:src" content="${ogImageUrl}"/>
|
||||
<meta property="twitter:domain" content="mempool.space">
|
||||
<body></body>
|
||||
|
||||
Reference in New Issue
Block a user