-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
39 lines (32 loc) · 1.01 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
const express = require("express");
const path = require("path");
const { MongoClient } = require("mongodb");
require("dotenv").config();
const startupController = require("./startup");
MongoClient.connect(
process.env.MONGODB_URI,
{
useNewUrlParser: true
},
function(err, client) {
if (err) {
return console.error(err);
}
const db = client.db();
const app = express();
app.use("/res", express.static(path.join(__dirname, "res")));
app.set("view engine", "ejs");
app.set("views", path.join(__dirname, "views"));
app.get("/", function(req, res) {res.render("index")})
app.get("/events", function(req, res) {res.render("events")})
app.get("/teams/:id", startupController.renderStartup(db));
app.get("/teams", startupController.showAllStartups(db));
app.get("/siicteam", function(req, res) {
res.render("siicteam", {});
});
const port = process.env.PORT;
app.listen(port, function() {
console.log("Server started on port", port);
});
}
);