Files
ins-landing-page/README.md
T
ngqileandClaude Opus 5.5 f75da6d928 fix: harden server per final review
- load static files at startup so a missing file fails fast instead of crashing on request
- WAL + busy_timeout so a manual export cannot fail live submissions
- exit cleanly on SIGTERM (node is PID 1 in the container)
- honour PORT=0
- document a required ingress rate limit
- square card corners and larger card titles

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfmHGGiYUjNcvJoyzdf
2026-12-01 10:43:30 +08:00

53 lines
2.2 KiB
Markdown

# INS Landing Page
Single landing page for Infinity Networks Security with a lead form. Leads are stored in a SQLite file; there is no admin UI, leads are exported manually.
- `public/index.html`: the page (content from infinitynetworks.com.my)
- `server.js`: serves the page and `POST /api/leads`, Node 22 built-ins only, no npm dependencies
## Run locally
Requires Node 22.13 or newer.
```bash
npm start # http://localhost:3000, database at ./data/leads.db
npm test
```
Environment: `PORT` (default `3000`), `DB_PATH` (default `./data/leads.db`).
## Docker
```bash
docker build -t ins-landing-page .
docker run -p 3000:3000 -v ins-leads:/data ins-landing-page
```
## Deploying to Kubernetes
- Mount a PersistentVolumeClaim at `/data`. Without it, leads are lost when the pod restarts.
- Run exactly **1 replica** (SQLite file, single writer). Use `strategy: Recreate` so two pods never hold the volume at once during a rollout.
- The container runs as user `node` (uid 1000); set `securityContext.fsGroup: 1000` so it can write to the volume.
- Health check: `GET /` returns 200.
- **Required: rate-limit `POST /api/leads` at the ingress.** The form is public and the honeypot only stops naive bots; without a limit a script can fill the volume. For ingress-nginx, e.g. `nginx.ingress.kubernetes.io/limit-rpm: "30"` (per client IP, applies to the whole Ingress) on this Ingress.
## Exporting leads
To CSV, from the running pod:
```bash
kubectl exec deploy/ins-landing-page -- node --disable-warning=ExperimentalWarning -e "
const {DatabaseSync}=require('node:sqlite');
const rows=new DatabaseSync(process.env.DB_PATH,{readOnly:true}).prepare('SELECT * FROM leads ORDER BY id').all();
const q=v=>v==null?'':'\"'+String(v).replace(/^[=+\-@]/,\"'\$&\").replace(/\"/g,'\"\"')+'\"';
if(rows.length)console.log(Object.keys(rows[0]).join(','));
for(const r of rows)console.log(Object.values(r).map(q).join(','));
" > leads.csv
```
Or copy the whole database file: `kubectl cp <pod>:/data/leads.db ./leads.db`.
Columns: `id, created_at (UTC), name, email, phone, company, industry, message, referrer, utm_source, utm_medium, utm_campaign`.
Leads contain personal data (PDPA). Keep exported files out of shared drives and delete them when done.