-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathserver.js
More file actions
33 lines (26 loc) · 755 Bytes
/
server.js
File metadata and controls
33 lines (26 loc) · 755 Bytes
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
const express = require("express");
const bodyParser = require("body-parser");
const mongoose = require("mongoose");
mongoose.Promise = global.Promise;
mongoose
.connect(YOUR_MONGODB_URL, {
useNewUrlParser: true,
})
.then(() => {
console.log("Successfully connected to the database");
})
.catch((err) => {
console.log("Could not connect to the database. Error...", err);
process.exit();
});
const app = express();
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.get("/", (req, res) => {
res.json({ message: "Server is running :D" });
});
let PORT = 8080;
require("./app/routes/app.routes.js")(app);
app.listen(PORT, () => {
console.log(`Server is listening on port ${PORT}`);
});