-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
35 lines (28 loc) · 828 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
34
35
// Dependencies
const express = require("express");
const logger = require("morgan");
const mongoose = require("mongoose");
// Setting Port
const PORT = process.env.PORT || 3001;
// Express
const app = express();
app.use(logger("dev"));
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
app.use(express.static("public"));
// Connect to MongoDB w/ Mongoose
mongoose.connect(process.env.MONGODB_URI || "mongodb://localhost/lets-workout", {
useNewUrlParser: true,
useUnifiedTopology: true,
useCreateIndex: true,
useFindAndModify: false
});
// Routes
const apiRouter = require("./routes/apiRoutes.js");
const htmlRouter = require("./routes/htmlRoutes.js");
app.use(apiRouter);
app.use(htmlRouter);
// Starting Server
app.listen(PORT, () => {
console.log(`App running on port ${PORT}!`);
});