Add explorer liquidity access and live route proxies
This commit is contained in:
93
scripts/check-explorer-health.sh
Executable file
93
scripts/check-explorer-health.sh
Executable file
@@ -0,0 +1,93 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
BASE_URL="${1:-https://explorer.d-bis.org}"
|
||||
|
||||
python3 - "$BASE_URL" <<'PY'
|
||||
import re
|
||||
import sys
|
||||
import requests
|
||||
|
||||
base = sys.argv[1].rstrip("/")
|
||||
session = requests.Session()
|
||||
session.headers.update({"User-Agent": "ExplorerHealthCheck/1.0"})
|
||||
|
||||
checks = [
|
||||
"/",
|
||||
"/home",
|
||||
"/blocks",
|
||||
"/transactions",
|
||||
"/addresses",
|
||||
"/bridge",
|
||||
"/weth",
|
||||
"/tokens",
|
||||
"/pools",
|
||||
"/watchlist",
|
||||
"/more",
|
||||
"/analytics",
|
||||
"/operator",
|
||||
"/liquidity",
|
||||
"/snap/",
|
||||
"/docs.html",
|
||||
"/privacy.html",
|
||||
"/terms.html",
|
||||
"/acknowledgments.html",
|
||||
"/api/v2/stats",
|
||||
"/api/config/token-list",
|
||||
"/api/config/networks",
|
||||
"/token-aggregation/api/v1/routes/tree?chainId=138&tokenIn=0x93E66202A11B1772E55407B32B44e5Cd8eda7f22&tokenOut=0x004b63A7B5b0E06f6bB6adb4a5F9f590BF3182D1&amountIn=1000000",
|
||||
"/token-aggregation/api/v1/routes/matrix",
|
||||
"/token-aggregation/api/v1/routes/ingestion?fromChainId=138&routeType=swap",
|
||||
"/token-aggregation/api/v1/routes/partner-payloads?partner=0x&amount=1000000&includeUnsupported=true",
|
||||
]
|
||||
|
||||
failed = False
|
||||
|
||||
print("== Core routes ==")
|
||||
for path in checks:
|
||||
url = base + path
|
||||
try:
|
||||
resp = session.get(url, timeout=20, allow_redirects=True)
|
||||
ctype = resp.headers.get("content-type", "")
|
||||
print(f"{resp.status_code:>3} {path} [{ctype[:50]}]")
|
||||
if resp.status_code >= 400:
|
||||
failed = True
|
||||
except Exception as exc:
|
||||
failed = True
|
||||
print(f"ERR {path} [{exc}]")
|
||||
|
||||
print("\n== Internal href targets from homepage ==")
|
||||
try:
|
||||
home = session.get(base + "/", timeout=20).text
|
||||
hrefs = sorted(set(re.findall(r'href="([^"]+)"', home)))
|
||||
for href in hrefs:
|
||||
if href.startswith("/") and not href.startswith("//"):
|
||||
resp = session.get(base + href, timeout=20, allow_redirects=True)
|
||||
print(f"{resp.status_code:>3} {href}")
|
||||
if resp.status_code >= 400:
|
||||
failed = True
|
||||
except Exception as exc:
|
||||
failed = True
|
||||
print(f"ERR homepage href sweep failed: {exc}")
|
||||
|
||||
print("\n== Static explorer domains referenced by bridge page ==")
|
||||
external_roots = [
|
||||
"https://etherscan.io/",
|
||||
"https://bscscan.com/",
|
||||
"https://polygonscan.com/",
|
||||
"https://subnets.avax.network/c-chain",
|
||||
"https://basescan.org/",
|
||||
"https://arbiscan.io/",
|
||||
"https://optimistic.etherscan.io/",
|
||||
]
|
||||
for url in external_roots:
|
||||
try:
|
||||
resp = session.get(url, timeout=20, allow_redirects=True)
|
||||
print(f"{resp.status_code:>3} {url}")
|
||||
except Exception as exc:
|
||||
print(f"ERR {url} [{exc}]")
|
||||
|
||||
if failed:
|
||||
sys.exit(1)
|
||||
PY
|
||||
@@ -115,6 +115,30 @@ server {
|
||||
add_header Access-Control-Allow-Origin *;
|
||||
}
|
||||
|
||||
location /token-aggregation/api/v1/ {
|
||||
proxy_pass http://192.168.11.140:3001/api/v1/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_read_timeout 60s;
|
||||
add_header Access-Control-Allow-Origin *;
|
||||
}
|
||||
|
||||
location = /api/config/token-list {
|
||||
default_type application/json;
|
||||
add_header Access-Control-Allow-Origin *;
|
||||
add_header Cache-Control "public, max-age=3600";
|
||||
alias /var/www/html/config/DUAL_CHAIN_TOKEN_LIST.tokenlist.json;
|
||||
}
|
||||
location = /api/config/networks {
|
||||
default_type application/json;
|
||||
add_header Access-Control-Allow-Origin *;
|
||||
add_header Cache-Control "public, max-age=3600";
|
||||
alias /var/www/html/config/DUAL_CHAIN_NETWORKS.json;
|
||||
}
|
||||
|
||||
location = / {
|
||||
root /var/www/html;
|
||||
try_files /index.html =404;
|
||||
@@ -147,6 +171,12 @@ server {
|
||||
try_files /index.html =404;
|
||||
}
|
||||
|
||||
location ~ ^/(address|tx|block|token|tokens|blocks|transactions|bridge|weth|liquidity|watchlist|nft|home|analytics|operator|more|pools)(/|$) {
|
||||
root /var/www/html;
|
||||
try_files /index.html =404;
|
||||
add_header Cache-Control "no-store, no-cache, must-revalidate";
|
||||
}
|
||||
|
||||
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
||||
root /var/www/html;
|
||||
expires 1y;
|
||||
@@ -165,6 +195,17 @@ server {
|
||||
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS";
|
||||
add_header Access-Control-Allow-Headers "Content-Type";
|
||||
}
|
||||
|
||||
location /token-aggregation/api/v1/ {
|
||||
proxy_pass http://192.168.11.140:3001/api/v1/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_read_timeout 60s;
|
||||
add_header Access-Control-Allow-Origin *;
|
||||
}
|
||||
}
|
||||
NGINX_CONF
|
||||
|
||||
|
||||
@@ -47,6 +47,34 @@ server {
|
||||
add_header Access-Control-Allow-Headers "Content-Type";
|
||||
}
|
||||
|
||||
# Token-aggregation API for live route-tree, quotes, and market data
|
||||
location /token-aggregation/api/v1/ {
|
||||
proxy_pass http://127.0.0.1:3001/api/v1/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_read_timeout 60s;
|
||||
add_header Access-Control-Allow-Origin *;
|
||||
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS";
|
||||
add_header Access-Control-Allow-Headers "Content-Type";
|
||||
}
|
||||
|
||||
# Explorer config API (token list, networks) - serve from /var/www/html/config/
|
||||
location = /api/config/token-list {
|
||||
default_type application/json;
|
||||
add_header Access-Control-Allow-Origin *;
|
||||
add_header Cache-Control "public, max-age=3600";
|
||||
alias /var/www/html/config/DUAL_CHAIN_TOKEN_LIST.tokenlist.json;
|
||||
}
|
||||
location = /api/config/networks {
|
||||
default_type application/json;
|
||||
add_header Access-Control-Allow-Origin *;
|
||||
add_header Cache-Control "public, max-age=3600";
|
||||
alias /var/www/html/config/DUAL_CHAIN_NETWORKS.json;
|
||||
}
|
||||
|
||||
location /health {
|
||||
access_log off;
|
||||
proxy_pass http://127.0.0.1:4000/api/v2/status;
|
||||
@@ -95,7 +123,7 @@ server {
|
||||
}
|
||||
|
||||
# SPA paths on HTTP (for internal/LAN tests) - serve index.html before redirect
|
||||
location ~ ^/(address|tx|block|token|tokens|blocks|transactions|bridge|weth|watchlist|nft|home|analytics|operator)(/|$) {
|
||||
location ~ ^/(address|tx|block|token|tokens|blocks|transactions|bridge|weth|liquidity|watchlist|nft|home|analytics|operator)(/|$) {
|
||||
root /var/www/html;
|
||||
try_files /index.html =404;
|
||||
add_header Cache-Control "no-store, no-cache, must-revalidate";
|
||||
@@ -171,7 +199,7 @@ server {
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
|
||||
# Token-aggregation API at /api/v1/ (Chain 138 Snap: market data, swap quote, bridge). Service runs on port 3001.
|
||||
# Token-aggregation API at /api/v1/ for the Snap site. Service runs on port 3001.
|
||||
location /api/v1/ {
|
||||
proxy_pass http://127.0.0.1:3001/api/v1/;
|
||||
proxy_http_version 1.1;
|
||||
@@ -183,6 +211,18 @@ server {
|
||||
add_header Access-Control-Allow-Origin *;
|
||||
}
|
||||
|
||||
# Token-aggregation API for the explorer SPA live route-tree and pool intelligence.
|
||||
location /token-aggregation/api/v1/ {
|
||||
proxy_pass http://127.0.0.1:3001/api/v1/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_read_timeout 60s;
|
||||
add_header Access-Control-Allow-Origin *;
|
||||
}
|
||||
|
||||
# Explorer config API (token list, networks) - serve from /var/www/html/config/
|
||||
location = /api/config/token-list {
|
||||
default_type application/json;
|
||||
@@ -231,9 +271,9 @@ server {
|
||||
proxy_connect_timeout 75s;
|
||||
}
|
||||
|
||||
# SPA paths: /address, /tx, /block, /token, /tokens, /blocks, /transactions, /bridge, /weth, /watchlist, /nft, /home, /analytics, /operator
|
||||
# SPA paths: /address, /tx, /block, /token, /tokens, /blocks, /transactions, /bridge, /weth, /liquidity, /watchlist, /nft, /home, /analytics, /operator
|
||||
# Must serve index.html so path-based routing works (regex takes precedence over proxy)
|
||||
location ~ ^/(address|tx|block|token|tokens|blocks|transactions|bridge|weth|watchlist|nft|home|analytics|operator)(/|$) {
|
||||
location ~ ^/(address|tx|block|token|tokens|blocks|transactions|bridge|weth|liquidity|watchlist|nft|home|analytics|operator)(/|$) {
|
||||
root /var/www/html;
|
||||
try_files /index.html =404;
|
||||
add_header Cache-Control "no-store, no-cache, must-revalidate";
|
||||
@@ -334,4 +374,3 @@ echo "Next steps:"
|
||||
echo "1. Deploy custom frontend: ./scripts/deploy-frontend-to-vmid5000.sh"
|
||||
echo "2. Or manually copy: cp explorer-monorepo/frontend/public/index.html /var/www/html/index.html"
|
||||
echo ""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user