From 0850a6f65911532a9d4497d42e7c78b16b75756a Mon Sep 17 00:00:00 2001 From: JBB0807 <104856796+JBB0807@users.noreply.github.com> Date: Fri, 25 Apr 2025 13:56:35 -0700 Subject: [PATCH] update git ignore --- .gitignore | 1 - assignment-db-service/.env | 12 +++++ assignment-service/.env | 2 + assignment-service/routes/InstructorRouter.js | 50 +++++++++++++++++++ auth-service/.env | 10 ++++ user-db-service/.env | 12 +++++ 6 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 assignment-db-service/.env create mode 100644 assignment-service/.env create mode 100644 assignment-service/routes/InstructorRouter.js create mode 100644 auth-service/.env create mode 100644 user-db-service/.env diff --git a/.gitignore b/.gitignore index 8eca2ac..883eb61 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,6 @@ lerna-debug.log* dist dist-ssr *.local -*.env # Editor directories and files .vscode/* diff --git a/assignment-db-service/.env b/assignment-db-service/.env new file mode 100644 index 0000000..3aaa685 --- /dev/null +++ b/assignment-db-service/.env @@ -0,0 +1,12 @@ +# Environment variables declared in this file are automatically made available to Prisma. +# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema + +# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB. +# See the documentation for all the connection string options: https://pris.ly/d/connection-strings + +#use this when testing local, remmber to run the proxy command +# DATABASE_URL="postgresql://postgres:wly9H8gjjmxYfg1@localhost:15432/postgres?schema=public" + +DATABASE_URL="postgres://postgres:wly9H8gjjmxYfg1@bytecamp-db.flycast:5432?sslmode=disable" +# DATABASE_URL=postgres://snakebyte:zVB7lgOiKr89dq6@localhost:5432/snakebyte?sslmode=disable +NODE_PORT=3000 diff --git a/assignment-service/.env b/assignment-service/.env new file mode 100644 index 0000000..c8a05a6 --- /dev/null +++ b/assignment-service/.env @@ -0,0 +1,2 @@ +#DB_ASSIGNMENT_SERVICE_URL = "http://localhost:3000/" +DB_ASSIGNMENT_SERVICE_URL = "http://db-assignment-service.internal:3000/" diff --git a/assignment-service/routes/InstructorRouter.js b/assignment-service/routes/InstructorRouter.js new file mode 100644 index 0000000..ddfe302 --- /dev/null +++ b/assignment-service/routes/InstructorRouter.js @@ -0,0 +1,50 @@ +const intructorRouter = require("express").Router(); +const passport = require("passport"); +const axios = require("axios"); + +const { DB_ASSIGNMENT_SERVICE_URL } = process.env.DB_ASSIGNMENT_SERVICE_URL || "http://localhost:3000"; + +// +intructorRouter.post("/create", passport.authenticate("jwt", { session: false }), async (req, res) => { + try { + const response = await axios.post(`${DB_ASSIGNMENT_SERVICE_URL}/assignments`, req.body); + res.status(response.status).json(response.data); + } catch (error) { + res.status(error.response?.status || 500).json({ error: error.message }); + } +}); + +// This endpoint is for instructors to get a list of assignments they have created +intructorRouter.get("/list", passport.authenticate("jwt", { session: false }), async (req, res) => { + try { + const instructorId = req.user.id; // Assuming req.user contains the authenticated user + const response = await axios.get(`${DB_ASSIGNMENT_SERVICE_URL}/assignments/instructor/${instructorId}`); + res.status(response.status).json(response.data); + } catch (error) { + res.status(error.response?.status || 500).json({ error: error.message }); + } +}); + +// This endpoint is for instructors to update an assignment +intructorRouter.put("/update/:id", passport.authenticate("jwt", { session: false }), async (req, res) => { + try { + const assignmentId = req.params.id; + const response = await axios.put(`${DB_ASSIGNMENT_SERVICE_URL}/assignments/${assignmentId}`, req.body); + res.status(response.status).json(response.data); + } catch (error) { + res.status(error.response?.status || 500).json({ error: error.message }); + } +}); + +// This endpoint is for instructors to delete an assignment +intructorRouter.delete("/delete/:id", passport.authenticate("jwt", { session: false }), async (req, res) => { + try { + const assignmentId = req.params.id; + const response = await axios.delete(`${DB_ASSIGNMENT_SERVICE_URL}/assignments/${assignmentId}`); + res.status(response.status).json(response.data); + } catch (error) { + res.status(error.response?.status || 500).json({ error: error.message }); + } +}); + +module.exports = intructorRouter; \ No newline at end of file diff --git a/auth-service/.env b/auth-service/.env new file mode 100644 index 0000000..f65f2f8 --- /dev/null +++ b/auth-service/.env @@ -0,0 +1,10 @@ +GOOGLE_CLIENT_ID = "485880105639-1in8tvb6ondnn198rasuj2d8ank06ntp.apps.googleusercontent.com" +GOOGLE_CLIENT_SECRET = "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" +GOOGLE_CALLBACK_URL = "https://byte-camp-auth-service.fly.dev/auth/google/callback" +LOGIN_REDIRECT_URL = "https://bytecamp-web.fly.dev/" +#DB_USER_SERVICE_URL = "http://localhost:3000/" +DB_USER_SERVICE_URL = "http://db-user-service.internal:3000/" +AUTH_SESSION_KEY = "f3f4d8e6b17a4b3abdc8e9a2c0457aaf91c0d5f6e3b7a9c8df624bd71ea35f42" + +fly secrets set GOOGLE_CALLBACK_URL=https://byte-camp-auth-service.fly.dev/auth/google/callback +#fly secrets set GOOGLE_CLIENT_ID=485880105639-1in8tvb6ondnn198rasuj2d8ank06ntp.apps.googleusercontent.com GOOGLE_CLIENT_SECRET=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 LOGIN_REDIRECT_URL=https://bytecamp-web.fly.dev/ DB_USER_SERVICE_URL=https://db-user-service.fly.dev:3000/ AUTH_SESSION_KEY=f3f4d8e6b17a4b3abdc8e9a2c0457aaf91c0d5f6e3b7a9c8df624bd71ea35f42 \ No newline at end of file diff --git a/user-db-service/.env b/user-db-service/.env new file mode 100644 index 0000000..3aaa685 --- /dev/null +++ b/user-db-service/.env @@ -0,0 +1,12 @@ +# Environment variables declared in this file are automatically made available to Prisma. +# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema + +# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB. +# See the documentation for all the connection string options: https://pris.ly/d/connection-strings + +#use this when testing local, remmber to run the proxy command +# DATABASE_URL="postgresql://postgres:wly9H8gjjmxYfg1@localhost:15432/postgres?schema=public" + +DATABASE_URL="postgres://postgres:wly9H8gjjmxYfg1@bytecamp-db.flycast:5432?sslmode=disable" +# DATABASE_URL=postgres://snakebyte:zVB7lgOiKr89dq6@localhost:5432/snakebyte?sslmode=disable +NODE_PORT=3000