Restructure backend into modular API layers with admin/organizador/invitados routes, add role-based middleware, flatten module models, and update build scripts

This commit is contained in:
mberlin
2026-03-19 09:15:22 -03:00
parent 989b19d338
commit 996c6e9241
285 changed files with 6551 additions and 2914 deletions

View File

@@ -0,0 +1,27 @@
import { Injectable } from '@nestjs/common';
import { v4 as uuidv4 } from 'uuid';
import { AuthToken } from '../entities/token.entity';
@Injectable()
export class TokenService {
// En una implementación real esto debería usar el repositorio de MikroORM.
private tokens: AuthToken[] = [];
createToken(name?: string, expiresInHours?: number): AuthToken {
const token = new AuthToken();
token.token = uuidv4();
token.name = name;
if (expiresInHours) {
token.expiresAt = new Date(Date.now() + expiresInHours * 60 * 60 * 1000);
}
this.tokens.push(token);
return token;
}
validate(tokenString: string): AuthToken | null {
const token = this.tokens.find((t) => t.token === tokenString);
if (!token) return null;
if (token.expiresAt && token.expiresAt < new Date()) return null;
return token;
}
}