Express.js basic server boilerplate
const express = require('express');
const bodyParser = require('body-parser');
const mongoose = require('mongoose');
const ejs = require('ejs');
const app = express();
app.set("view engine", ejs);
app.use(bodyParser.urlencoded({extended:true}));
app.use(express.static("public"));
//connect to Mongo Atlas
//mongoose.connect("mongodb+srv://USER:PASSWORD@cluster0.dohur.mongodb.net/
//BASE?retryWrites=true&w=majority",
//{useNewUrlParser: true, useUnifiedTopology: true});
//connect to local MongoDB
mongoose.connect('mongodb://localhost:27017/wikiDB', {useNewUrlParser: true, useUnifiedTopology: true});
app.get("/", function(req, res){
res.send("Server is working");
});
//listening for environment port, or else 3000
app.listen(process.env.PORT || 3000, function(){
console.log("Server is running and listening on port 3000");
});