-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add elasticsearch service, environment and loader
Some observations: There are two elasticsearch packages in npm worth looking at, 'elasticsearch' and '@elastic/elasticsearch'. The second is meant to replace the first, but mongoose-elasticsearch-xp which will handle the replication of models apparently uses clients from the first. Further down the line we can test if '@elastic/elasticsearch' and be used instead. The elasticsearch client is uncaptured. Use makeConfig() to prevent future issues: See elastic/elasticsearch-js#33
- Loading branch information
1 parent
b98eba4
commit 5d8c38f
Showing
7 changed files
with
144 additions
and
3 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,26 @@ | ||
const elasticsearch = require("elasticsearch"); | ||
const config = require("../config/env"); | ||
|
||
const makeConfig = () => { | ||
if (!(config.db_uri || (config.db_host && config.db_port))) { | ||
console.error("Either 'ES_URI' or 'ES_HOST' and 'ES_PORT' must be specified in the env file! See README.md for details."); | ||
process.exit(125); | ||
} | ||
|
||
const pass = config.es_pass ? `:${config.es_pass}` : ""; | ||
const auth = `${config.es_user}${pass}`; | ||
|
||
const uri = config.es_uri || `http://${config.es_host}:${config.es_port}`; | ||
|
||
return { | ||
host: uri, | ||
httpAuth: auth, | ||
log: "trace", // development only | ||
apiVersion: "7.6", | ||
name: "nijobs-es", | ||
}; | ||
}; | ||
|
||
const setupClient = () => elasticsearch.Client(makeConfig()); | ||
|
||
module.exports = setupClient; |
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