diff --git a/dist/index.js b/dist/index.js index f0d0721..c8ee9a7 100644 --- a/dist/index.js +++ b/dist/index.js @@ -90,8 +90,8 @@ app.use("/v1/email-change", emailChangeRouter); app.use("/v1/convert", authMiddleware, usageMiddleware, pdfRateLimitMiddleware, convertRouter); app.use("/v1/templates", authMiddleware, usageMiddleware, templatesRouter); // Admin: usage stats -app.get("/v1/usage", authMiddleware, (_req, res) => { - res.json(getUsageStats()); +app.get("/v1/usage", authMiddleware, (req, res) => { + res.json(getUsageStats(req.apiKeyInfo?.key)); }); // Admin: concurrency stats app.get("/v1/concurrency", authMiddleware, (_req, res) => { diff --git a/dist/middleware/usage.js b/dist/middleware/usage.js index 0df84f5..180f5a7 100644 --- a/dist/middleware/usage.js +++ b/dist/middleware/usage.js @@ -65,11 +65,14 @@ function trackUsage(key, monthKey) { saveUsageEntry(key, record).catch((err) => logger.error({ err }, "Failed to save usage entry")); } } -export function getUsageStats() { +export function getUsageStats(apiKey) { const stats = {}; - for (const [key, record] of usage) { - const masked = key.slice(0, 8) + "..."; - stats[masked] = { count: record.count, month: record.monthKey }; + if (apiKey) { + const record = usage.get(apiKey); + if (record) { + const masked = apiKey.slice(0, 8) + "..."; + stats[masked] = { count: record.count, month: record.monthKey }; + } } return stats; } diff --git a/dist/routes/billing.js b/dist/routes/billing.js index dca8ff4..647a512 100644 --- a/dist/routes/billing.js +++ b/dist/routes/billing.js @@ -65,7 +65,7 @@ a { color: #4f9; }
Your API key:
-Save this key! It won't be shown again.
10,000 PDFs/month • All endpoints • Priority support
diff --git a/public/impressum.html b/public/impressum.html index b869916..b19697b 100644 --- a/public/impressum.html +++ b/public/impressum.html @@ -105,7 +105,7 @@ footer .container { display: flex; align-items: center; justify-content: space-b Home Docs API Status - Change Email + Change Email Impressum Privacy Policy Terms of Service diff --git a/public/index.html b/public/index.html index b405f4b..b2f05ce 100644 --- a/public/index.html +++ b/public/index.html @@ -422,7 +422,7 @@ html, body { Home Docs API Status - Change Email + Change Email Impressum Privacy Policy Terms of Service diff --git a/public/privacy.html b/public/privacy.html index 57f3b66..4974616 100644 --- a/public/privacy.html +++ b/public/privacy.html @@ -191,7 +191,7 @@ footer .container { display: flex; align-items: center; justify-content: space-b Home Docs API Status - Change Email + Change Email Impressum Privacy Policy Terms of Service diff --git a/public/terms.html b/public/terms.html index 23dca5f..f2f5802 100644 --- a/public/terms.html +++ b/public/terms.html @@ -264,7 +264,7 @@ footer .container { display: flex; align-items: center; justify-content: space-b Home Docs API Status - Change Email + Change Email Impressum Privacy Policy Terms of Service diff --git a/src/index.ts b/src/index.ts index 1915476..3581a42 100644 --- a/src/index.ts +++ b/src/index.ts @@ -104,8 +104,8 @@ app.use("/v1/convert", authMiddleware, usageMiddleware, pdfRateLimitMiddleware, app.use("/v1/templates", authMiddleware, usageMiddleware, templatesRouter); // Admin: usage stats -app.get("/v1/usage", authMiddleware, (_req, res) => { - res.json(getUsageStats()); +app.get("/v1/usage", authMiddleware, (req: any, res) => { + res.json(getUsageStats(req.apiKeyInfo?.key)); }); // Admin: concurrency stats diff --git a/src/middleware/usage.ts b/src/middleware/usage.ts index fef35cd..0b1f0fd 100644 --- a/src/middleware/usage.ts +++ b/src/middleware/usage.ts @@ -76,11 +76,14 @@ function trackUsage(key: string, monthKey: string): void { } } -export function getUsageStats(): RecordYour API key:
-Save this key! It won't be shown again.
10,000 PDFs/month • All endpoints • Priority support