Skip to content

Commit

Permalink
Docs: Describe endpoint param, examples, cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
fvdm committed Jun 10, 2019
1 parent 6c71ed3 commit 1fd346f
Showing 1 changed file with 31 additions and 10 deletions.
41 changes: 31 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ When you don't provide a callback function you'll get
a _promise_ in return.


#### One line with callback
#### Callback function

```js
require ('geoip2ws') (userId, licenseKey) (ip, callback);
Expand Down Expand Up @@ -59,14 +59,15 @@ their GeoIP *web* services. You can find both [*here*](https://www.maxmind.com/e
The functions
-------------

The _first function_ is the setup and takes these settings:
The _first function_ is the config and takes these settings:

parameter | type | required | description
:--------------|:--------|:---------|:--------------------------------
userId | string | yes | Your Maxmind account user ID
licenseKey | string | yes | Your Maxmind account license key
service | string | no | The service you'd like to use: `insights`, `country`, `city` (default)
requestTimeout | integer | no | Socket read timeout in milliseconds to wait for reply from MaxMind
parameter | type | default | description
:----------------|:--------|:------------------|:--------------------------------
[userId] | string | | Your Maxmind account user ID
[licenseKey] | string | | Your Maxmind account license key
[service] | string | city | The service you'd like to use: `insights`, `country`, `city`
[endpoint] | string | geoip.maxmind.com | Override endpoint hostname or full url
[requestTimeout] | integer | 5000 | Socket read timeout in milliseconds to wait for reply from MaxMind

```js
// With arguments
Expand All @@ -82,6 +83,15 @@ const geo = require ('geoip2ws') ({
```


If you are providing the details in the lookup function,
then you don't have to set them here but you do need to
run this config function.

```js
const geo = require ('geoip2ws')();
```


The _second function_ does the IP-address lookup and takes these arguments:

parameter | type | required | description
Expand All @@ -94,6 +104,19 @@ callback | function | no | Your callback. Leave out to return a promise.
geo ('city', '145.53.252.135', myCallback);
```

You can also provide them in an object and include the config parameters.

```js
geo ({
ip: '1.2.3.4',
service: 'city',
endpoint: 'geoip-eu-west.maxmind.com',
})
.then (processData)
.catch (console.error)
;
```


#### Errors

Expand All @@ -106,8 +129,6 @@ request failed | A request error occured | `err.error`
API error | API error occured | `err.code` and `err.error`




Unlicense
---------

Expand Down

0 comments on commit 1fd346f

Please sign in to comment.