-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
34 lines (27 loc) · 775 Bytes
/
app.js
File metadata and controls
34 lines (27 loc) · 775 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
34
const express = require("express");
const mongoose = require("mongoose");
const cors = require("cors");
const mongoOptions = {
useNewUrlParser: true,
useUnifiedTopology: true,
};
// Database connection
mongoose.connect("mongodb://localhost:27017/todo", mongoOptions, (err, db) => {
if (err) throw err;
console.log("Successfully connected to Database.");
});
const app = express();
app.use(express.json());
app.use(cors());
const todo = require("./routes/todo-routes");
app.use("/todo", todo);
const port = 3000;
app.get("/", (request, response) => {
console.log("Base route hit!");
response.json({ success: true, msg: "Base Route HIT!" });
});
// HTTP Server
// 127.0.0.1:3000
app.listen(port, () => {
console.log(`Server Started on Port: ${port}`);
});