Files
la-huasca-ts/README.md
T

80 lines
2.1 KiB
Markdown

# la-huasca-ts
TypeScript + Next.js version of La Huasca.
A minimal Next.js 14+ App Router scaffold using TypeScript, with [`@chenglou/pretext`](https://github.com/chenglou/pretext) installed. The landing page demonstrates a Pretext-based text measurement in a client component (`src/components/MeasuredText.tsx`).
## Getting started
```bash
npm install
npm run dev
```
Open [http://localhost:3000](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.
Kubernetes runtime uses:
- namespace: `lahuasca`
- Postgres: 15, PVC-backed
- app secrets: `calendar-db-secrets`, key `url`
- ingress: Traefik on `lahuasca.com`
### Initialize the database schema and seed data
Once the database is reachable and `DATABASE_URL` is set, start the dev server and call:
```bash
curl -X POST http://localhost:3000/api/db/init
```
To reset everything (drops and recreates tables with seed data):
```bash
curl -X POST "http://localhost:3000/api/db/init?reset=true"
```
Note: database initialization is blocked in production. Use `reset=true` only if you actually want schema reinitialization.
## 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.