Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | 2x 2x 25x 25x 25x | import { createParamDecorator, ExecutionContext } from '@nestjs/common';
import type { AuthenticatedSession } from './tenant.guard';
// Injecteaza sesiunea populata de SessionGuard in handler:
// method(@CurrentSession() session: AuthenticatedSession)
export const CurrentSession = createParamDecorator(
(_data: unknown, context: ExecutionContext): AuthenticatedSession => {
const request = context.switchToHttp().getRequest<{ session?: AuthenticatedSession }>();
Iif (!request.session) {
// SessionGuard ruleaza inaintea oricarui handler ne-@Public; daca lipseste
// sesiunea aici e un bug de configurare, nu o eroare de client.
throw new Error('CurrentSession used on a route without SessionGuard');
}
return request.session;
},
);
|