{"id":30947643,"url":"https://github.com/ingfranciscastillo/elysia-weather-api","last_synced_at":"2026-05-05T06:42:19.893Z","repository":{"id":313306450,"uuid":"1050858112","full_name":"ingfranciscastillo/elysia-weather-api","owner":"ingfranciscastillo","description":"Un microservicio moderno y eficiente para obtener datos meteorológicos con cache, construido con Elysia.js sobre Bun.","archived":false,"fork":false,"pushed_at":"2025-09-05T05:59:28.000Z","size":37,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-09-05T07:30:06.983Z","etag":null,"topics":["bun","elysia","elysiajs","openweathermap","openweathermap-api","redis","sqlite"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ingfranciscastillo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-05T03:57:46.000Z","updated_at":"2025-09-05T06:41:21.000Z","dependencies_parsed_at":"2025-09-05T07:30:27.371Z","dependency_job_id":"1662b3e5-a108-4a1b-b132-6768eceef0ff","html_url":"https://github.com/ingfranciscastillo/elysia-weather-api","commit_stats":null,"previous_names":["ingfranciscastillo/elysia-weather-api"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/ingfranciscastillo/elysia-weather-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ingfranciscastillo%2Felysia-weather-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ingfranciscastillo%2Felysia-weather-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ingfranciscastillo%2Felysia-weather-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ingfranciscastillo%2Felysia-weather-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ingfranciscastillo","download_url":"https://codeload.github.com/ingfranciscastillo/elysia-weather-api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ingfranciscastillo%2Felysia-weather-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274563396,"owners_count":25308397,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-11T02:00:13.660Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bun","elysia","elysiajs","openweathermap","openweathermap-api","redis","sqlite"],"created_at":"2025-09-11T02:00:39.191Z","updated_at":"2026-05-05T06:42:14.855Z","avatar_url":"https://github.com/ingfranciscastillo.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🌤️ Microservicio de Clima con Elysia.js\n\nUn microservicio moderno y eficiente para obtener datos meteorológicos con cache, construido con **Elysia.js** sobre **Bun**.\n\n## ✨ Características\n\n- **API REST** con endpoints para consultas individuales y en lote\n- **Cache inteligente** con TTL de 10 minutos (SQLite o Redis)\n- **Datos en tiempo real** de OpenWeatherMap\n- **TypeScript** con tipos seguros\n- **Middleware de logging** para monitoreo\n- **Graceful shutdown** y manejo de errores robusto\n- **Health check** endpoint\n\n## 📁 Estructura del Proyecto\n\n```\nweather-microservice/\n├── src/\n│   ├── config/\n│   │   └── env.ts           # Configuración de variables de entorno\n│   ├── db/\n│   │   ├── schema.ts        # Esquema Drizzle ORM\n│   │   └── connection.ts    # Conexión SQLite con Drizzle\n│   ├── lib/\n│   │   └── redis.ts         # Cliente Redis dedicado\n│   ├── middleware/\n│   │   └── logging.ts       # Middleware de logging\n│   ├── routes/\n│   │   ├── health.ts        # Ruta de health check\n│   │   └── weather.ts       # Rutas de clima\n│   ├── services/\n│   │   ├── cache.ts         # Gestor de cache (Redis + SQLite)\n│   │   └── weather.ts       # Servicio de clima\n│   └── types/\n│       └── weather.ts       # Tipos TypeScript\n├── drizzle/                 # Migraciones generadas\n├── index.ts                 # Archivo principal\n├── drizzle.config.ts        # Configuración Drizzle\n├── package.json\n├── tsconfig.json\n└── .env.example\n```\n\n## 🚀 Instalación Rápida\n\n### Prerrequisitos\n\n- [Bun](https://bun.sh)\n- [Bun sqlite](https://bun.com/docs/api/sqlite)\n- [Redis](https://redis.io)\n- API Key de [OpenWeatherMap](https://openweathermap.org/api) (gratuita)\n\n### Paso a paso\n\n1. **Crear estructura de carpetas:**\n\n```bash\nmkdir -p src/{config,db,lib,middleware,routes,services,types}\n```\n\n2. **Instalar dependencias:**\n\n```bash\n# Instalar dependencias\nbun add elysia axios redis drizzle-orm\nbun add -d drizzle-kit bun-types\n```\n\n3. **Configurar Redis:**\n\n```bash\n# Instalar Redis (Ubuntu/Debian)\nsudo apt update \u0026\u0026 sudo apt install redis-server\n\n# Iniciar Redis\nredis-server\n\n# O usando Docker\ndocker run -d --name redis -p 6379:6379 redis:alpine\n```\n\n4. **Configurar variables de entorno:**\n\n```bash\n# Copiar archivo de ejemplo\ncp .env.example .env\n\n# Editar .env con tus datos\nOPENWEATHER_KEY=tu_api_key_de_openweathermap\nPORT=3000\nREDIS_URL=redis://localhost:6379\n```\n\n5. **Ejecutar el servidor:**\n\n```bash\n# Desarrollo (con auto-reload)\nbun run dev\n\n# Producción\nbun run start\n```\n\nEl servidor estará corriendo en `http://localhost:3000`\n\n## 📡 Endpoints API\n\n### 🏥 Health Check\n\n```bash\nGET /health\n```\n\nRespuesta con estadísticas detalladas:\n\n```json\n{\n  \"status\": \"healthy\",\n  \"service\": \"weather-microservice\",\n  \"timestamp\": \"2024-01-15T10:30:00.000Z\",\n  \"uptime\": 3600,\n  \"cache\": {\n    \"redis_connected\": true,\n    \"sqlite_enabled\": true,\n    \"total_entries\": 25,\n    \"valid_entries\": 20,\n    \"expired_entries\": 5\n  },\n  \"version\": \"2.0.0\"\n}\n```\n\n### 🌍 Clima de una ciudad\n\n```bash\nGET /weather/:city\n```\n\n**Ejemplo:**\n\n```bash\ncurl http://localhost:3000/weather/Madrid\n```\n\n**Respuesta (sin cambios):**\n\n```json\n{\n  \"success\": true,\n  \"data\": {\n    \"city\": \"Madrid\",\n    \"country\": \"ES\",\n    \"temperature\": 22,\n    \"feels_like\": 24,\n    \"humidity\": 65,\n    \"pressure\": 1013,\n    \"description\": \"cielo claro\",\n    \"icon\": \"01d\",\n    \"wind_speed\": 3.2,\n    \"visibility\": 10000,\n    \"timestamp\": 1705312200000\n  }\n}\n```\n\n### 🗺️ Clima de múltiples ciudades (Batch)\n\n```bash\nGET /weather?cities=city1,city2,city3\n```\n\n**Ejemplo:**\n\n```bash\ncurl \"http://localhost:3000/weather?cities=Madrid,Paris,Tokyo\"\n```\n\n## ⚡ Sistema de Cache Híbrido\n\n### **Flujo de Cache:**\n\n1. **Consulta** → Buscar en Redis (ultra rápido)\n2. **Si no existe** → Buscar en SQLite (respaldo)\n3. **Si no existe** → Llamar API → Guardar en Redis + SQLite\n4. **Cache hit** → Respuesta inmediata\n\n### **Ventajas:**\n\n✅ **Velocidad** - Redis para consultas frecuentes\n✅ **Persistencia** - SQLite mantiene datos después de reiniciar\n✅ **Redundancia** - Doble respaldo de datos\n✅ **Auto-healing** - Si Redis falla, SQLite sigue funcionando\n\n## 🛠️ Scripts de Base de Datos\n\n```bash\n# Generar migraciones Drizzle\nbun run db:generate\n\n# Aplicar migraciones\nbun run db:push\n\n# Ver schema actual\nbunx drizzle-kit studio\n```\n\n## 📊 Monitoreo Avanzado\n\n### **Logs del Sistema:**\n\n```\n🚀 GET /weather/Madrid - 2024-01-15T10:30:00.000Z\n📦 Redis cache hit for Madrid\n✅ GET /weather/Madrid - 200 (2ms)\n```\n\n### **Cache Stats en /health:**\n\n- Total de entradas en cache\n- Entradas válidas vs expiradas\n- Estado de conexión Redis\n- Uptime del servicio\n\n## 📄 License\n\nMIT License - úsalo como quieras 🎉\n\n---\n\n**Hecho con ❤️ usando Elysia.js y Bun**\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fingfranciscastillo%2Felysia-weather-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fingfranciscastillo%2Felysia-weather-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fingfranciscastillo%2Felysia-weather-api/lists"}