mirror of
https://git.meshkee.com/BaloutPastry/backend.git
synced 2026-08-11 22:31:00 +04:30
Add SMS OTP auth, discounts, customer orders, and category slugs.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
58380ab81d
commit
d09eca8702
+21
-3
@@ -46,8 +46,12 @@ Health check: `GET http://localhost:3100/api/v1/auth/me` → `401` without token
|
||||
|
||||
1. Keep this API on **3100**
|
||||
2. In dashboards: `VITE_API_BASE_URL=http://localhost:3100/api/v1`
|
||||
3. Backend `CORS_ORIGIN` must include `http://localhost:5173`
|
||||
4. Log in with the super-admin phone/password you created
|
||||
3. Backend `CORS_ORIGIN` must include local dashboard origins, e.g.
|
||||
`http://baloutpastry.com:5173,http://admin.baloutpastry.com:5173,http://customer.baloutpastry.com:5173,http://localhost:5173`
|
||||
4. Add local DNS in `/etc/hosts` for `baloutpastry.com`, `admin.baloutpastry.com`, `customer.baloutpastry.com` → `127.0.0.1`
|
||||
5. Log in with the super-admin phone/password you created
|
||||
- Admin: `http://admin.baloutpastry.com:5173`
|
||||
- Customer: `http://customer.baloutpastry.com:5173`
|
||||
|
||||
## Scripts
|
||||
|
||||
@@ -62,6 +66,7 @@ Health check: `GET http://localhost:3100/api/v1/auth/me` → `401` without token
|
||||
| `npm run prisma:deploy` | Apply existing migrations (CI / new device) |
|
||||
| `npm run prisma:generate` | Regenerate Prisma Client |
|
||||
| `npm run create-super-admin` | Create first `superAdmin` user |
|
||||
| `npm run send-sms` | Send SMS via Meshkee (`--to` / `--message`) |
|
||||
| `npm run lint` | ESLint |
|
||||
|
||||
## Environment
|
||||
@@ -79,12 +84,24 @@ Copy from `.env.example`. Do **not** commit `.env`.
|
||||
| `STORAGE_DISK` | `s3` for Parspack |
|
||||
| `S3_*` | Endpoint, bucket, public URL, keys |
|
||||
| `MEDIA_MAX_FILE_SIZE_MB` | Upload size cap |
|
||||
| `MESHKEE_SMS_URL` | Meshkee public SMS send endpoint |
|
||||
| `MESHKEE_SMS_API_KEY` | Partner API key (`X-Api-Key`) — server only |
|
||||
| `MESHKEE_SMS_DOMAIN` | Partner domain, e.g. `baloutpastry.com` |
|
||||
|
||||
Inject `SmsService` from `SmsModule` to send SMS from the backend (never from the frontend). Limits: 30/partner/min, 5/destination/min.
|
||||
|
||||
```bash
|
||||
npm run send-sms -- --to 09127004945 --message "متن پیام"
|
||||
```
|
||||
|
||||
Ports are intentional vs Meshkee: API **3100**, Postgres host **5434** (Meshkee uses 3000 / 5432).
|
||||
|
||||
## Auth rules
|
||||
|
||||
- Login: `POST /auth/login` with `{ "cellNumber": "09…", "password": "…" }`
|
||||
- Login with SMS: `POST /auth/login/send-code` then `POST /auth/login/verify`
|
||||
- Forgot password: `POST /auth/forgot-password/send-code` → `/verify` → `/reset`
|
||||
- Register: `POST /auth/register/send-code` then `POST /auth/register/verify` (SMS OTP → create `customer`)
|
||||
- Only `admin` and `superAdmin` can log in to the admin API/dashboard
|
||||
- Only `superAdmin` can assign `admin` or `superAdmin` roles
|
||||
- `customer` users exist for orders / future customer UI
|
||||
@@ -94,7 +111,7 @@ Ports are intentional vs Meshkee: API **3100**, Postgres host **5434** (Meshkee
|
||||
|
||||
| Area | Methods |
|
||||
|------|---------|
|
||||
| Auth | `POST /auth/login`, `/auth/refresh`, `/auth/logout`, `GET /auth/me` |
|
||||
| Auth | `POST /auth/login`, `/auth/login/send-code`, `/auth/login/verify`, `/auth/forgot-password/send-code`, `/auth/forgot-password/verify`, `/auth/forgot-password/reset`, `/auth/register/send-code`, `/auth/register/verify`, `/auth/refresh`, `/auth/logout`, `GET /auth/me` |
|
||||
| Users | CRUD + `PATCH /users/:id/role`, `/password` + addresses under `/users/:id/addresses` |
|
||||
| Flavors | CRUD |
|
||||
| Categories | tree CRUD + `GET\|PUT /categories/:id/options` |
|
||||
@@ -175,4 +192,5 @@ Ensure Postgres is reachable via `DATABASE_URL` and `CORS_ORIGIN` lists the real
|
||||
## Related
|
||||
|
||||
- Dashboards setup: clone `BaloutPastry/dashboards` and read `CONTEXT.md`
|
||||
- Website (storefront): clone `BaloutPastry/website` and read `CONTEXT.md` (dev port **5174**)
|
||||
- Short API overview also in `README.md`
|
||||
|
||||
Reference in New Issue
Block a user