Piattaforma ITI TECHNOLOGY: monorepo, Medusa, API, sito, area riservata e deploy
Deploy stack su Proxmox / deploy (push) Failing after 3s
Deploy stack su Proxmox / deploy (push) Failing after 3s
Monorepo npm con apps/public (Angular SSR), apps/private (Angular SPA), apps/api (Fastify), packages/shared e packages/styles; Medusa 2.21 in medusa/; infrastruttura Docker (Postgres PostGIS+pgvector, Redis, Caddy, backup) e workflow Gitea Actions per il deploy via SSH a ogni push su master. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018jQyT6dR9czzGwqb7FkG6u
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
# 06 — Medusa: route interne per il gateway Fastify
|
||||
|
||||
Leggi `CLAUDE.md`.
|
||||
|
||||
## Contesto
|
||||
Il frontend non parla mai con Medusa: Fastify è l'unico gateway e i customer Medusa non hanno password propria. Servono quindi alcune route interne, chiamabili **solo** da Fastify.
|
||||
|
||||
## Obiettivo
|
||||
Custom API routes in `medusa/src/api/internal/*` protette da segreto condiviso.
|
||||
|
||||
## Cosa fare
|
||||
- Middleware che accetta la richiesta solo se l'header `x-internal-secret` corrisponde a `INTERNAL_API_SECRET` (confronto a tempo costante); altrimenti 401.
|
||||
- Route:
|
||||
- `POST /internal/customers` → crea (o restituisce se esiste per email) un customer; body `{ email, first_name, last_name, company_name? }`.
|
||||
- `POST /internal/customers/:id/groups` → aggiunge/rimuove il customer dal gruppo `installatori`.
|
||||
- `POST /internal/carts/:id/customer` → associa un carrello a un customer.
|
||||
- `POST /internal/orders/claim` → collega al customer gli ordini guest con la stessa email; body `{ customer_id, email }`.
|
||||
- `GET /internal/customers/:id/orders` → elenco ordini del customer.
|
||||
- Implementa tramite i workflow ufficiali di Medusa v2 dove esistono (verifica nella documentazione quali: es. aggiornamento customer del carrello, trasferimento ordini). Annota in `CLAUDE.md` quali workflow sono stati usati.
|
||||
|
||||
## Criteri di accettazione
|
||||
- Senza header o con segreto errato tutte le route rispondono 401.
|
||||
- Test (anche manuali documentati, es. file `.http`) che dimostrano: creazione customer idempotente, associazione carrello, claim di un ordine guest.
|
||||
- Dopo l'associazione al gruppo `installatori`, il carrello del customer applica la price list.
|
||||
- `CLAUDE.md` aggiornato.
|
||||
Reference in New Issue
Block a user