Comparing version 1.0.1 to 1.0.2
50
index.js
@@ -1,47 +0,27 @@ | ||
#!/usr/bin/env node | ||
'use strict'; | ||
var got = require('got'); | ||
const got = require('got'); | ||
var cheerio = require('cheerio'); | ||
var Promise = require('pinkie-promise'); | ||
module.exports = function (username) { | ||
module.exports = (username, opts) => { | ||
if (typeof username !== 'string') { | ||
return Promise.reject(new Error('username required')); | ||
throw new TypeError(`Expected a string, got ${typeof username}`); | ||
} | ||
var url = 'http://en.gravatar.com/' + username; | ||
if (typeof opts !== 'string') { | ||
throw new TypeError(`Expected a string, got ${typeof opts}`); | ||
} | ||
return got(url).then(function (res) { | ||
var $ = cheerio.load(res.body); | ||
const url = `https://en.gravatar.com/${username}.json`; | ||
return got(url, {json: true}).then(res => { | ||
const val = res.body; | ||
return { | ||
username: $('.fn').text() || null, | ||
location: $('.location').text() || null, | ||
biography: $('#bio').text().trim() || null, | ||
wordpress: $('a.accounts_wordpress').attr('href') || null, | ||
twitter: $('a.accounts_twitter').attr('href') || null, | ||
facebook: $('a.accounts_facebook').attr('href') || null, | ||
flickr: $('a.accounts_flickr').attr('href') || null, | ||
googlePlus: $('a.accounts_google').attr('href') || null, | ||
linkedIn: $('a.accounts_linkedin').attr('href') || null, | ||
youtube: $('a.accounts_youtube').attr('href') || null, | ||
blogger: $('a.accounts_blogger').attr('href') || null, | ||
tumblr: $('a.accounts_tumblr').attr('href') || null | ||
opts: val.entry[0][opts] | ||
}; | ||
}).catch(err => { | ||
if (err) { | ||
err.message = `${username} is not a gravatar user`; | ||
} | ||
return err.message; | ||
}); | ||
}; |
{ | ||
"name": "gravator", | ||
"version": "1.0.1", | ||
"description": "Get user information of a Gravatar user", | ||
"version": "1.0.2", | ||
"description": "An unofficial API for Gravatar.com mostly for scrapping user data", | ||
"license": "MIT", | ||
@@ -32,5 +32,3 @@ "repository": { | ||
"dependencies": { | ||
"cheerio": "^0.19.0", | ||
"got": "^5.0.0", | ||
"pinkie-promise": "^2.0.0" | ||
"got": "^5.0.0" | ||
}, | ||
@@ -37,0 +35,0 @@ "devDependencies": { |
102
README.md
<h1 align="center"> | ||
<img src="media/gravator.png" alt="GRAVATOR" width="400"> | ||
<img src="https://raw.githubusercontent.com/CodeDotJS/gravator/master/media/gravator.png" alt="GRAVATOR" width="400"> | ||
<br> | ||
<img src="https://travis-ci.org/CodeDotJS/gravator.svg?branch=master"> | ||
<img src="https://img.shields.io/badge/code_style-XO-5ed9c7.svg"> | ||
</h1> | ||
<h5 align="center">Get user information of a Gravatar User</h5> | ||
<p align="center"><b>An unofficial API for Gravatar.com mostly for scrapping user data.</b></p> | ||
<h1 align="center"> | ||
<img src="https://travis-ci.org/CodeDotJS/gravator.svg?branch=master"> | ||
</h1> | ||
## Install | ||
## Install | ||
``` | ||
@@ -20,40 +18,80 @@ $ npm install --save gravator | ||
- `username` of a gravatar user is always __`foo`__`@example.com` | ||
```js | ||
'use strict'; | ||
const gravator = require('rushforlinux'); | ||
const gravator = require('gravator'); | ||
gravator('rushforlinux').then(user => { | ||
console.log(user); | ||
/* | ||
{ username : 'Rishi Giri (DotJS)', | ||
location : 'Gorakhpur', | ||
biography : 'JavaScript, Python and FOSS Enthusiast. Open Source Addict.', | ||
wordpress : null, | ||
twitter : 'http://twitter.com/Rishi_Giri_', | ||
facebook : 'https://www.facebook.com/rishi.giri.90', | ||
flickr : null, | ||
googlePlus : 'http://profiles.google.com/106157567815478859311', | ||
linkedIn : 'https://www.linkedin.com/in/rishidotjs', | ||
youtube : null, | ||
blogger : 'http://www.blogger.com/profile/g106157567815478859311', | ||
tumblr : 'http://geekyrush.tumblr.com/' } | ||
*/ | ||
gravator('username', 'options').then(res => { | ||
console.log(res); | ||
// {opts: 'data'} | ||
}); | ||
gravator('foo', 'hash').then(res => { | ||
console.log(res); | ||
// {opts: 'foo'} | ||
}) | ||
``` | ||
## Related | ||
## API | ||
- [gravator-cli](https://github.com/CodeDotJS/gravator-cli) : CLI Tool for Gravator. | ||
### `gravator(username, options)` | ||
- [twifo](https://github.com/CodeDotJS/whatiz-cli) : Get user information of a twitter user. | ||
#### __`username`__ | ||
- [packages-by](https://github.com/CodeDotJS/packages-by) : Total packages published by a npm user. | ||
Type: `string` | ||
- [packstat](https://github.com/CodeDotJS/packstat) : Displays metrics about npm modules. | ||
#### __`options`__ | ||
- [curver](https://github.com/CodeDotJS/curver) : Easily fetch the latest version of node module available on npm. | ||
Type: `string` | ||
Options: | ||
- `id` | ||
__`Example `__ | ||
```js | ||
gravator('matt', 'id').then(res => { | ||
console.log(res); | ||
// // {opts: '5'} | ||
}); | ||
``` | ||
- `hash` | ||
- `requestHash` | ||
- `profileUrl` | ||
- `preferredUsername` | ||
- `thumbnailUrl` | ||
- `photos` | ||
- `name` | ||
- `ims` | ||
- `displayName` | ||
- `aboutMe` | ||
- `currentLocation` | ||
- `emails` | ||
- `accounts` | ||
- `urls` | ||
## Related | ||
- __[`gravator-cli`](https://github.com/CodeDotJS/gravator-cli)__ `: CLI Tool for Gravator.` | ||
- __[`twifo`](https://github.com/CodeDotJS/whatiz-cli)__ `: Get user information of a twitter user.` | ||
## License | ||
MIT © [Rishi Giri](http://rishigiri.com/) | ||
MIT © [Rishi Giri](http://rishigiri.com) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1
97
3993
22
- Removedcheerio@^0.19.0
- Removedpinkie-promise@^2.0.0
- Removedboolbase@1.0.0(transitive)
- Removedcheerio@0.19.0(transitive)
- Removedcss-select@1.0.0(transitive)
- Removedcss-what@1.0.0(transitive)
- Removeddom-serializer@0.1.1(transitive)
- Removeddomelementtype@1.3.1(transitive)
- Removeddomhandler@2.3.0(transitive)
- Removeddomutils@1.4.31.5.1(transitive)
- Removedentities@1.0.01.1.2(transitive)
- Removedhtmlparser2@3.8.3(transitive)
- Removedisarray@0.0.1(transitive)
- Removedlodash@3.10.1(transitive)
- Removednth-check@1.0.2(transitive)
- Removedreadable-stream@1.1.14(transitive)
- Removedstring_decoder@0.10.31(transitive)