summaryrefslogtreecommitdiff
path: root/src/db/elasticsearch.ts
blob: 957b7ad97d13a0571a6e4c41e35454329e177c5d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import * as elasticsearch from 'elasticsearch';
import config from '../config';

// Init ElasticSearch connection
const client = new elasticsearch.Client({
	host: `${config.elasticsearch.host}:${config.elasticsearch.port}`
});

// Send a HEAD request
client.ping({
	// Ping usually has a 3000ms timeout
	requestTimeout: Infinity,

	// Undocumented params are appended to the query string
	hello: 'elasticsearch!'
} as any, error => {
	if (error) {
		console.error('elasticsearch is down!');
	}
});

export default client;