-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
43 lines (32 loc) · 1.02 KB
/
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
40
41
42
43
const express = require("express");
const logger = require("morgan");
const mongoose = require("mongoose");
const compression = require("compression");
const PORT = process.env.PORT || 3001;
const MONGODB_URI = process.env.MONGODB_URI || "mongodb://0.0.0.0/budget_tracker";
const app = express();
app.use(logger("dev"));
app.use(compression());
app.use(express.urlencoded({
extended: true
}));
app.use(express.json());
app.use(express.static("public"));
// is 27017 for Mongoose?
// removed 27017 from localhost below
mongoose.connect(MONGODB_URI || 'mongodb://0.0.0.0/budget_tracker', {
useNewUrlParser: true,
useFindAndModify: false,
});
// process.env.MONGODB_URI || 'mongodb://localhost/budget_tracker', {
// useNewUrlParser: true,
// useFindAndModify: false,
// };
// removed from process.env above: useUnifiedTopology: true
// routes
// app.use(require("./routes/api.js"));
// app.use("./routes/api");
app.use('/api', require('./routes/api'));
app.listen(PORT, () => {
console.log(`App running on port ${PORT}!`);
});