- Clonar repo
- npm install
- npm start
Asegúrate de tener el archivo .env en la carpeta y el servidor en ejecución en http://localhost:3000 antes de probar las siguientes rutas. Puedes usar herramientas como Thunder Client, Postman o cURL para interactuar con la API. Nombre de la base de datos en postgres = usertest
Ejemplo del archivo .env:
DB_USER = " "
DB_PASSWORD = " "
DB_HOST = localhost
PORT = 3000
Tech Stack:
- Express
- Postgresql
- Sequelize
- Nodemon
- JsonWebToken < para el manejo de inicio de sesion
- BCrypt < para hashear contraseñas
- Joi < para validar el input del la base de datos
Ruta: POST http://localhost:3000/user Descripción: Crea un nuevo usuario en la base de datos. Cuerpo (JSON):
{
"username": "nombre_usuario",
"email": "correo@dominio.com",
"password": "contraseña_segura",
"type": "Parents",
"nombre": "Nombre",
"apellidoPaterno": "ApellidoPaterno",
"apellidoMaterno": "ApellidoMaterno",
"complete": false,
"validate": false,
"state": true
}
{
"id": "12345-abcde-67890-fghij",
"email": "correo@dominio.com",
"type": "Parents",
"nombre": "Nombre",
"apellidoPaterno": "ApellidoPaterno",
"apellidoMaterno": "ApellidoMaterno",
"complete": false,
"validate": false,
"state": true
}
Ruta: GET http://localhost:3000/user Descripción: Obtiene todos los usuarios activos en la base de datos. Respuesta Esperada (Ejemplo):
[
{
"id": "12345-abcde-67890-fghij",
"email": "correo@dominio.com",
"type": "Parents",
"nombre": "Nombre",
"apellidoPaterno": "ApellidoPaterno",
"apellidoMaterno": "ApellidoMaterno",
"complete": false,
"validate": false,
"state": true
},
// Otros usuarios...
]
Ruta: GET http://localhost:3000/user/:id Descripción: Obtiene los detalles de un usuario específico por su ID. Respuesta Esperada (Ejemplo):
{
"id": "12345-abcde-67890-fghij",
"email": "correo@dominio.com",
"type": "Parents",
"nombre": "Nombre",
"apellidoPaterno": "ApellidoPaterno",
"apellidoMaterno": "ApellidoMaterno",
"complete": false,
"validate": false,
"state": true
}
Ruta: PUT http://localhost:3000/user/:id Descripción: Actualiza los detalles de un usuario específico por su ID. Cuerpo (JSON): (Enviar solo los campos que deseas actualizar)
{
"type": "Admin",
"complete": true
}
{
"id": "12345-abcde-67890-fghij",
"email": "correo@dominio.com",
"type": "Admin",
"nombre": "Nombre",
"apellidoPaterno": "ApellidoPaterno",
"apellidoMaterno": "ApellidoMaterno",
"complete": true,
"validate": false,
"state": true
}
Ruta: PUT http://localhost:3000/user/:id Descripción: Realiza una eliminación lógica (inactiva) de un usuario por su ID. Respuesta Esperada:
{
"message": "Usuario eliminado exitosamente"
}
POST a: http://localhost:3001/parents
Por body:
{
"idDoc":"12345678-1",
"name":"name-1",
"lastName":"lastname-1",
"educationLevel":"high school-1",
"profession":"worker-1",
"address":"house addres 123-1",
"jobAddress":"job address 123-1",
"telephone":"123456789-1",
"jobTelephone":"987654321-1",
"contactCellphone":"911-1",
"email":"test-1@gmail.com",
"tutor":"false",
"userId":"12345-abcde-67890-fghij" // <<-- id de User a relacionar
}
(ejemplo 2)
{
"idDoc":"12345678-2",
"name":"name 2",
"lastName":"lastname 2",
"educationLevel":"high school 2",
"profession":"worker 2",
"address":"house addres 123-2",
"jobAddress":"jobaddress 123-2",
"telephone":"123456788-2",
"jobTelephone":"987654321-2",
"contactCellphone":"911-2",
"email":"test-2@gmail.com",
"tutor":"true"
"userId":"12345-abcde-67890-fghij" // <<-- id de User a relacionar
}
{
"id": "47496be7-8eb3-4e12-b39a-32a646740a23",
"state": true,
"idDoc":"12345678-1",
"name":"name-1",
"lastName":"lastname-1",
"educationLevel":"high school-1",
"profession":"worker-1",
"address":"house addres 123-1",
"jobAddress":"job address 123-1",
"telephone":"123456789-1",
"jobTelephone":"987654321-1",
"contactCellphone":"911-1",
"email":"test-1@gmail.com",
"tutor":"false"
"updatedAt": "2023-12-12T23:01:25.193Z",
"createdAt": "2023-12-12T23:01:25.193Z"
}
GET a : localhost:3001/parents
(Primero realizar algunos POST para llenar la db)
[
{
"id": "47496be7-8eb3-4e12-b39a-32a646740a23",
"idDoc": "12345678",
"name": "name1",
"lastName": "lastname1",
"educationLevel": "high school",
"profession": "worker",
"address": "house addres 123",
"jobAddress": "jobaddress 123",
"telephone": "123456789",
"jobTelephone": "987654321",
"contactCellphone": "911",
"email": "test@gmail.com",
"tutor": false,
"state": true,
"createdAt": "2023-12-12T23:01:25.193Z",
"updatedAt": "2023-12-12T23:01:25.193Z"
},
{
"id": "75dc8813-2292-4965-b429-f27e2ea814bd",
"idDoc": "1234567",
"name": "name",
"lastName": "lastname",
"educationLevel": "high school",
"profession": "worker",
"address": "house addres 123",
"jobAddress": "jobaddress 123",
"telephone": "12345678",
"jobTelephone": "987654321",
"contactCellphone": "911",
"email": "test2@gmail.com",
"tutor": false,
"state": true,
"createdAt": "2023-12-12T23:03:15.276Z",
"updatedAt": "2023-12-12T23:03:15.276Z"
}
]
GET a localhost:3001/parents/"ID OBJETIVO"
{
"id": "332379ab-ed62-4ce6-9ef4-0634bacb022e",
"idDoc": "12345678",
"name": "name1",
"lastName": "lastname1",
"educationLevel": "high school",
"profession": "worker",
"address": "house addres 123",
"jobAddress": "job address 123",
"telephone": "123456789",
"jobTelephone": "987654321",
"contactCellphone": "911",
"email": "test@gmail.com",
"tutor": false,
"state": true,
"createdAt": "2023-12-13T01:26:33.241Z",
"updatedAt": "2023-12-13T01:26:33.241Z"
}
PUT a: localhost:3001/parents/"ID OBJETIVO"
Por body:
{
"profession":"enginner",
"address":"updating address"
}
(Sólo son necesarios los campos a actualizar)
{
"id": "02aee226-ef09-4e2e-b3fd-d3df156f47c7",
"idDoc": "12345678",
"name": "name2",
"lastName": "lastname2",
"educationLevel": "high school",
"profession": "enginner",❗
"address": "updating address",❗
"jobAddress": "jobaddress 123",
"telephone": "123456788",
"jobTelephone": "987654321",
"contactCellphone": "911",
"email": "test3@gmail.com",
"tutor": false,
"state": true,
"createdAt": "2023-12-12T23:47:20.009Z",
"updatedAt": "2023-12-12T23:47:42.532Z"
}
PUT a : localhost:3001/parents/delete/"ID OBJETIVO"
{
"message": "Parent unsubscribed successfully"
}
❗Luego de hacer un borrado logico, si se realiza una nueva solicitud POST repitiendo alguno de los campos que son unicos(idDoc por ejemplo) deberia devolver error de que no puede repetirse ese campo(ya que no se realizó un DELETE).
Ruta: POST http://localhost:3000/estudiantes Descripción: Crea un nuevo estudiante en la base de datos. Cuerpo (JSON):
{
"idDocumento": 110112,
"nombres": "andres j",
"apellidoPat": "caicedo",
"apellidoMat": "cabrera",
"Nacionalidad": "colombiano",
"fechNac": "1990-05-15",
"sexo": "masculino",
"peso": 75,
"estatura": 175,
"alergias": "no",
"grupoSanguineo": "b positivo",
"contactoEmerg": 6243427,
"fotoPerfil": "url",
"fotoDocumento": "url",
"state": true
"parentId":"47496be7-8eb3-4e12-b39a-32a646740a23"
}
{
"id": "5c4154ef-2f1a-4946-bbef-fdb23c9f5ece",
"idDocumento": 110112,
"nombres": "andres j",
"apellidoPat": "caicedo",
"apellidoMat": "cabrera",
"Nacionalidad": "colombiano",
"fechNac": "1990-05-15T00:00:00.000Z",
"sexo": "masculino",
"peso": 75,
"estatura": 175,
"alergias": "no",
"grupoSanguineo": "b positivo",
"contactoEmerg": 6243427,
"fotoPerfil": "url",
"fotoDocumento": "url",
"state": true
}
Ruta: GET http://localhost:3000/estudiantes Descripción: Obtiene todos los estudaintes activos en la base de datos. Respuesta Esperada (Ejemplo):
[
{
"id": "5c4154ef-2f1a-4946-bbef-fdb23c9f5ece",
"idDocumento": 110112,
"nombres": "andres j",
"apellidoPat": "caicedo",
"apellidoMat": "cabrera",
"Nacionalidad": "colombiano",
"fechNac": "1990-05-15T00:00:00.000Z",
"sexo": "masculino",
"peso": 75,
"estatura": 175,
"alergias": "no",
"grupoSanguineo": "b positivo",
"contactoEmerg": 6243427,
"fotoPerfil": "url",
"fotoDocumento": "url",
"state": true
},
// Otros usuarios...
]
Ruta: GET http://localhost:3000/estudiantes/:id Descripción: Obtiene los detalles de un estudiante específico por su ID. Respuesta Esperada (Ejemplo):
{
"id": "5c4154ef-2f1a-4946-bbef-fdb23c9f5ece",
"idDocumento": 110112,
"nombres": "andres j",
"apellidoPat": "caicedo",
"apellidoMat": "cabrera",
"Nacionalidad": "colombiano",
"fechNac": "1990-05-15T00:00:00.000Z",
"sexo": "masculino",
"peso": 75,
"estatura": 175,
"alergias": "no",
"grupoSanguineo": "b positivo",
"contactoEmerg": 6243427,
"fotoPerfil": "url",
"fotoDocumento": "url",
"state": true
}
Ruta: PUT http://localhost:3000/estudiantes/:id Descripción: Actualiza los detalles de un estudiante específico por su ID. Cuerpo (JSON): (Enviar solo los campos que deseas actualizar)
{
"nombres": "andres jose",
}
{
"id": "5c4154ef-2f1a-4946-bbef-fdb23c9f5ece",
"idDocumento": 110112,
"nombres": "andres jose",
"apellidoPat": "caicedo",
"apellidoMat": "cabrera",
"Nacionalidad": "colombiano",
"fechNac": "1990-05-15T00:00:00.000Z",
"sexo": "masculino",
"peso": 75,
"estatura": 175,
"alergias": "no",
"grupoSanguineo": "b positivo",
"contactoEmerg": 6243427,
"fotoPerfil": "url",
"fotoDocumento": "url",
"state": true
}
Ruta: DELETE http://localhost:3000/estudiantes/:id Descripción: Realiza una eliminación lógica (inactiva) de un estudiante por su ID. Respuesta Esperada:
{
"message": "Estudiante eliminado exitosamente"
}
GET a: http://localhost:3001/admin/parents-Active
[
{
"id": "9258460c-90b4-4848-8fa9-fd8fe45efe16",
"idDocumento": 440485387,
"nombres": "Frank68",
"apellidoPat": "Pérez",
"apellidoMat": "Rodríguez",
"Nacionalidad": "Canadian",
"fechNac": "2000-01-01T00:00:00.000Z",
"sexo": "Gender",
"peso": 70,
"estatura": 149,
"alergias": "Allergies",
"grupoSanguineo": "BloodGroup",
"contactoEmerg": 147838896,
"fotoPerfil": "ProfilePhotoURL",
"fotoDocumento": "DocumentPhotoURL",
"validate": true,
"state": true
},
{
"id": "3bdecce2-5bb3-46be-9ab2-3ec17691943a",
"idDocumento": 786372166,
"nombres": "Hannah41",
"apellidoPat": "García",
"apellidoMat": "Rodríguez",
"Nacionalidad": "Brazilian",
"fechNac": "2000-01-01T00:00:00.000Z",
"sexo": "Gender",
"peso": 51,
"estatura": 132,
"alergias": "Allergies",
"grupoSanguineo": "BloodGroup",
"contactoEmerg": 967384331,
"fotoPerfil": "ProfilePhotoURL",
"fotoDocumento": "DocumentPhotoURL",
"validate": true,
"state": true
},
{...❗resto que tengan validate: true❗...}
]
GET a : localhost:3001/admin/parents-Pending
[
{
"id": "3f8c9e38-e304-4c92-9f1e-0718d31015cd",
"idDoc": "356945668",
"fotoDocumento": "fotoDocumento",
"name": "Emma53",
"lastName": "López85",
"educationLevel": "High-School",
"profession": "Unknow",
"address": "Address",
"jobAddress": "JobAddress",
"telephone": "123456789",
"jobTelephone": "987654321",
"contactCellphone": "9876543210",
"email": "emma70@example.com",
"tutor": true,
"validate": false,
"state": true,
"createdAt": "2023-12-21T18:22:01.818Z",
"updatedAt": "2023-12-21T18:22:01.818Z"
},
{
...❗resto que tengan validate: false❗...
}
]
GET a localhost:3001/admin/parentDetail/"ID OBJETIVO"
{
"id": "f1f5c68c-2489-4e96-8bfb-fc9eb8f6dc9c",
"idDoc": "396364208",
"fotoDocumento": "fotoDocumento",
"name": "Emma92",
"lastName": "Sánchez40",
"educationLevel": "High-School",
"profession": "Unknow",
"address": "Address",
"jobAddress": "JobAddress",
"telephone": "123456789",
"jobTelephone": "987654321",
"contactCellphone": "9876543210",
"email": "hannah31@example.com",
"tutor": true,
"validate": true,
"state": true,
"createdAt": "2023-12-21T18:22:01.644Z",
"updatedAt": "2023-12-21T18:22:01.644Z"
}
PUT a: localhost:3001/admin/parentDetail/"ID OBJETIVO"
{
"message": "Parent approved successfully"
}
🔸Se actualizara su propiedad validate a true.
GET a: http://localhost:3001/admin/students-Active
[
{
"id": "9258460c-90b4-4848-8fa9-fd8fe45efe16",
"idDocumento": 440485387,
"nombres": "Frank68",
"apellidoPat": "Pérez",
"apellidoMat": "Rodríguez",
"Nacionalidad": "Canadian",
"fechNac": "2000-01-01T00:00:00.000Z",
"sexo": "Gender",
"peso": 70,
"estatura": 149,
"alergias": "Allergies",
"grupoSanguineo": "BloodGroup",
"contactoEmerg": 147838896,
"fotoPerfil": "ProfilePhotoURL",
"fotoDocumento": "DocumentPhotoURL",
"validate": true,
"state": true
},
{
...❗resto que tengan validate: TRUE❗...
}
]
GET a : localhost:3001/admin/students-Pending
[
{
"id": "11d3d019-c05a-4054-84cb-a5a0860486b0",
"idDocumento": 469231307,
"nombres": "David22",
"apellidoPat": "Martínez",
"apellidoMat": "Pérez",
"Nacionalidad": "Australian",
"fechNac": "2000-01-01T00:00:00.000Z",
"sexo": "Gender",
"peso": 91,
"estatura": 188,
"alergias": "Allergies",
"grupoSanguineo": "BloodGroup",
"contactoEmerg": 136750238,
"fotoPerfil": "ProfilePhotoURL",
"fotoDocumento": "DocumentPhotoURL",
"validate": false,
"state": true
},
{
...❗resto que tengan validate: FALSE❗...
}
]
GET a localhost:3001/admin/studentDetail/"ID OBJETIVO"
{
"id": "11d3d019-c05a-4054-84cb-a5a0860486b0",
"idDocumento": 469231307,
"nombres": "David22",
"apellidoPat": "Martínez",
"apellidoMat": "Pérez",
"Nacionalidad": "Australian",
"fechNac": "2000-01-01T00:00:00.000Z",
"sexo": "Gender",
"peso": 91,
"estatura": 188,
"alergias": "Allergies",
"grupoSanguineo": "BloodGroup",
"contactoEmerg": 136750238,
"fotoPerfil": "ProfilePhotoURL",
"fotoDocumento": "DocumentPhotoURL",
"validate": false,
"state": true
}
PUT a: localhost:3001/admin/studentDetail/"ID OBJETIVO"
{
"message": Student approved successfully
}
🔸Se actualizara su propiedad validate a true.
GET a: localhost:3001/admin/"ID OBJETIVO"
{
"id": "192820e3-a3bc-44f1-bbfd-99da823d0200",
"email": "hannah81@example.com",
"password": "password123",
"type": "Parents",
"nombre": "Alice",
"apellidoPaterno": "Pérez",
"apellidoMaterno": "González",
"complete": true,
"validate": false,
"state": true,
"createdAt": "2023-12-21T18:22:01.602Z",
"updatedAt": "2023-12-21T18:22:01.602Z"
}
Ruta no necesariamente a utilizar en algo, podria ser una vista inicial del administrador, devuelve sus datos mientras tanto
🔸Se actualizara su propiedad validate a true.