Endpoint
diff --git a/frontend/src/app/docs/api-docs/api-docs.component.scss b/frontend/src/app/docs/api-docs/api-docs.component.scss
index ed7b79636..a139288e7 100644
--- a/frontend/src/app/docs/api-docs/api-docs.component.scss
+++ b/frontend/src/app/docs/api-docs/api-docs.component.scss
@@ -204,6 +204,7 @@ h3 {
margin: 20px 0 20px 0;
font-size: 24px;
position: relative;
+ cursor: pointer;
}
.endpoint-container .section-header:hover {
text-decoration: none;
diff --git a/frontend/src/app/docs/api-docs/api-docs.component.ts b/frontend/src/app/docs/api-docs/api-docs.component.ts
index 3f5ce75e5..3198d80c6 100644
--- a/frontend/src/app/docs/api-docs/api-docs.component.ts
+++ b/frontend/src/app/docs/api-docs/api-docs.component.ts
@@ -56,7 +56,10 @@ export class ApiDocsComponent implements OnInit, AfterViewInit {
if( this.route.snapshot.fragment ) {
this.openEndpointContainer( this.route.snapshot.fragment );
if (document.getElementById( this.route.snapshot.fragment )) {
- document.getElementById( this.route.snapshot.fragment ).scrollIntoView();
+ let vOffset = ( window.innerWidth <= 992 ) ? 100 : 60;
+ window.scrollTo({
+ top: document.getElementById( this.route.snapshot.fragment ).offsetTop - vOffset
+ });
}
}
window.addEventListener('scroll', that.onDocScroll, { passive: true });
@@ -124,20 +127,13 @@ export class ApiDocsComponent implements OnInit, AfterViewInit {
this.desktopDocsNavPosition = ( window.pageYOffset > 115 ) ? "fixed" : "relative";
}
- anchorLinkClick( event: any ) {
- let targetId = "";
- if( event.target.nodeName === "A" ) {
- targetId = event.target.hash.substring(1);
- } else {
- let element = event.target;
- while( element.nodeName !== "A" ) {
- element = element.parentElement;
- }
- targetId = element.hash.substring(1);
- }
- if( this.route.snapshot.fragment === targetId && document.getElementById( targetId )) {
- document.getElementById( targetId ).scrollIntoView();
- }
+ anchorLinkClick( e ) {
+ let targetId = e.fragment;
+ let vOffset = ( window.innerWidth <= 992 ) ? 100 : 60;
+ window.scrollTo({
+ top: document.getElementById( targetId ).offsetTop - vOffset
+ });
+ window.history.pushState({}, null, document.location.href.split("#")[0] + "#" + targetId);
this.openEndpointContainer( targetId );
}
From dab9357b40661a5d5e8e369a31cdc47b9868900c Mon Sep 17 00:00:00 2001
From: nymkappa <1612910616@pm.me>
Date: Thu, 4 Apr 2024 13:56:39 +0900
Subject: [PATCH 2/3] [about page] proxy community sponsors apis to prod, small
refactor
---
backend/src/api/about.routes.ts | 87 +++++++++++++++++++++++
backend/src/api/bitcoin/bitcoin.routes.ts | 54 --------------
backend/src/index.ts | 2 +
3 files changed, 89 insertions(+), 54 deletions(-)
create mode 100644 backend/src/api/about.routes.ts
diff --git a/backend/src/api/about.routes.ts b/backend/src/api/about.routes.ts
new file mode 100644
index 000000000..5e7d3b70e
--- /dev/null
+++ b/backend/src/api/about.routes.ts
@@ -0,0 +1,87 @@
+import { Application } from "express";
+import config from "../config";
+import axios from "axios";
+import logger from "../logger";
+
+class AboutRoutes {
+ public initRoutes(app: Application) {
+ app
+ .get(config.MEMPOOL.API_URL_PREFIX + 'donations', async (req, res) => {
+ try {
+ const response = await axios.get(`${config.EXTERNAL_DATA_SERVER.MEMPOOL_API}/donations`, { responseType: 'stream', timeout: 10000 });
+ response.data.pipe(res);
+ } catch (e) {
+ res.status(500).end();
+ }
+ })
+ .get(config.MEMPOOL.API_URL_PREFIX + 'donations/images/:id', async (req, res) => {
+ try {
+ const response = await axios.get(`${config.EXTERNAL_DATA_SERVER.MEMPOOL_API}/donations/images/${req.params.id}`, {
+ responseType: 'stream', timeout: 10000
+ });
+ response.data.pipe(res);
+ } catch (e) {
+ res.status(500).end();
+ }
+ })
+ .get(config.MEMPOOL.API_URL_PREFIX + 'contributors', async (req, res) => {
+ try {
+ const response = await axios.get(`${config.EXTERNAL_DATA_SERVER.MEMPOOL_API}/contributors`, { responseType: 'stream', timeout: 10000 });
+ response.data.pipe(res);
+ } catch (e) {
+ res.status(500).end();
+ }
+ })
+ .get(config.MEMPOOL.API_URL_PREFIX + 'contributors/images/:id', async (req, res) => {
+ try {
+ const response = await axios.get(`${config.EXTERNAL_DATA_SERVER.MEMPOOL_API}/contributors/images/${req.params.id}`, {
+ responseType: 'stream', timeout: 10000
+ });
+ response.data.pipe(res);
+ } catch (e) {
+ res.status(500).end();
+ }
+ })
+ .get(config.MEMPOOL.API_URL_PREFIX + 'translators', async (req, res) => {
+ try {
+ const response = await axios.get(`${config.EXTERNAL_DATA_SERVER.MEMPOOL_API}/translators`, { responseType: 'stream', timeout: 10000 });
+ response.data.pipe(res);
+ } catch (e) {
+ res.status(500).end();
+ }
+ })
+ .get(config.MEMPOOL.API_URL_PREFIX + 'translators/images/:id', async (req, res) => {
+ try {
+ const response = await axios.get(`${config.EXTERNAL_DATA_SERVER.MEMPOOL_API}/translators/images/${req.params.id}`, {
+ responseType: 'stream', timeout: 10000
+ });
+ response.data.pipe(res);
+ } catch (e) {
+ res.status(500).end();
+ }
+ })
+ .get(config.MEMPOOL.API_URL_PREFIX + 'services/sponsors', async (req, res) => {
+ const url = `${config.MEMPOOL_SERVICES.API}/${req.originalUrl.replace('/api/v1/services/', '')}`;
+ try {
+ const response = await axios.get(url, { responseType: 'stream', timeout: 10000 });
+ response.data.pipe(res);
+ } catch (e) {
+ logger.err(`Unable to fetch sponsors from ${url}. ${e}`, 'About Page');
+ res.status(500).end();
+ }
+ })
+ .get(config.MEMPOOL.API_URL_PREFIX + 'services/account/images/:username', async (req, res) => {
+ const url = `${config.MEMPOOL_SERVICES.API}/${req.originalUrl.replace('/api/v1/services/', '')}`;
+ try {
+ const response = await axios.get(url, { responseType: 'stream', timeout: 10000 });
+ response.data.pipe(res);
+ } catch (e) {
+ logger.err(`Unable to fetch sponsor profile image from ${url}. ${e}`, 'About Page');
+ res.status(500).end();
+ }
+ })
+ ;
+ }
+}
+
+export default new AboutRoutes();
\ No newline at end of file
diff --git a/backend/src/api/bitcoin/bitcoin.routes.ts b/backend/src/api/bitcoin/bitcoin.routes.ts
index 29c3f7c21..a82cda3f0 100644
--- a/backend/src/api/bitcoin/bitcoin.routes.ts
+++ b/backend/src/api/bitcoin/bitcoin.routes.ts
@@ -37,60 +37,6 @@ class BitcoinRoutes {
.get(config.MEMPOOL.API_URL_PREFIX + 'replacements', this.getRbfReplacements)
.get(config.MEMPOOL.API_URL_PREFIX + 'fullrbf/replacements', this.getFullRbfReplacements)
.post(config.MEMPOOL.API_URL_PREFIX + 'tx/push', this.$postTransactionForm)
- .get(config.MEMPOOL.API_URL_PREFIX + 'donations', async (req, res) => {
- try {
- const response = await axios.get(`${config.EXTERNAL_DATA_SERVER.MEMPOOL_API}/donations`, { responseType: 'stream', timeout: 10000 });
- response.data.pipe(res);
- } catch (e) {
- res.status(500).end();
- }
- })
- .get(config.MEMPOOL.API_URL_PREFIX + 'donations/images/:id', async (req, res) => {
- try {
- const response = await axios.get(`${config.EXTERNAL_DATA_SERVER.MEMPOOL_API}/donations/images/${req.params.id}`, {
- responseType: 'stream', timeout: 10000
- });
- response.data.pipe(res);
- } catch (e) {
- res.status(500).end();
- }
- })
- .get(config.MEMPOOL.API_URL_PREFIX + 'contributors', async (req, res) => {
- try {
- const response = await axios.get(`${config.EXTERNAL_DATA_SERVER.MEMPOOL_API}/contributors`, { responseType: 'stream', timeout: 10000 });
- response.data.pipe(res);
- } catch (e) {
- res.status(500).end();
- }
- })
- .get(config.MEMPOOL.API_URL_PREFIX + 'contributors/images/:id', async (req, res) => {
- try {
- const response = await axios.get(`${config.EXTERNAL_DATA_SERVER.MEMPOOL_API}/contributors/images/${req.params.id}`, {
- responseType: 'stream', timeout: 10000
- });
- response.data.pipe(res);
- } catch (e) {
- res.status(500).end();
- }
- })
- .get(config.MEMPOOL.API_URL_PREFIX + 'translators', async (req, res) => {
- try {
- const response = await axios.get(`${config.EXTERNAL_DATA_SERVER.MEMPOOL_API}/translators`, { responseType: 'stream', timeout: 10000 });
- response.data.pipe(res);
- } catch (e) {
- res.status(500).end();
- }
- })
- .get(config.MEMPOOL.API_URL_PREFIX + 'translators/images/:id', async (req, res) => {
- try {
- const response = await axios.get(`${config.EXTERNAL_DATA_SERVER.MEMPOOL_API}/translators/images/${req.params.id}`, {
- responseType: 'stream', timeout: 10000
- });
- response.data.pipe(res);
- } catch (e) {
- res.status(500).end();
- }
- })
.get(config.MEMPOOL.API_URL_PREFIX + 'blocks', this.getBlocks.bind(this))
.get(config.MEMPOOL.API_URL_PREFIX + 'blocks/:height', this.getBlocks.bind(this))
.get(config.MEMPOOL.API_URL_PREFIX + 'block/:hash', this.getBlock)
diff --git a/backend/src/index.ts b/backend/src/index.ts
index b28e9ccbf..f17020cf8 100644
--- a/backend/src/index.ts
+++ b/backend/src/index.ts
@@ -43,6 +43,7 @@ import redisCache from './api/redis-cache';
import accelerationApi from './api/services/acceleration';
import bitcoinCoreRoutes from './api/bitcoin/bitcoin-core.routes';
import bitcoinSecondClient from './api/bitcoin/bitcoin-second-client';
+import aboutRoutes from './api/about.routes';
class Server {
private wss: WebSocket.Server | undefined;
@@ -305,6 +306,7 @@ class Server {
nodesRoutes.initRoutes(this.app);
channelsRoutes.initRoutes(this.app);
}
+ aboutRoutes.initRoutes(this.app);
}
healthCheck(): void {
From abdb27af3f45f15c43fb5e43980a79854eb83480 Mon Sep 17 00:00:00 2001
From: nymkappa <1612910616@pm.me>
Date: Thu, 4 Apr 2024 14:27:50 +0900
Subject: [PATCH 3/3] [migration] reset mining pool sha to force refreshing
---
backend/src/api/database-migration.ts | 1 +
1 file changed, 1 insertion(+)
diff --git a/backend/src/api/database-migration.ts b/backend/src/api/database-migration.ts
index 278cd2631..81f2caa44 100644
--- a/backend/src/api/database-migration.ts
+++ b/backend/src/api/database-migration.ts
@@ -655,6 +655,7 @@ class DatabaseMigration {
await this.$executeQuery('TRUNCATE hashrates');
await this.$executeQuery('TRUNCATE difficulty_adjustments');
+ await this.$executeQuery(`UPDATE state SET string = NULL WHERE name = 'pools_json_sha'`);
await this.updateToSchemaVersion(75);
}