Docs / Backend
ven.php
Backend
VenJS ships a secure PHP backend: a PDO database endpoint (ven.php) and a notification registration handler (ven_notify.php), plus a service worker (sw.js).
ven.php
Database Engine
Client-to-database CRUD over prepared statements.
ven_notify.phpNotification Server
Device registration + service worker push.
HardeningSecurity Guardrails
Prepared SQL, allowlists, CORS, timing-safe keys.
Files
| File | Role |
|---|---|
ven.php | Secure DB endpoint. Receives a JSON payload (op, table, …) and runs prepared statements. Used by venjs.db.connect(). |
ven_notify.php | Receives { deviceId, type } and appends the subscription to notification_handler.txt. |
sw.js | Service worker handling push and notificationclick events. |
api/read.txt | Placeholder folder note for your own API entry files. |
Frontend ↔ Backend flow
// Browser (venjs.db) // Server (ven.php)
venjs.db.connect({ endpoint:'/ven.php', // 1. check origin + API key
apiKey:'...', table:'users' }) // 2. sanitize identifiers / table allowlist
.read({ where:{ id: 1 } }) // 3. build + execute prepared statement
.then(rows => ...) // 4. respond JSON { ok, data, count }Real-life structure
Developers keep the form UI in components/login.js and the DB call in logic/login.js. The router maps /login to the page component.
venjs/
components/
login.js # LoginPage — form UI + local state
logic/
login.js # loginUser() — venjs.db.connect() call
router.js # maps /login => window.LoginPage()See Database Engine → Real-life login example for the full code.
Requirements
- PHP 8+ with the
pdo_mysqlextension enabled. - A MySQL/MariaDB database and a user with table access.
- Served over HTTP(S); the
ven.phpendpoint must be reachable by the frontend's fetch calls.