-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(libpostal): add support for libpostal over http service, adapter…
… pattern et al.
- Loading branch information
1 parent
63ce233
commit c09b84f
Showing
11 changed files
with
1,557 additions
and
71 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# base image | ||
FROM pelias/libpostal_baseimage | ||
FROM pelias/baseimage | ||
|
||
# dependencies | ||
RUN apt-get update && \ | ||
|
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
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,17 @@ | ||
const ServiceConfiguration = require('pelias-microservice-wrapper').ServiceConfiguration; | ||
|
||
class LibpostalServiceConfig extends ServiceConfiguration { | ||
constructor(config) { | ||
super('libpostal', config); | ||
} | ||
getUrl(params) { | ||
return this.baseUrl + params.endpoint; | ||
} | ||
getParameters(params) { | ||
return { | ||
address: params.address | ||
}; | ||
} | ||
} | ||
|
||
module.exports = LibpostalServiceConfig; |
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,21 @@ | ||
/* | ||
* Return the appropriate version of node-postal | ||
*/ | ||
|
||
const config = require('pelias-config').generate(); | ||
const serviceIsConfigured = config.get('services.libpostal') || config.get('api.services.libpostal'); | ||
|
||
// load the mock library if MOCK_LIBPOSTAL env var is set | ||
if (process.env.MOCK_LIBPOSTAL) { | ||
module.exports = require('./mock'); | ||
} | ||
|
||
// else use the HTTP webservice when configured | ||
else if (serviceIsConfigured) { | ||
module.exports = require('./service'); | ||
} | ||
|
||
// otherwise use the npm module | ||
else { | ||
module.exports = require('./module'); | ||
} |
Oops, something went wrong.