Spaces:
Sleeping
Sleeping
Add landing page
Browse files- src/index.js +17 -0
src/index.js
CHANGED
|
@@ -83,6 +83,23 @@ async function installSsrfGuard(page) {
|
|
| 83 |
// Health check is public (no auth) so platforms can probe it.
|
| 84 |
app.get('/health', (_req, res) => res.json({ status: 'ok' }));
|
| 85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
app.use((req, res, next) => (authorized(req) ? next() : res.status(401).json({ error: 'Unauthorized' })));
|
| 87 |
|
| 88 |
// Shared: validate input, SSRF pre-check, open page, navigate, then `produce` output.
|
|
|
|
| 83 |
// Health check is public (no auth) so platforms can probe it.
|
| 84 |
app.get('/health', (_req, res) => res.json({ status: 'ok' }));
|
| 85 |
|
| 86 |
+
// Public landing page (info only).
|
| 87 |
+
app.get('/', (_req, res) =>
|
| 88 |
+
res.type('html').send(
|
| 89 |
+
`<!doctype html><meta charset="utf-8"><title>PDF API</title>
|
| 90 |
+
<style>body{font-family:system-ui,sans-serif;max-width:640px;margin:60px auto;padding:0 20px;color:#1f2937;line-height:1.6}code{background:#f3f4f6;padding:2px 6px;border-radius:4px}h1{margin-bottom:0}.muted{color:#6b7280}</style>
|
| 91 |
+
<h1>📄 PDF API</h1>
|
| 92 |
+
<p class="muted">HTML/URL to PDF & screenshot API, with a built-in invoice template.</p>
|
| 93 |
+
<h3>Endpoints</h3>
|
| 94 |
+
<ul>
|
| 95 |
+
<li><code>GET /health</code> — status (public)</li>
|
| 96 |
+
<li><code>POST /pdf</code> — HTML / URL / template → PDF</li>
|
| 97 |
+
<li><code>POST /screenshot</code> — HTML / URL → PNG or JPEG</li>
|
| 98 |
+
</ul>
|
| 99 |
+
<p class="muted">Protected endpoints require an API key. Available on RapidAPI.</p>`
|
| 100 |
+
)
|
| 101 |
+
);
|
| 102 |
+
|
| 103 |
app.use((req, res, next) => (authorized(req) ? next() : res.status(401).json({ error: 'Unauthorized' })));
|
| 104 |
|
| 105 |
// Shared: validate input, SSRF pre-check, open page, navigate, then `produce` output.
|