🚀 Initialize Musadaq SaaS: Full Backend + AI + React Dashboard + Docker Setup

This commit is contained in:
Hamza-Ayed
2026-04-16 23:26:32 +03:00
commit d66891ba0f
221 changed files with 13079 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
/**
* ════════════════════════════════════════════════════════════
* مُصادَق (Musadaq) — Tenant Middleware
* ════════════════════════════════════════════════════════════
* يستخرج tenantId من JWT ويضعه في request.
* يستخدم في تصفية البيانات (Query filtering).
* ════════════════════════════════════════════════════════════
*/
import {
Injectable,
NestMiddleware,
UnauthorizedException,
} from '@nestjs/common';
import { Request, Response, NextFunction } from 'express';
@Injectable()
export class TenantMiddleware implements NestMiddleware {
use(req: Request, res: Response, next: NextFunction) {
const { user } = req as any;
if (!user || !user.tenantId) {
// Phase 1: Not always required (registration, login)
return next();
}
// Set tenant context for the request
(req as any).tenantId = user.tenantId;
next();
}
}