Skip to content

Commit

Permalink
Initial release πŸŽ‰πŸŽ‰πŸŽ‰
Browse files Browse the repository at this point in the history
  • Loading branch information
AleshaOleg committed Aug 6, 2017
1 parent ee22710 commit a3f6148
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"parser": "babel-eslint",
"env": {
"es6": true,
"node": true
},
"extends": "standard"
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
.idea
7 changes: 7 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.gitignore
.npmignore

node_modules/
npm-debug.log

.idea/
16 changes: 16 additions & 0 deletions README.md
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`
23 changes: 23 additions & 0 deletions index.js
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}`)
})
43 changes: 43 additions & 0 deletions package.json
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"
}
}

0 comments on commit a3f6148

Please sign in to comment.