forked from samanthatarrice/wwcode-hackathon2023
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
77 lines (67 loc) · 1.86 KB
/
Copy pathapp.js
File metadata and controls
77 lines (67 loc) · 1.86 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
const express = require("express");
const path = require("path");
const mongoose = require("mongoose");
const ejsMate = require("ejs-mate");
// Mongoose connect:
main().catch((err) =>
console.log("There was an error connecting to Mongo:", err)
);
async function main() {
// * Removed useCreateIndex and useFindAndModify bc it wasn't supported
await mongoose.connect("mongodb://localhost:27017/lavender", {
useNewUrlParser: true,
useUnifiedTopology: true,
});
console.log("Mongo connection open!");
}
const app = express();
app.engine("ejs", ejsMate);
app.set("view engine", "ejs");
app.set("views", path.join(__dirname, "views"));
app.use(express.static(path.join(__dirname, "public")));
// Serve static files from the "public" directory
app.use('/public', express.static('public'));
app.get("/", (req, res) => {
res.render("home");
});
// Goals routes:
app.get("/goals/mindful", (req, res) => {
res.render("goals/mindful");
});
app.get("/goals/inspired", (req, res) => {
res.render("goals/inspired");
});
app.get("/goals/destress", (req, res) => {
res.render("goals/destress");
});
app.get("/goals/calm", (req, res) => {
res.render("goals/calm");
});
app.get("/goals/motivated", (req, res) => {
res.render("goals/motivated");
});
app.get("/goals/grounded", (req, res) => {
res.render("goals/grounded");
});
// Emotions routes:
app.get("/emotions/angry", (req, res) => {
res.render("emotions/angry");
});
app.get("/emotions/anxious", (req, res) => {
res.render("emotions/anxious");
});
app.get("/emotions/happy", (req, res) => {
res.render("emotions/happy");
});
app.get("/emotions/silly", (req, res) => {
res.render("emotions/silly");
});
app.get("/emotions/sad", (req, res) => {
res.render("emotions/sad");
});
app.get("/about", (req, res) => {
res.render("about");
});
app.listen(3000, () => {
console.log("Serving Lavender on port 3000");
});