-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathojosanciones-web-front.js
46 lines (31 loc) · 1.16 KB
/
ojosanciones-web-front.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
'use strict';
const optionDefinitions = [
{ name: 'elastic_uri', alias: 'e', type: String }, // id field to use for file names in the dataset
{ name: 'keywordList', alias: 'k', type: String }, // id field to use for file names in the dataset
{ name: 'elastic_index', alias: 'i', type: String, defaultValue: "ojosanciones" } // elastic index name to query
];
const commandLineArgs = require('command-line-args');
const args = commandLineArgs(optionDefinitions);
//import user and keyword list
// const keywordList = require(args.keywordList)
const http = require("http");
const db = require("./lib/db");
const views = require("./lib/views");
const host = 'localhost';
const port = 8009 || process.env.OJOSANCIONES_PORT;
const log = ""
main();
//Connect to elastic, query each keyword and send emails
function main() {
db.connect(args.elastic_uri,args).then(() => {
startServer();
}).catch(err => {
process.exit(err);
})
}
function startServer() {
const server = http.createServer(views.requestListener);
server.listen(port, host, () => {
console.log(`Server is running on http://${host}:${port}`);
});
}