- Replace sqlite3 (native) with sql.js (pure JS/WebAssembly)
- Fixes GLIBC version compatibility issues
- Rewrite database module for sql.js async API
- Add proper file persistence for sql.js (in-memory with save-to-file)
- Update server startup to initialize database before listening
sql.js works everywhere without native compilation
Features:
- Express server on port 9991 with ESM syntax
- User registration, login, and session management
- Password hashing with bcryptjs
- SQLite database with sqlite3 package
- User credits and transaction tracking
- API key management
- Admin endpoints for user management
- Stripe and PayPal webhook endpoints (ready for integration)
- Rate limiting and error handling
- CORS and security headers with helmet
Database tables:
- users (accounts, subscriptions, credits)
- sessions (auth tokens)
- api_keys (user API access)
- credit_transactions (credit history)
- payments (payment tracking)