Skip to content

add user and th pages #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
7cf683b
update mental health tips
e-iroro Nov 4, 2022
1f9039c
added middlewares for handling sessions
qoudri4re Nov 6, 2022
67f4335
added new schema for forum and forum comments, updated the user schem…
qoudri4re Nov 6, 2022
e4d50b6
display the user's name
qoudri4re Nov 6, 2022
57a86f4
implemented session, fetch user details and send to the rendered temp…
qoudri4re Nov 6, 2022
329b4a2
installed modules needed for session
qoudri4re Nov 6, 2022
27a95f9
Merge pull request #14 from consuelo-th/eru-create-mental-health-tips
hassanyahya400 Nov 6, 2022
becdec1
resolve conflict
hassanyahya400 Nov 6, 2022
b1cb9df
Merge pull request #16 from consuelo-th/abdulqodir
hassanyahya400 Nov 6, 2022
5d2f35b
add new database uri, user blog page
hassanyahya400 Nov 6, 2022
ab693a8
Merge pull request #19 from consuelo-th/devhassan
hassanyahya400 Nov 6, 2022
b534d49
create folder for th
hassanyahya400 Nov 7, 2022
e9e2023
Merge pull request #25 from consuelo-th/devhassan
hassanyahya400 Nov 7, 2022
d5ef9ad
Abdulqodir (#27)
qoudri4re Nov 8, 2022
168d685
Create self affirmation (#20)
Thesaleem Nov 8, 2022
4098558
add th dashboard page, toggle password visibility
hassanyahya400 Nov 9, 2022
299615d
add lading page (#35)
hassanyahya400 Nov 12, 2022
ea03391
add animation to the landing page (#36)
hassanyahya400 Nov 13, 2022
1b92ea8
Meet a therapist (#38)
Thesaleem Nov 13, 2022
d05fcff
Devhassan (#39)
hassanyahya400 Nov 13, 2022
eddee9f
meet a therapist page (#40)
hassanyahya400 Nov 13, 2022
ac3159d
add profile page for th (#42)
hassanyahya400 Nov 14, 2022
5cbb02d
add dashboard and user forum (#44)
e-iroro Nov 14, 2022
6963305
Meet a therapist (#45)
Thesaleem Nov 15, 2022
793aa19
retouching profile
hassanyahya400 Nov 15, 2022
cba8170
add fix
hassanyahya400 Nov 15, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
19 changes: 15 additions & 4 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,26 @@ require("./database/connection");
const express = require("express");
const app = express();
const usersRoutes = require("./routes/user");
const therapistsRouter = require("./routes/therapists");
const cookieParser = require("cookie-parser");
const sessions = require("express-session");

app.use(express.static("public"));
app.set("view engine", "ejs");
app.use(express.json());

app.use(
sessions({
secret: "donttellanyone",
saveUninitialized: true,
cookie: { maxAge: 1000 * 60 * 60 * 24 },
resave: false,
})
);
app.use(cookieParser());
// parse incoming post request's body
app.use(express.urlencoded({ extended: false }));

app.use("/user", usersRoutes);
app.use("/th", therapistsRouter);

app.get("/", function (req, res) {
res.render("pages/index");
Expand All @@ -21,8 +32,8 @@ app.get("/design", (req, res) => {
});

app.use((req, res) => {
res.render("pages/errorPages/404");
res.render("templates/404");
});

const PORT = process.env.PORT || 3000;
app.listen(PORT, () => console.log(`Listening on ${PORT}`));
app.listen(PORT, () => console.log(`Listening on ${PORT}`));
3 changes: 2 additions & 1 deletion database/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ let connectionUrl = "";
//is the app app on production or development?
if (process.env.ENVIRONMENT === "development") {
connectionUrl = "mongodb://localhost:27017/consuelo";

} else {
//environment variables needed for connection
const username = process.env.DB_USERNAME;
const password = process.env.DB_PASSWORD;
const cluster = process.env.CLUSTER;
const dbname = process.env.DB_NAME;
connectionUrl = `mongodb://${username}:${password}@${cluster}.mongodb.net:27017,ac-iiwqc6d-shard-00-01.ntnbdr7.mongodb.net:27017,ac-iiwqc6d-shard-00-02.ntnbdr7.mongodb.net:27017/${dbname}?ssl=true&replicaSet=atlas-sgkixf-shard-0&authSource=admin&retryWrites=true&w=majority`;
connectionUrl = `mongodb+srv://${username}:${password}@${cluster}.mongodb.net/${dbname}?retryWrites=true&w=majority`
}

mongoose.connect(connectionUrl, (error) => {
Expand Down
34 changes: 32 additions & 2 deletions database/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const userSchema = new mongoose.Schema({
verified: { type: Boolean, default: false },
//an array of saved affirmation cards ID
savedCardsId: [{ type: String }],
profileImageUrl: { type: String, default: "default-image" },
notifications: [{ read: { type: Boolean, default: false }, content: String }],
});

const affirmationSchema = new mongoose.Schema({
Expand All @@ -22,15 +24,43 @@ const mentalHealthTipSchema = new mongoose.Schema({
description: String,
});

const forumSchema = new mongoose.Schema({
author: String,
datePosted: Date,
content: String,
likes: { type: Number, default: 0 },
comments: { type: Number, default: 0 },
});

const forumCommentSchema = new mongoose.Schema({
postID: String,
authorID: String,
comment: String,
});

const blogSchema = new mongoose.Schema({
title: String,
datePosted: Date,
readTime: String,
author: String,
content: String,
});

const User = mongoose.model("User", userSchema);
const Affirmation = mongoose.model("Affirmation", affirmationSchema);
const MentalHealthTips = mongoose.model(
const MentalHealthTip = mongoose.model(
"Mental Health Tip",
mentalHealthTipSchema
);
const forum = mongoose.model("Forum", forumSchema);
const forumComment = mongoose.model("Forum comments", forumCommentSchema);
const blog = mongoose.model("blog", blogSchema);

module.exports = {
User,
Affirmation,
MentalHealthTips,
MentalHealthTip,
forum,
forumComment,
blog,
};
5 changes: 5 additions & 0 deletions load.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
DB_USERNAME="dev"
DB_PASSWORD="dev"
CLUSTER="cluster1.8bih7o7"
DB_NAME="consuelo-test"
ENVIRONMENT=""
Loading