{"size": 1352, "ext": "js", "max_stars_repo_path": "index.js", "max_stars_repo_name": "Ch3relle/pt-matching-app", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "index.js", "max_issues_repo_name": "Ch3relle/pt-matching-app", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "index.js", "max_forks_repo_name": "Ch3relle/pt-matching-app", "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": 21.4603174603, "max_line_length": 89, "alphanum_fraction": 0.6531065089}
// requiring packages
const express = require('express');
const app = express();
const path = require('path');

const MongoClient = require('mongodb').MongoClient;
const assert = require('assert');

const bodyParser = require('body-parser');
const dotenv = require('dotenv');
const ejs = require('ejs');

const mongoose = require('mongoose');
const Schema = mongoose.Schema;

require('dotenv').config();

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

// mongodb connection
const uri = process.env.DB_CONNECTION;
const client = new MongoClient(uri, { useNewUrlParser: true, useUnifiedTopology: true });


// static files
app.use(express.static(__dirname + "/public"));

// templating engine ejs
app.set("view engine", "ejs");
app.set("views", path.join(__dirname, "views"));

// routes
// homepage
app.get("/", (req, res) => {
  res.render("home");
});

// users
app.get("/ann", (req, res) => {
  res.render("ann");
});

// about page
app.get("/about", (req, res) => {
  res.render("about");
});

// profile page
app.get("/profile", (req, res) => {
  res.render("profile");
});


// error handling: 404 Not Found
app.use((req, res, next) => {
  res.status(404).send("404 Not Found. Sorry, this page doesn't exist!");
  next();
});

// PORT
const port = process.env.PORT || 3000;
app.listen(port, () => console.log(`Listening on port ${port}...`));
