la-huasca-ts
TypeScript + Next.js version of La Huasca.
A minimal Next.js 14+ App Router scaffold using TypeScript, with @chenglou/pretext installed. The landing page demonstrates a Pretext-based text measurement in a client component (src/components/MeasuredText.tsx).
Getting started
npm install
npm run dev
Open http://localhost:3000.
Project structure
package.json
next.config.js
tsconfig.json
src/app/layout.tsx
src/app/page.tsx
src/app/login/page.tsx
src/app/admin/page.tsx
src/app/user/page.tsx
src/app/api/...
src/components/Navbar.tsx
src/components/MeasuredText.tsx
src/lib/db.ts
src/lib/schema.ts
src/lib/auth.ts
deploy-db.sh
README.md
Database
The app connects to a PostgreSQL database using the DATABASE_URL environment variable.
Deploy / rotate the database secret on Kubernetes
Run the helper script. It generates a secure random password, encrypts it to ~/.lahuasca-db-pass.enc, and applies it to the la-huasca-db-secrets secret in the la-huasca namespace.
./deploy-db.sh
To reveal the stored password, use the PIN 78963:
./deploy-db.sh reveal
Initialize the database schema and seed data
Once the database is reachable and DATABASE_URL is set, start the dev server and call:
curl -X POST http://localhost:3000/api/db/init
To reset everything (drops and recreates tables with seed data):
curl -X POST "http://localhost:3000/api/db/init?reset=true"
Authentication
The app includes JWT-based session authentication backed by the database. Demo accounts are seeded automatically:
admin/admin→ Admin portal (/admin)user/user→ User portal (/user)
The Login / Logout control lives in the Navbar.
Admin portal
Visit /admin after logging in as admin to upload images. Images are previewed in a gallery and can be deleted individually. Uploaded images are now persisted in PostgreSQL.
User portal
Visit /user after logging in as user to see a member portal with reservations, discount coupons, offers, the WiFi password, and a list of benefits.