-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
29 lines (23 loc) · 767 Bytes
/
server.js
File metadata and controls
29 lines (23 loc) · 767 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
const express = require("express");
const mongoose = require("mongoose");
const tasks = require("./routes/tasks");
const app = express();
app.use(express.json());
app.use(express.static(__dirname + "/public"));
app.use("/api/tasks", tasks);
app.set("view engine", "ejs");
mongoose
.connect("mongodb://localhost/roomeaze")
.then(() => console.log("Connected to MongoDB..."))
.catch((err) => console.error("Could not connect to MongoDB..."));
app.get("/", (req, res) => {
res.render("pages/index");
});
app.get("/newtask", (req, res) => {
res.render("pages/newtask");
});
app.get("/tasklist", (req, res) => {
res.render("pages/tasklist");
});
const port = process.env.PORT || 3000;
app.listen(port, () => console.log(`Listening on port ${port}...`));