refactor: enhance module exports and imports across services
Refactor multiple modules to improve dependency management by adding missing imports (e.g., `AuthModule`, `CryptoModule`) and ensuring essential services and repositories are exported. Update Dockerfile for better build and runtime efficiency, improve CORS handling, and enhance validation with updates to DTOs. Include package.json refinements for dependency organization.
This commit is contained in:
@@ -24,14 +24,31 @@ async function bootstrap() {
|
||||
}
|
||||
|
||||
// Sécurité
|
||||
app.use(helmet());
|
||||
app.enableCors({
|
||||
origin:
|
||||
configService.get("NODE_ENV") === "production"
|
||||
? [configService.get("DOMAIN_NAME") as string]
|
||||
: true,
|
||||
credentials: true,
|
||||
});
|
||||
app.use(
|
||||
helmet({
|
||||
crossOriginResourcePolicy: { policy: "cross-origin" },
|
||||
}),
|
||||
);
|
||||
const corsEnabled = Boolean(configService.get<boolean>("ENABLE_CORS"));
|
||||
if (corsEnabled) {
|
||||
const domainName = configService.get<string>("CORS_DOMAIN_NAME");
|
||||
app.enableCors({
|
||||
origin: (origin, callback) => {
|
||||
if (!origin || domainName === "*") {
|
||||
callback(null, true);
|
||||
return;
|
||||
}
|
||||
|
||||
const allowedOrigins = domainName?.split(",").map((o) => o.trim()) || [];
|
||||
if (allowedOrigins.includes(origin)) {
|
||||
callback(null, true);
|
||||
} else {
|
||||
callback(null, false);
|
||||
}
|
||||
},
|
||||
credentials: true,
|
||||
});
|
||||
}
|
||||
|
||||
// Validation Globale
|
||||
app.useGlobalPipes(
|
||||
@@ -49,4 +66,4 @@ async function bootstrap() {
|
||||
await app.listen(port);
|
||||
logger.log(`Application is running on: http://localhost:${port}`);
|
||||
}
|
||||
bootstrap();
|
||||
bootstrap().then();
|
||||
|
||||
Reference in New Issue
Block a user