JOHN SILLVESTOR commited on
Commit
a412982
·
verified ·
1 Parent(s): 15f682b

official docker api card

Browse files
Files changed (1) hide show
  1. server.js +15 -2
server.js CHANGED
@@ -582,6 +582,18 @@ function handleHealth(res) {
582
  });
583
  }
584
 
 
 
 
 
 
 
 
 
 
 
 
 
585
  async function onReq(req, res) {
586
  cors(req, res);
587
  if (req.method === "OPTIONS") {
@@ -594,7 +606,8 @@ async function onReq(req, res) {
594
  return res.end();
595
  }
596
  try {
597
- if (url.pathname === "/" || url.pathname === "/health") return handleHealth(res);
 
598
  if (url.pathname === "/public/bootstrap") return handleBootstrap(req, res, url);
599
  if (url.pathname === "/generate-token" && req.method === "GET") return handleGenerate(req, res, url);
600
  if (url.pathname === "/vip/status" && req.method === "GET") return handleVipStatus(req, res);
@@ -613,7 +626,7 @@ async function onReq(req, res) {
613
 
614
  async function main() {
615
  if (!API_ID || !API_HASH || !STREAM_SECRET) {
616
- process.stderr.write("missing TELEGRAM_API_ID / TELEGRAM_API_HASH / STREAM_SECRET\n");
617
  process.exit(1);
618
  }
619
  const tokens = String(process.env.BOT_TOKENS || "")
 
582
  });
583
  }
584
 
585
+ function handleHome(req, res) {
586
+ const acc = String(req.headers.accept || "");
587
+ if (!acc.includes("text/html")) return handleHealth(res);
588
+ res.writeHead(200, {
589
+ "Content-Type": "text/html; charset=utf-8",
590
+ "Cache-Control": "no-store"
591
+ });
592
+ res.end(
593
+ "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width,initial-scale=1\"><title>DUBLK Studio</title><style>body{font-family:system-ui,sans-serif;margin:2.5rem auto;max-width:36rem;line-height:1.55;color:#111827}a{color:#4f46e5}</style></head><body><h1>DUBLK Studio</h1><p>Node.js HTTP API for the public DUBLK blog demo.</p><p><a href=\"/health\">Health status</a></p></body></html>"
594
+ );
595
+ }
596
+
597
  async function onReq(req, res) {
598
  cors(req, res);
599
  if (req.method === "OPTIONS") {
 
606
  return res.end();
607
  }
608
  try {
609
+ if (url.pathname === "/") return handleHome(req, res);
610
+ if (url.pathname === "/health") return handleHealth(res);
611
  if (url.pathname === "/public/bootstrap") return handleBootstrap(req, res, url);
612
  if (url.pathname === "/generate-token" && req.method === "GET") return handleGenerate(req, res, url);
613
  if (url.pathname === "/vip/status" && req.method === "GET") return handleVipStatus(req, res);
 
626
 
627
  async function main() {
628
  if (!API_ID || !API_HASH || !STREAM_SECRET) {
629
+ process.stderr.write("missing required settings\n");
630
  process.exit(1);
631
  }
632
  const tokens = String(process.env.BOT_TOKENS || "")