Multi-tenant event manager built with NestJS 10, Prisma ORM, and PostgreSQL.
- Multi-tenant: Ogni client ha accesso solo ai propri eventi tramite token
- Gestione Partecipanti: Aggiungi e rimuovi partecipanti agli eventi
- Eventi Ricorrenti: Crea eventi che si ripetono settimanalmente/mensilmente/annualmente
- RRULE Support: Utilizza lo standard RFC 5545 per le ricorrenze
- Auto Cleanup: Pulizia automatica degli eventi passati
npm installcp .env.example .env
# Modifica .env con i tuoi dati di connessione PostgreSQLnpm run prisma:migrate
npm run prisma:generatenpm run start:devL'app sarà disponibile su http://localhost:3000
POST /clients
Content-Type: application/json
{
"name": "My Event Company"
}Risposta:
{
"id": "cluxxxxxx",
"name": "My Event Company",
"token": "Y2x1exxxxxx"
}GET /clientsTutti gli endpoint degli eventi richiedono l'header: x-client-token: <token>
POST /events
Headers: x-client-token: <token>
Content-Type: application/json
{
"title": "Weekly Team Meeting",
"description": "Discussione settimanale",
"authorId": "user123",
"authorName": "John Doe",
"startTime": "2026-03-05T14:00:00Z",
"recurrenceRule": "FREQ=WEEKLY;BYDAY=WE;INTERVAL=1"
}Risposta:
{
"id": "cluxxxxxx",
"title": "Weekly Team Meeting",
"description": "Discussione settimanale",
"clientId": "cluxxxxxx",
"authorId": "user123",
"authorName": "John Doe",
"startTime": "2026-03-05T14:00:00Z",
"isRecurring": true,
"recurrenceRule": "FREQ=WEEKLY;BYDAY=WE;INTERVAL=1",
"participants": [],
"createdAt": "2026-02-26T10:00:00Z",
"updatedAt": "2026-02-26T10:00:00Z"
}GET /events
Headers: x-client-token: <token>GET /events/:eventId
Headers: x-client-token: <token>POST /events/:eventId/participants
Headers: x-client-token: <token>
Content-Type: application/json
{
"userId": "user456",
"userName": "Jane Smith"
}DELETE /events/:eventId/participants/:userId
Headers: x-client-token: <token>FREQ=WEEKLY;BYDAY=MO
FREQ=WEEKLY;BYDAY=MO,TH;INTERVAL=2
FREQ=MONTHLY;BYMONTHDAY=1
FREQ=DAILY;BYDAY=MO,TU,WE,TH,FR
Client (1) ---< (M) Event
Event (1) ---< (M) Participant
Event (Parent) ---< (Child) Event (per ricorrenze)
- Client invia
x-client-tokennell'header ClientAuthGuardverifica il token- Request viene arricchita con
req.clientcontenente i dati del client - Tutti i servizi filtrano i dati per
clientId
- Quando crei un evento ricorrente, viene creato l'evento genitore
- Automaticamente vengono generate 52 istanze (1 anno) dell'evento
- Ogni istanza ha
parentEventIdche punta all'evento genitore - Un cron job giornaliero (ore 2:00) elimina le istanze scadute
# Avvia in modalità development con watch
npm run start:dev
# Build per production
npm run build
# Esegui migrazioni Prisma
npm run prisma:migrate
# Genera Prisma Client
npm run prisma:generatesrc/
├── app.module.ts # Modulo principale
├── index.ts # Entry point
├── clients/ # Modulo client
│ ├── client.module.ts
│ ├── client.controller.ts
│ └── client.service.ts
├── events/ # Modulo events
│ ├── event.module.ts
│ ├── event.controller.ts
│ ├── event.service.ts
│ └── dto/
│ └── event.dto.ts
├── guards/ # Guards
│ └── client-auth.guard.ts
└── prisma/ # Servizi Prisma
└── prisma.service.ts
npm run prisma:generateVerifica che:
- PostgreSQL sia in esecuzione
- L'URL di connessione in
.envsia corretta - I permessi del database siano corretti
Assicurati di:
- Aver creato un client con
POST /clients - Usare il token corretto nell'header
x-client-token
MIT
