-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5d6d705
Showing
244 changed files
with
22,564 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const lugar = require('./lugar/lugar'); | ||
const clima = require('./clima/clima'); | ||
|
||
const argv = require('yargs').options({ | ||
direccion: { | ||
alias: 'd', | ||
desc: 'Direccion de la ciudad para obener el clima', | ||
demand: true | ||
} | ||
}).argv; | ||
|
||
//lugar.getLugarLatLng(argv.direccion).then(console.log); | ||
//clima.getClima(40.750000, -74.000000).then(console.log); | ||
|
||
const getInfo = async(direccion) => { | ||
|
||
try { | ||
const coordes = await lugar.getLugarLatLng(direccion); | ||
const temp = await clima.getClima(coordes.lat, coordes.lng); | ||
return `El clima de ${coordes.dir} es de ${temp}` | ||
} catch (e) { | ||
return `No se pudo determinar el clima de ${direccion}` | ||
} | ||
|
||
} | ||
|
||
getInfo(argv.direccion) | ||
.then(console.log) | ||
.catch(console.log); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
##Aplicacion del clima - curso node | ||
|
||
Recuerda ejecutar '''npm install''' para las librerias | ||
|
||
|
||
## Ejemplo : node app -d "New York" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const axios = require('axios'); | ||
|
||
const getClima = async(lat, lng) => { | ||
|
||
const resp = await axios.get(`https://api.openweathermap.org/data/2.5/weather?lat=${ lat }&lon=${ lng }&appid=be4d5e9db9b5918cf282c5a9d1aebd35`) | ||
|
||
return resp.data.main.temp; | ||
|
||
} | ||
|
||
|
||
module.exports = { | ||
getClima | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const axios = require('axios'); | ||
|
||
const getLugarLatLng = async(direccion) => { | ||
|
||
const encoudeURL = encodeURI(direccion); | ||
|
||
const instance = axios.create({ | ||
baseURL: 'https://devru-latitude-longitude-find-v1.p.rapidapi.com/latlon.php?location=' + encoudeURL, | ||
headers: { 'X-RapidAPI-Key': '9f7b574f86mshcf6b47f4bde626dp18db4bjsnedb3a25abaaf' } | ||
}); | ||
|
||
const resp = await instance.get(); | ||
|
||
if (resp.data.Results.length === 0) { | ||
throw new Error('No hay resultados para' + direccion); | ||
} | ||
|
||
const data = resp.data.Results[0]; | ||
const dir = data.name; | ||
const lat = data.lat; | ||
const lng = data.lon; | ||
|
||
return { | ||
dir, | ||
lat, | ||
lng | ||
} | ||
|
||
} | ||
|
||
module.exports = { | ||
getLugarLatLng | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.