local-lite-server 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +103 -2
- package/admin/dist/assets/index-B2nX9Pef.js +18 -0
- package/admin/dist/assets/index-Dt3bXEks.css +2 -0
- package/admin/dist/favicon.svg +11 -0
- package/admin/dist/index.html +14 -0
- package/dist/admin/console.d.ts +19 -0
- package/dist/admin/console.js +166 -0
- package/dist/admin/index.d.ts +28 -0
- package/dist/admin/index.js +13 -0
- package/dist/admin/ops.d.ts +11 -0
- package/dist/admin/ops.js +279 -0
- package/dist/admin/session.d.ts +14 -0
- package/dist/admin/session.js +160 -0
- package/dist/apiKeys.d.ts +36 -0
- package/dist/apiKeys.js +91 -0
- package/dist/app.d.ts +1 -0
- package/dist/app.js +10 -0
- package/dist/auth.d.ts +16 -0
- package/dist/auth.js +99 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +127 -0
- package/dist/codegen.d.ts +4 -0
- package/dist/codegen.js +74 -0
- package/dist/config.d.ts +39 -0
- package/dist/config.js +51 -0
- package/dist/core/broker.d.ts +12 -0
- package/dist/core/broker.js +78 -0
- package/dist/core/changes.d.ts +17 -0
- package/dist/core/changes.js +68 -0
- package/dist/core/http.d.ts +8 -0
- package/dist/core/http.js +72 -0
- package/dist/core/mailer.d.ts +3 -0
- package/dist/core/mailer.js +11 -0
- package/dist/cpanel.d.ts +1 -0
- package/dist/cpanel.js +96 -0
- package/dist/crons.d.ts +24 -0
- package/dist/crons.js +124 -0
- package/dist/db.d.ts +7 -0
- package/dist/db.js +37 -0
- package/dist/functions/index.d.ts +3 -0
- package/dist/functions/index.js +3 -0
- package/dist/functions/loader.d.ts +4 -0
- package/dist/functions/loader.js +64 -0
- package/dist/functions/runtime.d.ts +21 -0
- package/dist/functions/runtime.js +238 -0
- package/dist/functions/types.d.ts +59 -0
- package/dist/functions/types.js +16 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +7 -0
- package/dist/migrations.d.ts +16 -0
- package/dist/migrations.js +254 -0
- package/dist/oauth.d.ts +7 -0
- package/dist/oauth.js +152 -0
- package/dist/rateLimit.d.ts +12 -0
- package/dist/rateLimit.js +54 -0
- package/dist/routes.d.ts +15 -0
- package/dist/routes.js +29 -0
- package/dist/rules.d.ts +23 -0
- package/dist/rules.js +73 -0
- package/dist/schema.d.ts +18 -0
- package/dist/schema.js +89 -0
- package/dist/server.d.ts +13 -0
- package/dist/server.js +340 -0
- package/dist/start.d.ts +8 -0
- package/dist/start.js +168 -0
- package/dist/storage.d.ts +4 -0
- package/dist/storage.js +82 -0
- package/dist/tableStorage.d.ts +63 -0
- package/dist/tableStorage.js +261 -0
- package/docs/api.md +181 -0
- package/docs/client-usage.md +104 -0
- package/docs/cpanel.md +63 -0
- package/docs/functions.md +78 -0
- package/docs/schema-and-migrations.md +54 -0
- package/docs/vps.md +67 -0
- package/package.json +54 -4
- package/templates/.env +16 -0
- package/templates/.env.example +49 -0
- package/templates/README.md +23 -0
- package/templates/data/backups/.gitkeep +1 -0
- package/templates/data/uploads/.gitkeep +1 -0
- package/templates/gitignore +29 -0
- package/templates/package.json +14 -0
- package/templates/src/functions/notes.ts +47 -0
- package/templates/src/lib/validators.ts +9 -0
- package/templates/src/rules.ts +12 -0
- package/templates/src/schema.ts +9 -0
- package/templates/src/types.ts +9 -0
- package/templates/tests/notes.test.ts +26 -0
- package/templates/tsconfig.json +13 -0
package/README.md
CHANGED
|
@@ -1,3 +1,104 @@
|
|
|
1
|
-
#
|
|
1
|
+
# local-lite-server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Self-hostable reactive sync & server functions backend powered by [`local-lite`](https://github.com/georgechitechi/local-lite).
|
|
4
|
+
Runs on **MySQL** or **PostgreSQL**, deploys to **cPanel (Node.js App / Passenger)** or any **VPS** with **no Docker**, and includes a built-in React **Admin Console** at `/admin`.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Key Capabilities
|
|
9
|
+
|
|
10
|
+
- **Real SQL Tables from `schema.ts`:** Generates and applies MySQL or PostgreSQL DDL automatically on boot (`AUTO_MIGRATE=true`) or via CLI.
|
|
11
|
+
- **Slim Change Log:** `_server_changes` stores only `(table_name, row_id, timestamp)` for fast delta sync and live SSE invalidation.
|
|
12
|
+
- **Server Functions (`functions/`):** Write `query`, `mutation` (transactional), and `action` handlers in TypeScript with live SSE subscriptions (`GET /subscribe/:module/:name`).
|
|
13
|
+
- **Authentication & Email OTP:** `/auth/signin`, `/auth/signup`, `/auth/refresh`, `/auth/forgot-password`, and `/auth/reset-password` backed by SQL + SMTP.
|
|
14
|
+
- **Admin Console (`/admin`):** Overview, Data Browser (row editor drawer), Auth & Users, Server Functions runner & live SSE subscriber, Schedules, Backups, Storage, Sync Logs, Environment variables, and Settings.
|
|
15
|
+
- **Zero-Framework HTTP:** Built on `node:http` + Web `Request`/`Response` (no Express or Fastify).
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
### On a Fresh PC (`npx`)
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npx local-lite-server init my-backend # or run `npx local-lite-server init` inside an existing folder
|
|
25
|
+
cd my-backend
|
|
26
|
+
# Edit .env with your MySQL or Postgres database credentials, then:
|
|
27
|
+
npx local-lite-server start
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### From This Repo (Development)
|
|
31
|
+
|
|
32
|
+
1. **Install dependencies & build the Admin UI:**
|
|
33
|
+
```bash
|
|
34
|
+
npm install
|
|
35
|
+
cd admin && npm install && npm run build && cd ..
|
|
36
|
+
```
|
|
37
|
+
2. **Configure `.env`:**
|
|
38
|
+
```bash
|
|
39
|
+
cp .env.example .env
|
|
40
|
+
```
|
|
41
|
+
Set `DB_DIALECT` (`mysql` or `postgres`), `DB_HOST`, `DB_USER`, `DB_PASSWORD`, `DB_NAME`, `SERVER_API_KEY`, and `APP_SECRET`.
|
|
42
|
+
3. **Create an empty database:**
|
|
43
|
+
- MySQL: `CREATE DATABASE \`local-admin\` CHARACTER SET utf8mb4;`
|
|
44
|
+
- Postgres: `CREATE DATABASE "local-admin";`
|
|
45
|
+
4. **Start in dev mode (auto-rebuild + function hot-reload):**
|
|
46
|
+
```bash
|
|
47
|
+
npm run dev
|
|
48
|
+
```
|
|
49
|
+
5. Open **http://localhost:3000/admin** and complete **First-Time Setup** using your `APP_SECRET` (or `SERVER_API_KEY`).
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## Documentation
|
|
54
|
+
|
|
55
|
+
- [HTTP & SSE API Reference](./docs/api.md) — `/sync`, `/fn`, `/subscribe`, `/auth`, `/storage`, and `/admin` endpoints
|
|
56
|
+
- [Schema & Migrations](./docs/schema-and-migrations.md) — `schema.ts`, supported types, `AUTO_MIGRATE`, and CLI commands
|
|
57
|
+
- [Server Functions & Reactive Queries](./docs/functions.md) — `query`, `mutation`, `action`, and SSE `/subscribe`
|
|
58
|
+
- [Client Usage & Auth](./docs/client-usage.md) — `SelfHostedRemoteAdapter`, `/auth/*`, and calling functions from apps
|
|
59
|
+
- [Deploying on cPanel (Namecheap, etc.)](./docs/cpanel.md) — single-file `app.cjs` bundle for Setup Node.js App
|
|
60
|
+
- [Deploying on a VPS (systemd / PM2 / Nginx)](./docs/vps.md) — production Linux deployment without Docker
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Environment Variables
|
|
65
|
+
|
|
66
|
+
| Variable | Required | Default | Description |
|
|
67
|
+
|---|---|---|---|
|
|
68
|
+
| `DB_DIALECT` | Yes | `mysql` | `mysql` or `postgres` |
|
|
69
|
+
| `DB_HOST` | Yes | — | Database host |
|
|
70
|
+
| `DB_PORT` | No | `3306` / `5432` | Database port |
|
|
71
|
+
| `DB_USER` | Yes | — | Database username |
|
|
72
|
+
| `DB_PASSWORD` | No | `""` | Database password |
|
|
73
|
+
| `DB_NAME` | Yes | — | Database name |
|
|
74
|
+
| `DB_SSL` | No | `false` | Enable TLS for Postgres (`rejectUnauthorized: false`) |
|
|
75
|
+
| `DB_POOL_SIZE` | No | `5` | Max connection pool size |
|
|
76
|
+
| `SERVER_PORT` / `PORT` | No | `3000` | HTTP port or Passenger socket path |
|
|
77
|
+
| `SERVER_API_KEY` | Yes | — | Master Bearer key for `/sync`, `/fn`, and `/admin` |
|
|
78
|
+
| `APP_SECRET` | No | — | Enables `/auth/*` user accounts and signs JWTs + admin cookies |
|
|
79
|
+
| `APP_NAME` | No | `local-lite-server` | Display name in emails and admin console |
|
|
80
|
+
| `AUTO_MIGRATE` | No | `true` | Apply core & `schema.ts` migrations on boot |
|
|
81
|
+
| `SCHEMA_PATH` | No | `src/schema.ts` | Path to schema file |
|
|
82
|
+
| `RULES_PATH` | No | `src/rules.ts` | Path to per-table RLS rules (`read`/`write`) |
|
|
83
|
+
| `FUNCTIONS_DIR` | No | `src/functions` | Directory containing server function modules |
|
|
84
|
+
| `UPLOAD_DIR` | No | `./uploads` | Directory for uploaded storage files |
|
|
85
|
+
| `BACKUP_DIR` | No | `./backups` | Directory for JSON backup snapshots |
|
|
86
|
+
| `ENABLE_INTERNAL_CRONS` | No | `false` | Run `_lls_crons` schedules inside Node every 60s |
|
|
87
|
+
| `MULTI_INSTANCE` | No | `false` | Postgres `LISTEN/NOTIFY` (or MySQL tailing) + DB rate limits |
|
|
88
|
+
| `ADMIN_UI` | No | `true` | Set `false` to disable `/admin` routes |
|
|
89
|
+
| `CORS_ORIGINS` | No | `*` | Comma-separated allowed origins, or `*` |
|
|
90
|
+
| `SMTP_HOST`, `SMTP_PORT`, `SMTP_SECURE`, `SMTP_USER`, `SMTP_PASS`, `SMTP_FROM` | No | — | SMTP settings for password-reset OTP emails |
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## Scripts
|
|
95
|
+
|
|
96
|
+
| Script | Purpose |
|
|
97
|
+
|---|---|
|
|
98
|
+
| `npm run dev` | Watch & rebuild `src/` + restart server + hot-reload `functions/` |
|
|
99
|
+
| `npm run dev:admin` | Vite HMR dev server for `admin/` on `http://localhost:5173/admin/` |
|
|
100
|
+
| `npm run start` | Build `dist/` and run production server |
|
|
101
|
+
| `npm run migrate` | Apply core + `schema.ts` migrations (`status` / `diff` subcommands supported) |
|
|
102
|
+
| `npx local-lite-server codegen` | Generate typed client SDK (`--out src/client.ts`) |
|
|
103
|
+
| `npm run build:cpanel` | Build self-contained `dist/cpanel/` bundle for cPanel |
|
|
104
|
+
| `npm test` | Run Vitest suite |
|