Skip to content

Commit b754e23

Browse files
committed
elasticsearch and several library updates
1 parent 12046ba commit b754e23

17 files changed

+3738
-2832
lines changed

.docker/logstash/conf/logstash.conf

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ input {
22
jdbc {
33
jdbc_driver_library => "mysql-connector-java-5.1.36-bin.jar"
44
jdbc_driver_class => "com.mysql.jdbc.Driver"
5-
jdbc_connection_string => "jdbc:mysql://mysql:33060/node_es_example"
5+
jdbc_connection_string => "jdbc:mysql://127.0.0.1:33060/node_es_example"
66
jdbc_user => "root"
7-
jdbc_password => "123456"
7+
jdbc_password => ""
88
schedule => "* * * * *"
99
statement => "CALL fetchDataForElastic(:sql_last_value);"
1010
}
@@ -30,9 +30,8 @@ output {
3030

3131
elasticsearch
3232
{
33-
hosts => ["elasticsearch:9200"]
33+
hosts => ["127.0.0.1:9200"]
3434
index => "products"
35-
document_type => "product"
3635
document_id => "%{id}"
3736
}
3837
}

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ PUT products
5252
"type": "custom",
5353
"tokenizer": "standard",
5454
"filter": [
55-
"standard",
5655
"lowercase",
5756
"asciifolding"
5857
]
@@ -70,7 +69,7 @@ PUT products
7069
}
7170
7271
73-
PUT products/product/_mapping
72+
PUT products/_mapping
7473
{
7574
"properties": {
7675
"name": {

app.js

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,26 @@
1-
var express = require('express');
2-
var path = require('path');
3-
var favicon = require('serve-favicon');
4-
var logger = require('morgan');
5-
var cookieParser = require('cookie-parser');
6-
var bodyParser = require('body-parser');
7-
var lessMiddleware = require('less-middleware');
1+
const express = require('express');
2+
const path = require('path');
3+
const logger = require('morgan');
4+
const cookieParser = require('cookie-parser');
5+
const bodyParser = require('body-parser');
6+
const lessMiddleware = require('less-middleware');
87

98
// .env file configuration
109
require('dotenv').config();
1110

1211

13-
var index = require('./routes/index');
14-
var products = require('./routes/products');
15-
var categories = require('./routes/categories');
16-
var search = require('./routes/search');
17-
var graphs = require('./routes/graphs');
12+
const index = require('./routes/index');
13+
const products = require('./routes/products');
14+
const categories = require('./routes/categories');
15+
const search = require('./routes/search');
16+
const graphs = require('./routes/graphs');
1817

19-
var app = express();
18+
const app = express();
2019

2120
// view engine setup
2221
app.set('views', path.join(__dirname, 'views'));
2322
app.set('view engine', 'twig');
2423

25-
// uncomment after placing your favicon in /public
26-
//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
2724
app.use(logger('dev'));
2825
app.use(bodyParser.json());
2926
app.use(bodyParser.urlencoded({ extended: false }));
@@ -39,7 +36,7 @@ app.use('/graphs', graphs);
3936

4037
// catch 404 and forward to error handler
4138
app.use(function(req, res, next) {
42-
var err = new Error('Not Found');
39+
const err = new Error('Not Found');
4340
err.status = 404;
4441
next(err);
4542
});

libraries/database.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var mysql = require('mysql');
1+
var mysql = require('mysql2');
22

33
var pool = mysql.createPool({
44
host: process.env.MYSQL_HOST,

libraries/elasticsearch.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
var elasticsearch = require('elasticsearch');
2-
var client = new elasticsearch.Client({
3-
host: process.env.ELASTIC_HOST,
1+
const { Client } = require('@elastic/elasticsearch');
2+
const client = new Client({
3+
node: process.env.ELASTIC_HOST,
44
log: process.env.ELASTIC_LOG
55
});
66

libraries/redis-client.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
var redis = require('redis');
2-
client = redis.createClient({'host': 'redis'});
2+
client = redis.createClient({'host': process.env.REDIS_HOST});
33

4-
var RedisClient = {
4+
await client.connect();
5+
6+
const RedisClient = {
57
getClient: function() {
68
return client;
79
},

0 commit comments

Comments
 (0)