{"size": 2362, "ext": "js", "max_stars_repo_path": "app.js", "max_stars_repo_name": "lars-gaechter/first_mongodb", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "app.js", "max_issues_repo_name": "lars-gaechter/first_mongodb", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "app.js", "max_forks_repo_name": "lars-gaechter/first_mongodb", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 46.3137254902, "max_line_length": 1011, "alphanum_fraction": 0.6913632515}
const express = require('express');
const app = express();
const mongoose = require('mongoose');
const bodyParser = require('body-parser');
require('dotenv').config();

// middleware use on any and every route a body parser
app.use(bodyParser.json());


const postsRoute = require('./routes/posts');
// middleware use for posts
app.use('/posts', postsRoute);

// respond with "hello world" when a GET request is made to the homepage
app.get('/', function(req, res) {
    const day_1 = [1977,1802,1856,1309,2003,1854,1898,1862,1857,542,1616,1599,1628,1511,1848,1623,1959,1693,1444,1211,1551,1399,1855,1538,1869,1664,1719,1241,1875,1733,1547,1813,1531,1773,624,1336,1897,1179,1258,1205,1727,1364,1957,540,1970,1273,1621,1964,1723,1699,1847,1249,1254,1644,1449,1794,1797,1713,1534,1202,1951,1598,1926,1865,1294,1893,1641,1325,1432,1960,413,1517,1724,1715,1458,1775,1317,1694,1484,1840,1999,1811,1578,1658,1906,1481,1313,1997,1339,1592,1971,1453,1706,1884,1956,1384,1579,1689,1726,1217,1796,1536,1213,1867,1304,2010,1503,1665,1361,814,2007,1430,1625,1958,860,1799,1942,1876,1772,1198,1221,1814,1826,1667,1334,1504,1420,1164,1414,1934,1823,1507,1195,21,1752,1472,1196,1558,1322,1927,1556,1922,277,1828,1883,1280,1947,1231,1915,1235,1961,1494,1324,2009,1367,1545,1736,1575,1214,1704,1833,1663,1474,1894,1754,1564,1321,1119,1975,1987,1873,1834,1686,1574,1505,1656,1688,1896,1982,1554,1990,1902,1859,1293,1739,1282,1889,1981,1283,1687,1220,1443,1409,1252,1506,1742,1319,1882,951,1849];
    var day_1_subtracted = [];
    var two_values = 1;
    var two_values_list = [];
    function newSubtract(value, index, array) {
        day_1_subtracted[index] = 2020 - value;
    }
    function findSummand(value, index, array) {
        two_values = day_1.find(element => element === value);
        if(two_values !== undefined) {
            console.log(two_values);
            two_values_list.push(two_values);
        }
    }
    day_1.forEach(newSubtract);
    day_1_subtracted.forEach(findSummand);
    console.log(two_values_list[0] * two_values_list[1]);
    
    res.send('home');
});


mongoose.connect(
    process.env.DB_CONNECTION,
    { 
        useUnifiedTopology: true,
        useNewUrlParser: true 
    },
    () => {
        console.log("connected to db")
    }
);

// server start to listen
app.listen(3000);