-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change New Elasticsearch Node.js Client
Change Library elasticsearch 16.7.1 → @elastic/elasticsearch 5.6.22 / 6.8.8 / 7.9.1 Update Library eslint 7.8.1 → 7.10.0 husky 4.2.5 → 4.3.0 Add Library axios 0.20.0
- Loading branch information
1 parent
a4ad1d7
commit 2a8dd26
Showing
8 changed files
with
263 additions
and
138 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,11 @@ | ||
{ | ||
"presets": [ | ||
"@babel/preset-env" | ||
[ | ||
"@babel/preset-env", { | ||
"targets": { | ||
"node": "current" | ||
} | ||
} | ||
] | ||
] | ||
} | ||
} |
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
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,21 +1,27 @@ | ||
import { getClient } from '../../common/elasticsearch_client'; | ||
|
||
export default function indicesHandler(request, response) { | ||
export default async function indicesHandler(request, response) { | ||
/** | ||
* @type {ElastalertServer} | ||
*/ | ||
|
||
var client = getClient(); | ||
try { | ||
const client = await getClient(); | ||
|
||
client.cat.indices({ | ||
h: ['index'] | ||
}).then(function(resp) { | ||
let indices = resp.trim().split('\n'); | ||
response.send(indices); | ||
}, function(err) { | ||
response.send({ | ||
error: err | ||
client.cat.indices({ | ||
h: ['index'] | ||
}, (err, {body}) => { | ||
if (err) { | ||
response.send({ | ||
error: err | ||
}); | ||
} else { | ||
let indices = body.trim().split('\n'); | ||
response.send(indices); | ||
} | ||
}); | ||
}); | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
|
||
} |
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,20 +1,26 @@ | ||
import { getClient } from '../../common/elasticsearch_client'; | ||
|
||
export default function mappingHandler(request, response) { | ||
export default async function mappingHandler(request, response) { | ||
/** | ||
* @type {ElastalertServer} | ||
*/ | ||
|
||
var client = getClient(); | ||
|
||
client.indices.getMapping({ | ||
index: request.params.index | ||
}).then(function(resp) { | ||
response.send(resp); | ||
}, function(err) { | ||
response.send({ | ||
error: err | ||
try { | ||
const client = await getClient(); | ||
|
||
client.indices.getMapping({ | ||
index: request.params.index | ||
}, (err, {body}) => { | ||
if (err) { | ||
response.send({ | ||
error: err | ||
}); | ||
} else { | ||
response.send(body); | ||
} | ||
}); | ||
}); | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
|
||
} |
Oops, something went wrong.