{"size": 1189, "ext": "js", "max_stars_repo_path": "app.js", "max_stars_repo_name": "alineresendecampos/Project-6", "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": "alineresendecampos/Project-6", "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": "alineresendecampos/Project-6", "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": 22.4339622642, "max_line_length": 64, "alphanum_fraction": 0.6711522288}
const express = require("express");
const multer = require('multer')
const path = require("path");
const hbs = require("express-handlebars");
var cookieParser = require("cookie-parser");
var indexRouter = require("./routes/index");
const mongoose = require("mongoose");

const PORT = process.env.PORT || 3000;

mongoose.connect("mongodb://localhost/project-6", {
  useNewUrlParser: true,
  useUnifiedTopology: true,
});

let db = mongoose.connection;

//check connections
db.once("open", function () {
  console.log("connected to mongoDB");
});

//check for db errors
db.on("error", function (err) {
  console.log(err);
});

const app = express();
// view engine setup
app.engine(
  "hbs",
  hbs({
    layoutsDir: "views/layout",
    defaultLayout: "main",
    extname: "hbs",
    helpers: {
      imageToBase64: (data) => data.buffer.toString('base64'),
    }
  })
);
app.set("view engine", "hbs");

app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, "../public")));

app.use(express.static( "./Images"));

app.use(indexRouter);

app.listen(PORT, console.log(`Server running on port ${PORT}`));
