Skip to content

Commit

Permalink
adds documentation and status routes lists routes
Browse files Browse the repository at this point in the history
  • Loading branch information
marshallford committed Jun 17, 2016
1 parent 4decf46 commit adf33e5
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,51 @@
* `npm run dev`
* POST to `http://localhost:8080/api/v1/reverse-geocode`


## Information

### Example response

```json
{
"input": {
"lat": 46,
"lng": -96
},
"output": "26501-26599 210th Ave, Elbow Lake, MN 56531, USA",
"date_retrieved": "2016-06-17T16:11:40.741Z",
"errors": [
"postgis: could not connect to provider"
]
}
```

### General configuration options

|Key|Description|
|---------------|
|`truncate`|number of decimal points to truncate off the lat and long|
|`log`|enable logging, `true` or `false`|
|`redis`|redis options hash|

### Provider setup

|Provider key|Type|Description|
|-----------------------------|
|`type`|`all`|type of provider, current options: `http`, `pg`|
|`limit`|`all`|object containing rate limiting value and time period|
|`priority`|`all`|signifies the order in which providers will be used. A value of `0` will disable the provider. `1` is the highest priority|
|`path`|`all`|the dot notation path of where the address is in the response|
|`failures`|`all`|array of dot notation paths, if these keys are undefined or empty, the provider will be skipped|
|`url`|`http`|API url to consume|
|`key`|`http`|API key used to consume the provider|
|`host`|`pg`|PostgreSQL install location|
|`port`|`pg`|port that PostgreSQL is running on|
|`db`|`pg`|PostgreSQL database name|
|`username`|`pg`|PostgreSQL username|
|`password`|`pg`|PostgreSQL password|
|`query`|`pg`|query to run on the database|

## TODO

* Throttling per provider
6 changes: 5 additions & 1 deletion src/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ providers
const api = () => {
var api = Router()
api.get('/status', (req, res) => {
return res.json({ redis: client.server_info, providers: providers })
const routes = []
api.stack.forEach(singleRoute => {
routes.push(singleRoute.route.path)
})
return res.json({ redis: client.server_info, providers: providers, routes })
})

api.post('/reverse-geocode', (req, res) => {
Expand Down

0 comments on commit adf33e5

Please sign in to comment.