Comentarios
This commit is contained in:
		| @@ -2,20 +2,42 @@ import ApiResponse from "../interfaces/ApiResponse"; | |||||||
| import Embalse from "../interfaces/Embalse"; | import Embalse from "../interfaces/Embalse"; | ||||||
| import Env from "./Env"; | import Env from "./Env"; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * Wrapper API de la REST de Oracle DB | ||||||
|  |  */ | ||||||
| export default class Api { | export default class Api { | ||||||
|  |   /** | ||||||
|  |    * Conseguir todos los embalses | ||||||
|  |    */ | ||||||
|   static async embalses(): Promise<Embalse[]> { |   static async embalses(): Promise<Embalse[]> { | ||||||
|     return Api._makeReq('/embalses'); |     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[]> { |   static async embalseById(id: string): Promise<Embalse[]> { | ||||||
|     return Api._makeReq(`/embalses/${id}`); |     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[]> { |   static async embalsesNearby(lat: string, lon: string): Promise<Embalse[]> { | ||||||
|     return Api._makeReq(`/embalsesCercanos/${lat}/${lon}`); |     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 hasMore = true; | ||||||
|  |  | ||||||
|     let url = Env.api_base() + endpoint; |     let url = Env.api_base() + endpoint; | ||||||
|   | |||||||
| @@ -1,5 +1,18 @@ | |||||||
|  | /** | ||||||
|  |  * Helper para conseguir las variables del entorno | ||||||
|  |  */ | ||||||
| export default class Env { | export default class Env { | ||||||
|  |   /** | ||||||
|  |    * Base de API | ||||||
|  |    */ | ||||||
|   static api_base(): string { |   static api_base(): string { | ||||||
|     return import.meta.env.VITE_API_BASE; |     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> { | export default interface ApiResponse<T> { | ||||||
|   items: T[]; |   items: T[]; | ||||||
|   hasMore: boolean; |   hasMore: boolean; | ||||||
|   | |||||||
| @@ -1,3 +1,6 @@ | |||||||
|  | /** | ||||||
|  |  * Datos del embalse | ||||||
|  |  */ | ||||||
| export default interface Embalse { | export default interface Embalse { | ||||||
|   id: number |   id: number | ||||||
|   ambito_nombre: string |   ambito_nombre: string | ||||||
|   | |||||||
| @@ -1,3 +1,6 @@ | |||||||
|  | /** | ||||||
|  |  * Respuesta de la API OpenWeatherMap | ||||||
|  |  */ | ||||||
| export default interface OWMResponse { | export default interface OWMResponse { | ||||||
|   cod: string |   cod: string | ||||||
|   message: number |   message: number | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								src/styles/bulma.scss
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								src/styles/bulma.scss
									
									
									
									
										vendored
									
									
								
							| @@ -1,3 +1,5 @@ | |||||||
| @charset 'utf8'; | @charset 'utf8'; | ||||||
|  |  | ||||||
|  | // TODO: MODULAR | ||||||
|  |  | ||||||
| @forward 'bulma/sass'; | @forward 'bulma/sass'; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user