Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
ff19397
inital commit
devinfiachra Jul 18, 2023
46988b3
initial commit, server connected to frontend and database
devinfiachra Jul 18, 2023
f590d3d
update setup for adaptable
devinfiachra Jul 18, 2023
d221b7d
deployment-update config for external atlas and netlify app
devinfiachra Jul 19, 2023
37fc376
update fallbackroute for local frontend app
devinfiachra Jul 19, 2023
fd54cfb
update frontend url
devinfiachra Jul 19, 2023
0cd8eb8
updated backend messages for clarity
devinfiachra Jul 20, 2023
91f7692
update auth routes so that the user generates a jwt token an is logge…
devinfiachra Jul 20, 2023
88cd0fd
Merge pull request #1 from devinfiachra/release-2023-20-07-1
devinfiachra Jul 20, 2023
1914ca9
therapist auth route and model created
bienenbohnenbuhnen Jul 20, 2023
7e2871b
route url and app js url updated
bienenbohnenbuhnen Jul 21, 2023
b77d56b
therapist sing up and login routes complete
bienenbohnenbuhnen Jul 21, 2023
66b2a56
Merge pull request #3 from devinfiachra/release-2023-21-07-21-1
devinfiachra Jul 21, 2023
ae20862
therapist read and update actions complete
bienenbohnenbuhnen Jul 23, 2023
ab739b4
therapist delete action complete
bienenbohnenbuhnen Jul 23, 2023
427108e
Merge pull request #5 from devinfiachra/release-2023-24-07-1-therapis…
devinfiachra Jul 24, 2023
90b32a8
ai chatbot with pre-defined personality complete
bienenbohnenbuhnen Jul 24, 2023
3aead2b
update config
devinfiachra Jul 24, 2023
61b209a
Merge pull request #7 from devinfiachra/release-2023-24-07-2-ai-thera…
devinfiachra Jul 24, 2023
8a8ebd8
all therapists retrieved from db with get request
bienenbohnenbuhnen Jul 24, 2023
64cc2fc
Merge remote-tracking branch 'origin/therapist-list-page' into releas…
devinfiachra Jul 24, 2023
559f465
Merge pull request #8 from devinfiachra/release-2023-24-07-4-therapis…
devinfiachra Jul 24, 2023
6f83445
therapist info retrieved for details page dynamically
bienenbohnenbuhnen Jul 25, 2023
bfb09e1
Merge remote-tracking branch 'origin/therapist-details-page' into rel…
devinfiachra Jul 25, 2023
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
9 changes: 7 additions & 2 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
PORT=5005
TOKEN_SECRET=1r0Nh4cK
EXTERNAL_URL=
CLIENT_URL=
TOKEN_SECRET=
MONGODB_URI=
PORT=
DATABASE_URL=
OPENAI_API_KEY=
17 changes: 15 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ require("./config")(app);


// 👇 Start handling routes here

const dashboardRouter = require("./routes/dashboard.routes")
app.use("/", dashboardRouter)

const allRoutes = require("./routes");
app.use("/api", allRoutes);

Expand All @@ -19,8 +23,17 @@ app.use("/api", isAuthenticated, projectRouter);
const taskRouter = require("./routes/task.routes");
app.use("/api", isAuthenticated, taskRouter);

const authRouter = require("./routes/auth.routes");
app.use("/auth", authRouter);
const userAuthRouter = require("./routes/userAuth.routes");
app.use("/auth", userAuthRouter);

const therapistAuthRouter = require("./routes/therapistAuth.routes");
app.use("/therapist", therapistAuthRouter);

const therapistRouter = require("./routes/therapist.routes");
app.use("/therapist", isAuthenticated, therapistRouter)

const GPTRouter = require("./routes/gpt.routes");
app.use("/ai-therapist", GPTRouter);

require("./error-handling")(app);

Expand Down
7 changes: 6 additions & 1 deletion config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,20 @@ const cookieParser = require("cookie-parser");

const cors = require("cors");


const client = process.env.CLIENT_URL || "http://localhost:5173"

// Middleware configuration
module.exports = (app) => {
// Because this is a server that will accept requests from outside and it will be hosted ona server with a `proxy`, express needs to know that it should trust that setting.
// Services like heroku use something called a proxy and you need to add this to your server
app.set("trust proxy", 1);

// UPDATED FOR LIVE DEPLOYMENT

app.use(
cors({
origin: ["http://localhost:3000"],
origin: [client],
})
);

Expand Down
2 changes: 1 addition & 1 deletion db/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const mongoose = require("mongoose");
// ℹ️ Sets the MongoDB URI for our app to have access to it.
// If no env has been set, we dynamically set it to whatever the folder name was upon the creation of the app

const MONGO_URI = process.env.MONGODB_URI || "mongodb://127.0.0.1:27017/project-management-server";
const MONGO_URI = process.env.DATABASE_URL ||process.env.MONGODB_URI || "mongodb://127.0.0.1:27017/bookworm-local-test-db";

mongoose
.connect(MONGO_URI)
Expand Down
2 changes: 1 addition & 1 deletion error-handling/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = (app) => {
app.use((req, res, next) => {
// this middleware runs whenever requested page is not available
res.status(404).json({ errorMessage: "This route does not exist" });
res.status(404).json({ errorMessage: "This route does not exist, will never exist, or is yet to be created!" });
});

app.use((err, req, res, next) => {
Expand Down
18 changes: 18 additions & 0 deletions models/Therapist.model.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const mongoose = require("mongoose");
const { Schema, model } = mongoose;

const therapistSchema = new Schema({
email: { type: String, unique: true, required: true },
introduction: { type: String },
password: { type: String, required: true },
name: { type: String, required: true },
location: { type: String, required: true },
price: { type: Number, required: true },
languages: [{ type: String, required: true }],
approach: [{ type: String, required: true }],
specialization: [{ type: String, required: true }],
availability: [{ type: String, required: true }],
appointments: [{ type: Schema.Types.ObjectId, ref: "Appointment" }]
});

module.exports = model("Therapist", therapistSchema);
76 changes: 35 additions & 41 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions routes/dashboard.routes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const router = require("express").Router();

router.get("/", (req, res, next) => {
res.json("Welcome to the Dashboard, all route calls are based off api-address/api/*. In the future we will implement a UI interface for our backend - an admin dashboard. - Stephen, Andy, Devin");
});

module.exports = router;
41 changes: 41 additions & 0 deletions routes/gpt.routes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
const express = require("express");
const router = express.Router();
const mongoose = require("mongoose");
const dotenv = require("dotenv");
dotenv.config();

const chatAPIKey = process.env.OPENAI_API_KEY;

router.post("/completions", async (req, res, next) => {
const options = {
method: "POST",
headers: {
Authorization: `Bearer ${chatAPIKey}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "gpt-3.5-turbo",
messages: [
{
role: "system",
content:
"You are an empathetic companion on an emotional wellbeing app. You offer mental health tips and advice to users based on their prompts. Do not assume the role of a professional and remind them of that.",
},
{ role: "user", content: req.body.message }],
max_tokens: 500,
}),
};
try {
const response = await fetch(
"https://api.openai.com/v1/chat/completions",
options
);
const data = await response.json();
res.send(data);
} catch (error) {
console.log(error);
}
});


module.exports = router;
2 changes: 1 addition & 1 deletion routes/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const router = require("express").Router();

router.get("/", (req, res, next) => {
res.json("All good in here");
res.json("You are on the API Route");
});

module.exports = router;
Loading