-
Notifications
You must be signed in to change notification settings - Fork 1
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
1 parent
ee22710
commit a3f6148
Showing
6 changed files
with
99 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,8 @@ | ||
{ | ||
"parser": "babel-eslint", | ||
"env": { | ||
"es6": true, | ||
"node": true | ||
}, | ||
"extends": "standard" | ||
} |
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,2 @@ | ||
node_modules | ||
.idea |
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,7 @@ | ||
.gitignore | ||
.npmignore | ||
|
||
node_modules/ | ||
npm-debug.log | ||
|
||
.idea/ |
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 |
---|---|---|
@@ -1,2 +1,18 @@ | ||
# pogodka | ||
Get current weather, from console | ||
|
||
## Installing | ||
|
||
Install package globaly with command: | ||
|
||
`npm i pogodka -g` | ||
|
||
## Usage | ||
|
||
Just type in command line, one of these commands: | ||
|
||
- `pogodka` | ||
- `pogoda` | ||
- `pgd` | ||
- `weather` | ||
- `wthr` |
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,23 @@ | ||
#! /usr/bin/env node | ||
|
||
const geoip = require('geoip-lite') | ||
const extIP = require('ext-ip')() | ||
const request = require('request') | ||
|
||
const apiKey = 'f2d5b989dfafdab237be56401ef53185' | ||
|
||
extIP.get().then(ip => { | ||
const geo = geoip.lookup(ip) | ||
const req = 'http://api.openweathermap.org/data/2.5/weather?' | ||
request(`${req}lat=${geo.ll[0]}&lon=${geo.ll[1]}&appid=${apiKey}&units=metric`, | ||
(err, res, body) => { | ||
if (!err) { | ||
const response = JSON.parse(body) | ||
console.log(`Current temperature in ${response.name}: ${response.main.temp}`) | ||
} else { | ||
console.log(`Can't get weather. Try again.\nMore: ${err}`) | ||
} | ||
}) | ||
}, err => { | ||
console.error(`Can't get your location.\nMore: ${err}`) | ||
}) |
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,43 @@ | ||
{ | ||
"version": "0.0.1", | ||
"author": { | ||
"name": "Oleh Aloshkin" | ||
}, | ||
"bin": { | ||
"pogodka": "./index.js", | ||
"weather": "./index.js" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/AleshaOleg/pogodka/issues" | ||
}, | ||
"dependencies": { | ||
"ext-ip": "^0.3.8", | ||
"geoip-lite": "^1.2.1" | ||
}, | ||
"description": "Get current weather, from console", | ||
"devDependencies": { | ||
"babel-eslint": "^7.2.3", | ||
"eslint": "^4.4.0", | ||
"eslint-config-standard": "^10.2.1", | ||
"eslint-plugin-import": "^2.7.0", | ||
"eslint-plugin-node": "^5.1.1", | ||
"eslint-plugin-promise": "^3.5.0", | ||
"eslint-plugin-standard": "^3.0.1" | ||
}, | ||
"gitHead": "ee22710e008046226a4cc9fba94c88c0f6e2e15d", | ||
"homepage": "https://github.com/AleshaOleg/pogodka#readme", | ||
"keywords": [ | ||
"weather", | ||
"console-weather" | ||
], | ||
"license": "ISC", | ||
"main": "index.js", | ||
"name": "pogodka", | ||
"optionalDependencies": {}, | ||
"readme": "# pogodka\nGet current weather, from console\n", | ||
"readmeFilename": "README.md", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/AleshaOleg/pogodka.git" | ||
} | ||
} |