# Folie Ninja — cPanel deployment

This package is a production-ready Next.js standalone application. It does not
contain `.env.local`, API keys, local caches, source maps, or development tools.

## 1. Upload

1. Upload `folieninja-cpanel-ready.zip` to the Node.js application folder in cPanel.
2. Extract it so `server.js` is in the application root.
3. Create or edit the cPanel Node.js application:
   - Node.js version: **22.x** recommended (20.x minimum for this build)
   - Application root: the extracted folder
   - Startup file: `server.js`
   - Application URL: your Folie Ninja domain

The standalone package contains its production dependencies, so `npm install`
is normally unnecessary.

When deploying the source package instead, upload the included root-level
`server.js`, run `npm install` and `npm run build`, then restart the app.

## 2. Environment variables

Copy `.env.example` to `.env` beside `server.js`, then enter the real values.
Never upload `.env.local` from the development computer.

Required for the website and admin:

- `NEXT_PUBLIC_BASE_URL`
- `NEXTAUTH_URL` (normally the same URL; used by Google Calendar callbacks)
- `NEXT_PUBLIC_SUPABASE_URL`
- `NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY` (or the legacy anon key)
- `SUPABASE_SERVICE_ROLE_KEY`

Required when those features are enabled:

- Stripe: `STRIPE_SECRET_KEY`, `STRIPE_WEBHOOK_SECRET`
- Email: `RESEND_API_KEY`, `RESEND_FROM_EMAIL`, `CONTACT_TO_EMAIL`
- Calendar: `GOOGLE_CLIENT_ID`, `GOOGLE_CLIENT_SECRET`, `GOOGLE_SYNC_SERVICE_ID`
- Reminders: `CRON_SECRET`

## 3. Database

The `database-migrations` folder is included for reference and fresh installs.
The connected production database already contains the current migrations. Do
not re-run them blindly against an existing database.

## 4. Stripe webhook

Configure Stripe to send events to:

`https://YOUR-DOMAIN/api/stripe/webhook`

Store the signing secret as `STRIPE_WEBHOOK_SECRET`.

## 5. Reminder cron job

Run every 15 minutes in cPanel Cron Jobs:

```sh
*/15 * * * * curl -s -H "Authorization: Bearer YOUR_CRON_SECRET" https://YOUR-DOMAIN/api/cron/reminders
```

## 6. Start and verify

Restart the Node.js application, then verify:

1. Homepage and `/priser`
2. `/admin/login`
3. Test booking and Stripe test payment
4. Confirmation email
5. Admin image upload
