{"size": 1015, "ext": "js", "max_stars_repo_path": "backend/src/app.js", "max_stars_repo_name": "QuanticTM/tienda", "max_stars_repo_stars_event_min_datetime": "2021-11-03T02:01:09.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-15T22:45:49.000Z", "max_issues_repo_path": "backend/src/app.js", "max_issues_repo_name": "QuanticTM/tienda", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "backend/src/app.js", "max_forks_repo_name": "QuanticTM/tienda", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 3, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 23.0681818182, "max_line_length": 127, "alphanum_fraction": 0.6610837438}
const exp = require("express");
const path = require("path");
const mongoose = require("mongoose");
const app = exp();

// routes

app.use("/products", require("./routes/productsR"));


// it changes the server port or defaults to 4269

app.set('port', process.env.PORT || 4269 );

// middleware

app.use(exp.urlencoded({extended: false}));
app.use(exp.json());

const connectionUrl = "mongodb+srv://dbAdmin:b1pIzXu8ucc6RXt4@cluster0.5roux.mongodb.net/Cluster0?retryWrites=true&w=majority";


const { MongoClient } = require('mongodb');

try{
    const client = new MongoClient(connectionUrl, { useNewUrlParser: true, useUnifiedTopology: true });
    client.connect(err => {
      const collection = client.db("test").collection("devices");
      // perform actions on the collection object
      client.close();
    });
    app.listen( app.get("port"), () => {
        console.log("connected to port " + app.get("port"));
    });
}
catch(err){
    console.log(err);
    console.log("An error has occurred");
}




