# cPanel Node.js Selector — Deploy ZEKAA Gateway

## 0. Important (CloudLinux)

- **Do NOT upload `node_modules`.** Delete it from the app root if you uploaded it.
  CloudLinux creates its own `node_modules` symlink — a real folder breaks the app.
- Use **Node.js 18+ or 20+** (not 10.x).
- After fixing: **Run NPM Install** from the Selector, then **Restart**.

## 1. Upload

Upload the `backend/` folder as the Node application root (e.g. `/home/USER/zekaa-gateway`).
Upload only source files (`app.js`, `package.json`, folders) — never `node_modules`.

Upload `storage/` **outside** `public_html`, e.g. `/home/USER/storage`:

```
/home/USER/
  public_html/          ← no zip files here
  zekaa-gateway/        ← backend (Node app root)
  storage/
    game/
    online/
    bypass/
    manifests/
    version.json
```

## 2. Node.js Selector

1. Open **Setup Node.js App**
2. Application root: `zekaa-gateway` (path to `backend/`)
3. Application URL: your subdomain (e.g. `api.zekaa-vip.xyz`)
4. Application startup file: **`app.js`**
5. Node version: 18+ or 20+
6. Click **Run NPM Install**
7. Add environment variables from `backend/.env.example` (especially secrets + `STORAGE_ROOT=/home/USER/storage`)
8. **Restart** the application

## 3. Electron client

Set in client `.env`:

```
ZEKAA_API_BASE=https://api.zekaa-vip.xyz
ZEKAA_LOCAL_VERSION=5.0.0
```

No `ZEKAA_MANIFEST_API_KEY`, no PHP URLs, no GitHub.

## 4. Packages

Place files only under private storage:

- `storage/game/730.zip`
- `storage/online/some-id.zip`
- `storage/bypass/some-id.zip`

Flow:

1. `POST /api/packages/resolve` → `{ downloadToken }` (60 seconds)
2. `POST /api/download` `{ downloadToken }` → binary stream (single-use)

## 5. Health check

`GET https://api.YOUR-DOMAIN/health` → `{ ok: true }`
