swagger
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
export const feriaSexualidad = {
|
||||
nombre_form: 'Registro para la Feria de la Sexualidad - FES Acatlán',
|
||||
descripcion:
|
||||
'La Feria de la Sexualidad es un espacio seguro e informativo dirigido a toda la comunidad universitaria. Este registro nos ayudará a organizar mejor las actividades, talleres y charlas, así como conocer tus intereses. Por favor, completa el siguiente formulario para confirmar tu participación.',
|
||||
fecha_inicio: '2025-03-07T00:00:01',
|
||||
fecha_fin: '2025-03-18T23:59:59',
|
||||
id_tipo_cuestionario: 1,
|
||||
secciones: [
|
||||
{
|
||||
titulo: 'Información Personal',
|
||||
descripcion:
|
||||
'Proporciona tus datos personales para poder contactarte y enviarte información relevante sobre la Feria de la Sexualidad.',
|
||||
preguntas: [
|
||||
{
|
||||
titulo: '¿Eres parte de la comunidad de la FES Acatlán?',
|
||||
tipo: 'Multiple',
|
||||
opciones: [{ valor: 'Si' }, { valor: 'No' }],
|
||||
obligatoria: true,
|
||||
},
|
||||
{
|
||||
titulo: 'Numero de cuenta',
|
||||
obligatoria: true,
|
||||
tipo: 'Numero',
|
||||
},
|
||||
{
|
||||
titulo: 'Nombre(s)',
|
||||
obligatoria: true,
|
||||
tipo: 'Texto',
|
||||
},
|
||||
{
|
||||
titulo: 'Apellidos',
|
||||
obligatoria: true,
|
||||
tipo: 'Texto',
|
||||
},
|
||||
{
|
||||
titulo: 'genero',
|
||||
obligatoria: true,
|
||||
tipo: 'Radio',
|
||||
opciones: [
|
||||
{ valor: 'Masculino' },
|
||||
{ valor: 'Femenino' },
|
||||
{ valor: 'Prefiero no decirlo' },
|
||||
],
|
||||
},
|
||||
{
|
||||
titulo: 'Institución de procedencia',
|
||||
tipo: 'Abierto',
|
||||
obligatoria: true,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -0,0 +1,46 @@
|
||||
// Script para cargar un formulario desde un archivo JSON
|
||||
|
||||
const axios = require('axios');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const API_URL = 'http://localhost:3000';
|
||||
|
||||
async function loadFormFromFile(filePath) {
|
||||
try {
|
||||
// Leer el archivo JSON
|
||||
const formData = require(filePath);
|
||||
|
||||
console.log('Enviando datos del formulario al servidor...');
|
||||
console.log('Datos:', JSON.stringify(formData, null, 2));
|
||||
|
||||
// Enviar los datos al endpoint
|
||||
const response = await axios.post(`${API_URL}/cuestionario`, formData);
|
||||
|
||||
console.log('Formulario creado exitosamente:');
|
||||
console.log(JSON.stringify(response.data, null, 2));
|
||||
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Error al crear el formulario:');
|
||||
if (error.response) {
|
||||
console.error('Status:', error.response.status);
|
||||
console.error('Data:', JSON.stringify(error.response.data, null, 2));
|
||||
} else {
|
||||
console.error(error.message);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// Verificar si se proporcionó un argumento de archivo
|
||||
const args = process.argv.slice(2);
|
||||
const filePath = args[0] || './crear_formulario_feria';
|
||||
|
||||
// Ejecutar la función
|
||||
loadFormFromFile(filePath)
|
||||
.then(() => console.log('Proceso completado'))
|
||||
.catch(() => {
|
||||
console.log('Proceso fallido');
|
||||
process.exit(1);
|
||||
});
|
||||
@@ -0,0 +1,21 @@
|
||||
const comunidad = {
|
||||
id_formulario: 1,
|
||||
respuestas: [
|
||||
{ id_pregunta: 101, valor: 'Si' }, // ¿Eres parte de la comunidad de la FES Acatlán?
|
||||
{ id_pregunta: 102, valor: '123456789' }, // Numero de cuenta
|
||||
{ id_pregunta: 106, valor: 'Prefiero no decirlo' },
|
||||
],
|
||||
fecha_envio: '2025-04-02T13:45:00',
|
||||
};
|
||||
|
||||
const externos = {
|
||||
id_formulario: 1,
|
||||
respuestas: [
|
||||
{ id_pregunta: 101, valor: 'No' }, // ¿Eres parte de la comunidad de la FES Acatlán?
|
||||
{ id_pregunta: 103, valor: 'Juan Carlos' }, // Nombre(s)
|
||||
{ id_pregunta: 104, valor: 'Ramírez López' }, // Apellidos
|
||||
{ id_pregunta: 106, valor: 'Prefiero no decirlo' }, // genero
|
||||
{ id_pregunta: 107, valor: 'UAM Azcapotzalco' }, // Institución de procedencia
|
||||
],
|
||||
fecha_envio: '2025-04-02T13:45:00',
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
import { feriaSexualidad } from './crear_formulario_feria';
|
||||
import axios from 'axios';
|
||||
|
||||
// Asumiendo que el servidor está corriendo en localhost:3000
|
||||
const API_URL = 'http://localhost:3000';
|
||||
|
||||
async function crearFormulario() {
|
||||
try {
|
||||
const response = await axios.post(`${API_URL}/cuestionario`, feriaSexualidad);
|
||||
console.log('Formulario creado exitosamente:');
|
||||
console.log(JSON.stringify(response.data, null, 2));
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Error al crear el formulario:');
|
||||
if (error.response) {
|
||||
console.error('Status:', error.response.status);
|
||||
console.error('Data:', error.response.data);
|
||||
} else {
|
||||
console.error(error.message);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// Ejecutar la función
|
||||
crearFormulario()
|
||||
.then(() => console.log('Proceso completado'))
|
||||
.catch(() => console.log('Proceso fallido'));
|
||||
Reference in New Issue
Block a user