Add @nestjs/serve-static dependency and update file paths for banner uploads; remove unused form utility files

This commit is contained in:
miguel
2025-06-16 13:49:12 -06:00
parent 63e1d3183e
commit 5f302df2a7
18 changed files with 43 additions and 364 deletions
-1
View File
@@ -31,7 +31,6 @@ import { AlumnosModule } from './alumnos/alumnos.module';
@Module({
imports: [
ConfigModule.forRoot({ isGlobal: true }),
TypeOrmModule.forRootAsync({
imports: [ConfigModule],
useFactory: createMainDbConfig,
+1 -1
View File
@@ -46,7 +46,7 @@ export class CuestionarioController {
@UseInterceptors(
FileInterceptor('banner', {
storage: diskStorage({
destination: './public/banners', // Asegúrate de que esta carpeta exista
destination: './uploads/banners', // Asegúrate de que esta carpeta exista
filename: (req, file, cb) => {
const uniqueSuffix =
Date.now() + '-' + Math.round(Math.random() * 1e9);
@@ -6,7 +6,7 @@ import {
ApiTags,
getSchemaPath,
} from '@nestjs/swagger';
import { feriaSexualidad } from '../../../utils/crear_formulario_feria';
/* import { feriaSexualidad } from '../../../utils/crear_formulario_feria'; */
import { applyDecorators } from '@nestjs/common';
import { FormularioDto } from '../dto/formulario.schema';
import {
@@ -47,7 +47,7 @@ export class CuestionarioApiDocumentation {
type: 'number',
example: 1,
}),
ApiResponse({
/* ApiResponse({
status: 200,
description:
'Formulario completo con todas sus secciones, preguntas y opciones. Las preguntas incluyen el atributo "validacion" si tienen reglas de validación específicas (como "correo", "cuenta_alumno", "telefono", "nombre", etc.)',
@@ -58,7 +58,7 @@ export class CuestionarioApiDocumentation {
example: feriaSexualidad,
},
},
}),
}), */
ApiResponse({ status: 404, description: 'Cuestionario no encontrado' }),
);
+1 -1
View File
@@ -16,7 +16,7 @@ export const createMainDbConfig = async (
synchronize: true,
retryAttempts: 5,
retryDelay: 3000,
dropSchema: true,
dropSchema: false,
});
export const createAlumnosDbConfig = async (
+1 -1
View File
@@ -49,7 +49,7 @@ export class EventoController {
@UseInterceptors(
FileInterceptor('banner', {
storage: diskStorage({
destination: './public/banners', // Asegúrate de que esta carpeta exista
destination: './uploads/banners', // Asegúrate de que esta carpeta exista
filename: (req, file, cb) => {
const uniqueSuffix =
Date.now() + '-' + Math.round(Math.random() * 1e9);
+8 -1
View File
@@ -3,9 +3,11 @@ import { AppModule } from './app.module';
import { ValidationPipe } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import { NestExpressApplication } from '@nestjs/platform-express';
import { join } from 'path';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
const app = await NestFactory.create<NestExpressApplication>(AppModule);
const configService = app.get(ConfigService);
// Configuración de validación global
@@ -17,6 +19,11 @@ async function bootstrap() {
}),
);
app.useStaticAssets(join(__dirname, '..', 'uploads'), {
index: false,
prefix: '/',
});
// CORS configuration
app.enableCors({
origin: '*',