REST API for managing publications and files for Curaduria 2 Cartagena.
⭐ If you find this project helpful, please consider giving it a star!
- User Authentication (JWT)
- File Records Management
- Publication System
- AWS S3 Integration for File Storage
- Environment-based Configuration
- CORS Support
- Health Check Endpoint
- PHP 8.2+
- MySQL/MariaDB
- Apache with mod_rewrite enabled
- Composer (for development)
- Clone the repository:
git clone https://github.com/yourusername/apiCuraduria2ca.git- Set up your environment variables by copying the example file:
cp api/.env.example api/.env- Configure your
.envfile with your credentials:
DB_HOST=your_host
DB_NAME=your_database
DB_USER=your_user
DB_PASS=your_password
PATH_AWS=your_aws_url
MAIL_TO=[email protected]
MAIL_FROM=[email protected]
AWS_ACCESS_KEY_ID=your_aws_key
AWS_SECRET_ACCESS_KEY=your_aws_secret
AWS_BUCKET=your_bucket
AWS_BUCKET_FOLDER=your_folder
AWS_REGION=your_region
API_URL_FRONT=your_api_url
APP_ENV=prodGET /or/health-check- System health check and API informationPOST /login- User loginGET /expedientes- Query record by ID and yearGET /publicaciones- List all publicationsGET /publicaciones/{id}- Get publication by IDGET /publicaciones?fecha_inicio=&fecha_fin=- Search by date rangeGET /tipos-publicacion- List publication typesGET /tipos-publicacion/{id}- Get publication type by ID
All protected endpoints require a valid JWT token in the Authorization header: Authorization: Bearer {your_token}
POST /register- Register new userGET /verify-token- Verify JWT tokenPOST /logout- User logout
POST /publicaciones- Create new publicationPUT /publicaciones/{id}- Update publicationDELETE /publicaciones/{id}- Delete publication
The project uses GitHub Actions for automated deployment. The workflow:
-
Triggers on:
- Push to main/master
- Merged pull requests to main/master
-
Deployment process:
- Checks out the code
- Creates production .env file
- Deploys via FTP to production server
Required GitHub Secrets for deployment:
FTP_HOSTFTP_USERNAMEFTP_PASSWORD- All environment variables listed in the Installation section
- JWT for API authentication
- CORS headers configured
- Environment-based configuration
- Secure file handling
- AWS S3 for secure file storage
The API supports multiple environments:
local- Developmentstage- Stagingprod- Production
Each environment can have its own .env.{environment} file.
API REST para la gestión de publicaciones y archivos de la Curaduría 2 de Cartagena.
⭐ Si encuentras útil este proyecto, ¡considera darle una estrella!
- Autenticación de Usuarios (JWT)
- Gestión de Expedientes
- Sistema de Publicaciones
- Integración con AWS S3 para Almacenamiento
- Configuración basada en Entornos
- Soporte CORS
- Endpoint de Verificación de Salud
- PHP 8.2+
- MySQL/MariaDB
- Apache con mod_rewrite habilitado
- Composer (para desarrollo)
- Clonar el repositorio:
git clone https://github.com/tuusuario/apiCuraduria2ca.git- Configurar variables de entorno copiando el archivo de ejemplo:
cp api/.env.example api/.env- Configurar el archivo
.envcon tus credenciales:
DB_HOST=tu_host
DB_NAME=tu_base_de_datos
DB_USER=tu_usuario
DB_PASS=tu_contraseña
PATH_AWS=tu_url_aws
MAIL_TO=[email protected]
MAIL_FROM=[email protected]
AWS_ACCESS_KEY_ID=tu_clave_aws
AWS_SECRET_ACCESS_KEY=tu_secreto_aws
AWS_BUCKET=tu_bucket
AWS_BUCKET_FOLDER=tu_carpeta
AWS_REGION=tu_region
API_URL_FRONT=tu_url_api
APP_ENV=prodGET /o/health-check- Verificación de salud del sistema e información de la APIPOST /login- Inicio de sesiónGET /expedientes- Consultar expediente por ID y añoGET /publicaciones- Listar todas las publicacionesGET /publicaciones/{id}- Obtener publicación por IDGET /publicaciones?fecha_inicio=&fecha_fin=- Buscar por rango de fechasGET /tipos-publicacion- Listar tipos de publicaciónGET /tipos-publicacion/{id}- Obtener tipo de publicación por ID
Todos los endpoints protegidos requieren un token JWT válido en el encabezado Authorization: Authorization: Bearer {tu_token}
POST /register- Registro de usuarioGET /verify-token- Verificar token JWTPOST /logout- Cerrar sesión
POST /publicaciones- Crear nueva publicaciónPUT /publicaciones/{id}- Actualizar publicaciónDELETE /publicaciones/{id}- Eliminar publicación
El proyecto usa GitHub Actions para despliegue automatizado. El workflow:
-
Se activa con:
- Push a main/master
- Pull requests fusionados en main/master
-
Proceso de despliegue:
- Obtiene el código
- Crea archivo .env de producción
- Despliega vía FTP al servidor de producción
Secretos requeridos en GitHub para el despliegue:
FTP_HOSTFTP_USERNAMEFTP_PASSWORD- Todas las variables de entorno listadas en la sección de Instalación
- JWT para autenticación de API
- Cabeceras CORS configuradas
- Configuración basada en entorno
- Manejo seguro de archivos
- AWS S3 para almacenamiento seguro
La API soporta múltiples entornos:
local- Desarrollostage- Pruebasprod- Producción
Cada entorno puede tener su propio archivo .env.{entorno}.