Node.js / Express app with user registration, login, and a dashboard backed by MariaDB on MAMP.
- Register and log in (sessions + bcrypt password hashing)
- Protected dashboard with summary stats and two sample data tables
- Original banana shop demo at
/shop.html - Checkout API unchanged (
POST /checkout)
- Node.js, Express
- MariaDB (via MAMP) — managed with phpMyAdmin
mysql2,bcryptjs,express-session,dotenv
- MAMP — start MySQL/MariaDB (Apache is not required for this app).
- Node.js — v18+ recommended.
- Open phpMyAdmin from MAMP (often
http://localhost:8888/phpMyAdminor similar). - Open the SQL tab.
- Paste the contents of
sql/schema.sqland run it.
This creates the banana_dashboard database, users table, and two seeded tables: weekly_metrics and recent_activity.
-
Copy
.env.exampleto.env:copy .env.example .env
-
Edit
.envto match MAMP:Variable Typical MAMP value DB_HOST127.0.0.1DB_PORT8889or3306— check MAMP → Preferences → PortsDB_USERrootDB_PASSWORDrootDB_NAMEbanana_dashboardSESSION_SECRETany long random string
npm install
npm start- Home — links to register, login, dashboard
- Register — create an account, then go to the dashboard
- Dashboard — requires login; shows stats from the seeded tables
- Banana Shop — original demo at
shop.html
| Method | Path | Auth |
|---|---|---|
| POST | /api/auth/register |
— |
| POST | /api/auth/login |
— |
| POST | /api/auth/logout |
session |
| GET | /api/auth/me |
session |
| GET | /api/dashboard/stats |
session |
- ECONNREFUSED / access denied — wrong
DB_PORTor password; confirm MySQL is running in MAMP. - Table doesn't exist — run
sql/schema.sqlagain in phpMyAdmin. - Login works but dashboard empty / 500 — seed data missing; re-run the
INSERTsection ofschema.sqlor the full script on a fresh database.
Demo project only. Do not use weak secrets or default passwords in production. For HTTPS deployments, set cookie.secure: true on the session middleware.