-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
33 lines (29 loc) · 852 Bytes
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Dependencies
const express = require('express');
const mongoose = require('mongoose');
require('dotenv').config();
// Define Express route
const app = express();
// Select A PORT to run on
const PORT = process.env.PORT || 8022;
// Set up Express app
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
app.use(express.static('public'));
// Set up Mongo DB
// db mongo
var MONGODB = process.env.MONGODB_URI;
mongoose.connect(MONGODB || "mongodb://localhost/workout", {
useNewUrlParser: true,
useFindAndModify: false,
useUnifiedTopology: true
});
// Define Express routes
// Creating Routes
require("./routes/apiRoutes")(app);
require("./routes/htmlRoutes")(app);
// Start sever listening
// Starts the server to begin listening
app.listen(PORT, function(){
console.log(`App listening on Port ${PORT}!`);
});