Piattaforma ITI TECHNOLOGY: monorepo, Medusa, API, sito, area riservata e deploy
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:
Lorenzo Sanesi
2026-10-20 09:30:48 +02:00
co-authored by Claude Opus 5.5
commit b83ce039fb
505 changed files with 84544 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
import type { FastifyInstance } from "fastify"
import fp from "fastify-plugin"
import { type FetchFn, MedusaClient } from "../services/medusa-client.js"
import { trySync } from "../services/medusa-sync.js"
declare module "fastify" {
interface FastifyInstance {
/** Client Medusa: `medusa.store` (Store API) e `medusa.internal` (route /internal/*). */
medusa: MedusaClient
/**
* Avvia una sincronizzazione con Medusa senza attenderla (la risposta HTTP non dipende da Medusa).
* Gli errori diventano warning nei log; le operazioni in corso vengono attese alla chiusura del server.
*/
syncInBackground: (what: string, userId: string, fn: () => Promise<unknown>) => void
/** Attende le sincronizzazioni in background in corso (usato da onClose e dai test). */
flushSyncs: () => Promise<void>
}
}
/** Espone il client Medusa come `app.medusa`. `fetch` è sostituibile nei test (Medusa mockato). */
export default fp(
async function medusaClientPlugin(app: FastifyInstance, opts: { fetch?: FetchFn | undefined }) {
app.decorate(
"medusa",
new MedusaClient({
baseUrl: app.config.MEDUSA_URL,
publishableKey: app.config.MEDUSA_PUBLISHABLE_KEY,
internalSecret: app.config.INTERNAL_API_SECRET,
timeoutMs: app.config.MEDUSA_TIMEOUT_MS,
...(opts.fetch ? { fetch: opts.fetch } : {}),
}),
)
const pending = new Set<Promise<unknown>>()
app.decorate("syncInBackground", (what: string, userId: string, fn: () => Promise<unknown>) => {
const p = trySync(app.log, what, userId, fn).finally(() => pending.delete(p))
pending.add(p)
})
app.decorate("flushSyncs", async () => {
while (pending.size > 0) await Promise.allSettled([...pending])
})
app.addHook("onClose", async () => {
await app.flushSyncs()
})
},
{ name: "medusa-client", dependencies: ["config"] },
)