daily pastebin goal
75%
SHARE
TWEET

Untitled

a guest May 16th, 2018 102 in 21 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'use strict';
  2.  
  3. var express = require('express');
  4. var bodyParser = require('body-parser');
  5. var server;
  6. var app = express();
  7. app.use(bodyParser.json());
  8.  
  9. var init = function () {
  10.  //il file lo lancio come un server a parte
  11.   server = app.listen('8082');
  12. };
  13.  
  14. //Chiamata ad elasticsearch!!!!
  15.  
  16. var elasticSearch = function (req, res) {
  17.   var body = {
  18.     "query": {
  19.       "match_all": {}
  20.     }
  21.   };
  22.   es.search('feeds', 'alienvaultOTX', body, function (error, response) {
  23.     if (array) {
  24.       console.log("array", response);
  25.       res.status(200).type('json').end(response);
  26.     } else if (err) {
  27.       console.log("ELASTICSEARCH SEARCH, err: ", error);
  28.       res.status(200).type('json').end(response);
  29.     }
  30.   });
  31. };
  32.  
  33. app.get('/api/search', elasticSearch);
  34.  
  35. init();
RAW Paste Data
Top