Skip to content

Commit

Permalink
Primer commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mavega998 committed Jun 15, 2019
0 parents commit 0f5327c
Show file tree
Hide file tree
Showing 9 changed files with 535 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
3 changes: 3 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"esversion": 8
}
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
## Aplicacion de Clima
Esta aplicación nos muestra a que temperatura estamos según la ciudad que le enviemos por consola.

Utiliza las API de:
- [City Geolocation](https://rapidapi.com/dev132/api/city-geo-location-lookup), con la cual obtenemos la latitud y longitud según el nombre de la ciudad
- [Open Weather Map](https://openweathermap.org/), con la cual obtenemos la temperatura según la latitud y longitud de la ciudad.

### Uso
1. Para poder instalar todos los paquetes debemos ejecutar el siguiente comando.
```
npm install
```
2. Para obtener el mensaje con la temperatura de la ciudad debemos usar el siguiente comando
```
node app -d 'Cucuta Colombia'
#Output El clima de Cucuta Colombia es de 28°C.
```
26 changes: 26 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const { argv } = require('./config/yargs');
const { getLatLng } = require('./place/devrull');
const { getClima } = require('./place/weather');

// getLatLng(argv.direccion)
// .then(resp => {
// return getClima(resp.lat, resp.lng);
// })
// .then(resp => console.log(resp))
// .catch(err => console.log("Error", err));

const getInfo = async(direccion) => {
try {
const geolokt = await getLatLng(direccion);
const weather = await getClima(geolokt.lat, geolokt.lng);
return `El clima de ${direccion} es de ${weather}°C.`;
} catch (err) {
return `No se pudo determinar el clima de ${direccion}`;
}


};

getInfo(argv.direccion)
.then(console.log)
.catch(console.log);
13 changes: 13 additions & 0 deletions config/yargs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const argv = require('yargs')
.options({
direccion: {
alias: 'd',
demand: true
}
})
.help()
.argv;

module.exports = {
argv
};
Loading

0 comments on commit 0f5327c

Please sign in to comment.