-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
39 lines (30 loc) · 813 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
36
37
38
39
//Dependencies
const express = require("express");
const logger = require("morgan");
const mongoose = require("mongoose");
const compression = require("compression");
//Port
const PORT = process.env.PORT || 3000;
//Express App
const app = express();
//Logger App
app.use(logger("dev"));
// Compression App
app.use(compression());
//Express App
app.use(express.urlencoded({ extended: true }));
app.use(express.json());
app.use(express.static("public"));
// Mongoose Connection
mongoose.connect(process.env.MONGODB_URI || "mongodb://localhost/budget", {
useNewUrlParser: true,
useUnifiedTopology: true,
useCreateIndex: true,
useFindAndModify: false
});
// Routes
app.use(require("./routes/api.js"));
//Listening on Port...
app.listen(PORT, () => {
console.log(`App running on port ${PORT}!`);
});