{"size": 1147, "ext": "js", "max_stars_repo_path": "server.js", "max_stars_repo_name": "AAA-Intelligence/docker-backend", "max_stars_repo_stars_event_min_datetime": "2018-09-26T16:48:49.000Z", "max_stars_repo_stars_event_max_datetime": "2018-09-26T16:48:49.000Z", "max_issues_repo_path": "server.js", "max_issues_repo_name": "AAA-Intelligence/docker-backend", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "server.js", "max_forks_repo_name": "AAA-Intelligence/docker-backend", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 24.4042553191, "max_line_length": 70, "alphanum_fraction": 0.6451612903}
"use strict";
var express = require("express");
var bodyParser = require("body-parser");
var cors = require("cors");
var T2M = require("./T2M");
var path = require("path");
T2M = new T2M();

//Init
var app = express();

app.use(express.static(path.join(__dirname, "/public")));

app.use(cors());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json()); // to support JSON-encoded bodies

//Routing
app.get("/", function(req, res) {
  res.send(__dirname + " Hello World");
});

//      title: body.Title,
//       text: body.Text,
//       preciseSearch: body.PreciseSearch,
//       optionsDropDown: body.OptionsDropDown
app.get("/api/submit", function(req, res) {
  let text = req.query.text;
  let title = req.query.title;
  let preciseSearch = req.query.preciseSearch;

  let obj = {
    text: text,
    title: title,
    preciseSearch: preciseSearch
  };
  T2M.createSoundFile(obj, (error, pathToSoundFile) => {
    if (error !== null) {
      return res.send("Error occurred creating sound file: " + error);
    }
    res.send("/" + pathToSoundFile);
  });
});

app.listen(1247);
console.log("Listening on Port 1247");
