OpenCode commited on
Commit
069529c
·
1 Parent(s): 3f8984a

debug: add cf credentials debug endpoint

Browse files
Files changed (2) hide show
  1. api/debug.js +18 -0
  2. server.js +1 -0
api/debug.js ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const { parseCfCredentials, isCfEnabled } = require("./lib/cloudflare.js");
2
+
3
+ function mask(s) {
4
+ if (!s) return "";
5
+ if (s.length <= 8) return "***";
6
+ return s.slice(0, 6) + "..." + s.slice(-4);
7
+ }
8
+
9
+ module.exports = async function handler(req, res) {
10
+ const credentials = parseCfCredentials();
11
+ res.status(200).json({
12
+ cloudflareEnabled: isCfEnabled(),
13
+ credentialsCount: credentials.length,
14
+ first: credentials[0] ? { accountId: mask(credentials[0].accountId), tokenPrefix: mask(credentials[0].token) } : null,
15
+ last: credentials[credentials.length - 1] ? { accountId: mask(credentials[credentials.length - 1].accountId), tokenPrefix: mask(credentials[credentials.length - 1].token) } : null,
16
+ rawLength: (process.env.CLOUDFLARE_CREDENTIALS || "").length,
17
+ });
18
+ };
server.js CHANGED
@@ -47,6 +47,7 @@ const handlers = {
47
  "/health": () => require("./api/health.js"),
48
  "/api/dashboard": () => require("./api/dashboard.js"),
49
  "/dashboard": () => require("./api/dashboard.js"),
 
50
  };
51
 
52
  const server = http.createServer(async (req, res) => {
 
47
  "/health": () => require("./api/health.js"),
48
  "/api/dashboard": () => require("./api/dashboard.js"),
49
  "/dashboard": () => require("./api/dashboard.js"),
50
+ "/api/debug/cf": () => require("./api/debug.js"),
51
  };
52
 
53
  const server = http.createServer(async (req, res) => {