-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
51 lines (44 loc) · 1.39 KB
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
'use strict';
var restify = require('restify');
var plugins = require('restify-plugins');
var restifyValidator = require('restify-validator');
var server = restify.createServer({
name: '[Vin Elasticsearch]',
version: '1.0.0'
});
//var elasticsearch = require('elasticsearch');
var setupController = require('./controllers/setupController.js');
var client = require('./controllers/elasticConnection.js');
setupController(server, restify, plugins, restifyValidator);
function checkElasticSearchHealth(){
client.cluster.health({},function(err,resp,status) {
console.log("-- Client Health --",resp);
});
}
checkElasticSearchHealth();
//require and init
function requireAndInit(handlers) {
handlers.map((handler) => {
require(handler).call(null, server);
});
}
requireAndInit([
'./routes/getUsers.js',
'./routes/getApps.js',
'./routes/createIndexMappingType.js',
'./routes/checkESCloud.js',
'./routes/addTypeToIndex.js',
'./routes/addTranTemplate.js',
'./routes/createTranIndex.js',
'./routes/addDataDirectToTranIndex.js',
'./routes/getIndexDataCount.js',
'./routes/getIndexDataById.js',
'./routes/createIndexAliasByRounting.js',
'./routes/swapAliasToIndex.js',
'./routes/getAliasDataCountForIndex.js',
'./routes/addDataViaAlias.js',
// Assuming this list gets long
]);
server.listen(8080, function () {
console.log('%s listening at %s', server.name, server.url);
});