Comentarios
This commit is contained in:
		| @@ -2,20 +2,42 @@ import ApiResponse from "../interfaces/ApiResponse"; | ||||
| import Embalse from "../interfaces/Embalse"; | ||||
| import Env from "./Env"; | ||||
|  | ||||
| /** | ||||
|  * Wrapper API de la REST de Oracle DB | ||||
|  */ | ||||
| export default class Api { | ||||
|   /** | ||||
|    * Conseguir todos los embalses | ||||
|    */ | ||||
|   static async embalses(): Promise<Embalse[]> { | ||||
|     return Api._makeReq('/embalses'); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Conseguir embalse a partir de su id | ||||
|    * @param id ID del embalse | ||||
|    * @returns Lista de embalses que coinciden con la búsqueda | ||||
|    */ | ||||
|   static async embalseById(id: string): Promise<Embalse[]> { | ||||
|     return Api._makeReq(`/embalses/${id}`); | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Conseguir todos los embalses cercanos | ||||
|    * @param lat Latitud | ||||
|    * @param lon Longitud | ||||
|    * @returns Lista de embalses cercanos | ||||
|    */ | ||||
|   static async embalsesNearby(lat: string, lon: string): Promise<Embalse[]> { | ||||
|     return Api._makeReq(`/embalsesCercanos/${lat}/${lon}`); | ||||
|   } | ||||
|  | ||||
|   static async _makeReq<T>(endpoint: string): Promise<T[]> { | ||||
|   /** | ||||
|    * Método privado para enviar solicitudes | ||||
|    * @param endpoint Endpoint requerido | ||||
|    * @returns Lista de elementos | ||||
|    */ | ||||
|   private static async _makeReq<T>(endpoint: string): Promise<T[]> { | ||||
|     let hasMore = true; | ||||
|  | ||||
|     let url = Env.api_base() + endpoint; | ||||
|   | ||||
| @@ -1,5 +1,18 @@ | ||||
| /** | ||||
|  * Helper para conseguir las variables del entorno | ||||
|  */ | ||||
| export default class Env { | ||||
|   /** | ||||
|    * Base de API | ||||
|    */ | ||||
|   static api_base(): string { | ||||
|     return import.meta.env.VITE_API_BASE; | ||||
|   } | ||||
|  | ||||
|   /** | ||||
|    * Clave API de OpenWeatherMap | ||||
|    */ | ||||
|   static owm_key(): string { | ||||
|     return import.meta.env.VITE_OWM_KEY; | ||||
|   } | ||||
| } | ||||
|   | ||||
| @@ -1,3 +1,6 @@ | ||||
| /** | ||||
|  * Respuesta de Oracle DB | ||||
|  */ | ||||
| export default interface ApiResponse<T> { | ||||
|   items: T[]; | ||||
|   hasMore: boolean; | ||||
|   | ||||
| @@ -1,3 +1,6 @@ | ||||
| /** | ||||
|  * Datos del embalse | ||||
|  */ | ||||
| export default interface Embalse { | ||||
|   id: number | ||||
|   ambito_nombre: string | ||||
|   | ||||
| @@ -1,3 +1,6 @@ | ||||
| /** | ||||
|  * Respuesta de la API OpenWeatherMap | ||||
|  */ | ||||
| export default interface OWMResponse { | ||||
|   cod: string | ||||
|   message: number | ||||
|   | ||||
							
								
								
									
										2
									
								
								src/styles/bulma.scss
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								src/styles/bulma.scss
									
									
									
									
										vendored
									
									
								
							| @@ -1,3 +1,5 @@ | ||||
| @charset 'utf8'; | ||||
|  | ||||
| // TODO: MODULAR | ||||
|  | ||||
| @forward 'bulma/sass'; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user