From 52968f84abe2bb044f530ae105b0698a627aa792 Mon Sep 17 00:00:00 2001 From: Jared E Plummer <113934345+JaredPlummer5@users.noreply.github.com> Date: Thu, 28 Sep 2023 14:53:22 -0500 Subject: [PATCH 01/12] Pusher setup --- .env | 2 +- app/api/Class/[id]/route.ts | 43 ++++++++++++ app/api/Class/route.ts | 50 ++++++++++++++ app/api/User/[id]/route.ts | 43 ++++++++++++ app/api/User/route.ts | 11 ++- app/api/message/route.ts | 9 +++ app/api/pusher-auth/route.ts | 26 ++++++++ app/db/models/Class.ts | 26 ++++++++ app/db/models/User.ts | 16 ++++- app/db/models/project.ts | 18 ++++- app/layout.tsx | 4 +- app/page.tsx | 67 ++++++++++++++----- lib/pusher.ts | 23 +++++++ middleware.ts | 4 +- package-lock.json | 126 +++++++++++++++++++++++++++++++++-- package.json | 3 + 16 files changed, 438 insertions(+), 33 deletions(-) create mode 100644 app/api/Class/[id]/route.ts create mode 100644 app/api/Class/route.ts create mode 100644 app/api/User/[id]/route.ts create mode 100644 app/api/message/route.ts create mode 100644 app/api/pusher-auth/route.ts create mode 100644 app/db/models/Class.ts create mode 100644 lib/pusher.ts diff --git a/.env b/.env index e7c7057..6380e6d 100644 --- a/.env +++ b/.env @@ -1,2 +1,2 @@ JUDGE_SUBMISSIONS_URL=http://localhost:2358/submissions -MONGO_URI_DOCKER=mongodb://localhost:27017/myappdb \ No newline at end of file +MONGO_URI_DOCKER=mongodb://localhost:27017/myappdb diff --git a/app/api/Class/[id]/route.ts b/app/api/Class/[id]/route.ts new file mode 100644 index 0000000..478554b --- /dev/null +++ b/app/api/Class/[id]/route.ts @@ -0,0 +1,43 @@ +import { NextRequest, NextResponse } from "next/server"; +import User from "../../../db/models/User"; +import Projects from "../../../db/models/project"; +import Class from "../../../db/models/Class"; +import mongoose from "mongoose"; +const uri = process.env.MONGO_URI_DOCKER || ''; + +export async function POST(request: NextRequest, {params}:{params:{_id: string}}) { + try { + await mongoose.connect(uri); + + const { _id } = params; + + let { students } = await request.json(); + + let classroom = await Class.findById({ _id }); + + for (let i = 0; i < students.length; i++) { + + classroom.student.push(students[i]); + await classroom.save(); + } + NextResponse.json(classroom); + } + catch (error) { + NextResponse.json(error); + } +} + +export async function GET(request: NextRequest, {params}:{params:{_id: string}}) { + try { + + await mongoose.connect(uri); + + const { _id } = params; + let classroom = await Class.findById({ _id }); + NextResponse.json(classroom); + } + catch (error) { + NextResponse.json(error); + } + +} \ No newline at end of file diff --git a/app/api/Class/route.ts b/app/api/Class/route.ts new file mode 100644 index 0000000..e8665e5 --- /dev/null +++ b/app/api/Class/route.ts @@ -0,0 +1,50 @@ +import { NextRequest, NextResponse } from "next/server"; +import User from "../../db/models/User"; +import Projects from "../../db/models/project"; +import Class from "../../db/models/Class"; +import mongoose from "mongoose"; +const uri = process.env.MONGO_URI_DOCKER || ''; + + + + +export async function POST(request: Request) { + try { + await mongoose.connect(uri); + let { name, teacherId } = await request.json(); + + // Input validation + if (!name || !teacherId) { + return NextResponse.json({ error: "Name and teacherId are required" }); + } + + let teacher = await User.findById({_id: teacherId}); + + // Check if teacher exists + if (!teacher) { + return NextResponse.json({ error: "Teacher not found" }); + } + + // Check if user is a teacher (optional) + if (teacher.role !== 'Teacher') { + return NextResponse.json({ error: "Specified user is not a teacher" }); + } + + let newClass = await Class.create({ + name: name, + teacher: teacher, + students: [] + }); + + // Optional: You might also want to add this class to the teacher's classesTeaching array + teacher.classesTeaching.push(newClass._id); + await teacher.save(); + + return NextResponse.json(newClass); + } + catch (error) { + // Log the error for debugging purposes + console.error(error); + return NextResponse.json({ error: "An error occurred while creating the class" }); + } +} diff --git a/app/api/User/[id]/route.ts b/app/api/User/[id]/route.ts new file mode 100644 index 0000000..77774fe --- /dev/null +++ b/app/api/User/[id]/route.ts @@ -0,0 +1,43 @@ +import { NextResponse } from "next/server"; +import User from "@/app/db/models/User"; +import mongoose from "mongoose"; +const uri = process.env.MONGO_URI_DOCKER || ''; + +mongoose.connect(uri); + + +export async function GET(request: Request, { params }: { params: { id: string } }) { + const { id } = params; + try { + const user = await User.findById(id); + return NextResponse.json(user); + } catch (error) { + return NextResponse.error(); + } +} + +export async function PUT(request: Request, { params }: { params: { id: string } }) { + const { id } = params; + try { + const userData = await request.json(); // Get the updated user data from the request body + const user = await User.findByIdAndUpdate(id, userData, { new: true }); // Update the user + if (!user) throw new Error('User not found'); // Handle user not found + return NextResponse.json(user); // Return the updated user + } catch (error) { + console.error(error); // Log the error for debugging + return NextResponse.error(); // Return a generic error response + } +} + + +export async function DELETE(request: Request, { params }: { params: { id: string } }) { + const { id } = params; + try { + const user = await User.findByIdAndRemove(id); // Remove the user + if (!user) throw new Error('User not found'); // Handle user not found + return NextResponse.json({ message: 'User successfully deleted', userId: id }); // Return success message + } catch (error) { + console.error(error); // Log the error for debugging + return NextResponse.error(); // Return a generic error response + } +} \ No newline at end of file diff --git a/app/api/User/route.ts b/app/api/User/route.ts index 920858c..e568318 100644 --- a/app/api/User/route.ts +++ b/app/api/User/route.ts @@ -10,10 +10,15 @@ const uri = process.env.MONGO_URI_DOCKER || ''; // Establish an initial connection to MongoDB mongoose.connect(uri); -// Handle GET requests +//GET request to get all Users export async function GET(request: Request) { - // Return a success response - return NextResponse.json("success"); + try { + await mongoose.connect(uri); + let allUsers = await User.find({}); + return NextResponse.json(allUsers); + } catch (err) { + return NextResponse.json(err); + } } // Handle POST requests diff --git a/app/api/message/route.ts b/app/api/message/route.ts new file mode 100644 index 0000000..36b25cc --- /dev/null +++ b/app/api/message/route.ts @@ -0,0 +1,9 @@ +import { pusherServer } from '@/lib/pusher' +import { NextResponse } from "next/server"; +export async function POST(req: Request) { + const { text } = await req.json() + + let trigger = pusherServer.trigger("my-channel", 'incoming-message', text) + + return NextResponse.json(text); +} \ No newline at end of file diff --git a/app/api/pusher-auth/route.ts b/app/api/pusher-auth/route.ts new file mode 100644 index 0000000..4de4b45 --- /dev/null +++ b/app/api/pusher-auth/route.ts @@ -0,0 +1,26 @@ +// Currently not in use but keepin for future versions + +import { pusherServer } from '@/lib/pusher' +import { nanoid } from 'nanoid' + +export async function POST(req: Request) { + const data = await req.text() + const [socketId, channelName] = data + .split('&') + .map((str) => str.split('=')[1]) + + const id = nanoid() + + const presenceData = { + user_id: id, + user_data: { user_id: id }, + } + + const auth = pusherServer.authorizeChannel( + socketId, + channelName, + presenceData + ) + + return new Response(JSON.stringify(auth)) +} \ No newline at end of file diff --git a/app/db/models/Class.ts b/app/db/models/Class.ts new file mode 100644 index 0000000..238637b --- /dev/null +++ b/app/db/models/Class.ts @@ -0,0 +1,26 @@ +import mongoose from "mongoose"; + + +// Define a schema for a Class +const classSchema = new mongoose.Schema({ + // Define a field 'name' of type String for the class's name + name: { + type: String, + required: true, + }, + // Define a field 'teacher' that will store ObjectId of the User model (who is a teacher) + teacher: { + type: mongoose.Schema.Types.ObjectId, + ref: 'User', + required: true, + }, + // For classes, a list of students enrolled in them. This list will store ObjectIds of the User model + students: [{ + type: mongoose.Schema.Types.ObjectId, + ref: 'User', + }], + // Optional: Any other information relevant to the class +}); + +// Export the Class model. If it already exists, use that; otherwise, create a new model using the classSchema +export default mongoose.models.Class || mongoose.model('Class', classSchema); diff --git a/app/db/models/User.ts b/app/db/models/User.ts index 09ff044..c02c25e 100644 --- a/app/db/models/User.ts +++ b/app/db/models/User.ts @@ -1,6 +1,5 @@ // Import the mongoose library to be used for database modeling import mongoose from "mongoose"; - // Define a schema for a User const userSchema = new mongoose.Schema({ // Define a field 'username' of type String which is required and unique for each user @@ -20,7 +19,7 @@ const userSchema = new mongoose.Schema({ role: { type: String, enum: ['Student', 'Teacher', 'Regular User'], - default: 'student' + default: 'Student' }, // For students, a list of teachers they are associated with. This list will store ObjectIds of the User model teachers: [{ @@ -32,6 +31,16 @@ const userSchema = new mongoose.Schema({ type: mongoose.Schema.Types.ObjectId, ref: 'User', }], + // For teachers, a list of classes they teach + classesTeaching: [{ + type: mongoose.Schema.Types.ObjectId, + ref: 'Class', + }], + // For students, a list of classes they are enrolled in + classesEnrolled: [{ + type: mongoose.Schema.Types.ObjectId, + ref: 'Class', + }], // Define a field 'createdAt' of type Date which will have a default value of the current date and time createdAt: { type: Date, @@ -41,7 +50,8 @@ const userSchema = new mongoose.Schema({ type: mongoose.Schema.Types.ObjectId, ref: 'Project' }] - + + }); // Export the User model. If the User model already exists, then use that, otherwise create a new model using the userSchema diff --git a/app/db/models/project.ts b/app/db/models/project.ts index 3c6dc5e..b87f802 100644 --- a/app/db/models/project.ts +++ b/app/db/models/project.ts @@ -36,9 +36,23 @@ const projectSchema = new mongoose.Schema({ }, assignedBy: { type: String - } + }, + // Define a list 'collaborators' to store ObjectIds of the User model who have access to the project + collaborators: [{ + type: mongoose.Schema.Types.ObjectId, + ref: 'User', + }], + // Define a field 'currentWriter' to store the ObjectId of the User model who currently has write access + currentWriter: { + type: mongoose.Schema.Types.ObjectId, + ref: 'User', + }, + // Optional: Timestamps for when the project was created and last updated +}, + { timestamps: true } +); -}); + // Export the Project model. If the Project model already exists, then use that, otherwise create a new model using the projectSchema export default mongoose.models.Project || mongoose.model('Project', projectSchema); diff --git a/app/layout.tsx b/app/layout.tsx index cb78bbb..fa151ad 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -10,7 +10,9 @@ export const metadata = { export default function RootLayout({ children }) { return ( - + + {/* */} +
{children} diff --git a/app/page.tsx b/app/page.tsx index 65f54e3..a27b397 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1,21 +1,56 @@ +"use client" import Link from "next/link"; +import PusherServer from "pusher-js" +import { pusherClient } from '@/lib/pusher'; +import React, { useState, useEffect } from "react"; +import axios from "axios"; const DemoPage = () => { - return ( -
-
-

Welcome to CodeCrewLabs

-

- CodeCrewLabs is an interactive e-learning environment with a codepen-like web playground. - You can create projects in multiple programming languages, practice coding, and more! -

- - - -
-
- ); + // const pusher = new Pusher({ + // appId: "1677536", + // key: "f2e9097c92705d394593", + // secret: "b18814e8f0a3a3c46b18", + // cluster: "us2", + // useTLS: true + // }); + const [incommingMessages, setIncommingMessages] = useState(''); + useEffect(() => { + pusherClient.subscribe("my-channel"); + + // console.log("Connected to Pusher"); + pusherClient.bind('incoming-message', (text: string) => { + setIncommingMessages(text); + }) + + // return () => { + // pusherClient.unsubscribe("my-channel"); + // } + }, []) + + const sendMessage = async (message: string) => { + let response = await axios.post("/api/message", { text: message }); + console.log(response.data); + + } + return ( +
+
+

Welcome to CodeCrewLabs

+

+ CodeCrewLabs is an interactive e-learning environment with a codepen-like web playground. + You can create projects in multiple programming languages, practice coding, and more! +

+ + + + +

{incommingMessages}

+
+
+ ); }; export default DemoPage; diff --git a/lib/pusher.ts b/lib/pusher.ts new file mode 100644 index 0000000..5a38c2f --- /dev/null +++ b/lib/pusher.ts @@ -0,0 +1,23 @@ +import PusherServer from 'pusher' +import PusherClient from 'pusher-js' + +export const pusherServer = new PusherServer({ + appId: "1677536", + key: "f2e9097c92705d394593", + secret: "b18814e8f0a3a3c46b18", + cluster: "us2", + useTLS: true +}); + + +/** + * The following pusher client uses auth, not neccessary for the video chatroom example + * Only the cluster would be important for that + * These values can be found after creating a pusher app under + * @see https://dashboard.pusher.com/apps/1677536/keys + */ + +export const pusherClient = new PusherClient(process.env.NEXT_PUBLIC_PUSHER_APP_KEY!, { + cluster: 'us2' + +}) \ No newline at end of file diff --git a/middleware.ts b/middleware.ts index 11e4ecb..32f7b02 100644 --- a/middleware.ts +++ b/middleware.ts @@ -4,9 +4,9 @@ import { authMiddleware } from "@clerk/nextjs"; // Please edit this to allow other routes to be public as needed. // See https://clerk.com/docs/nextjs/middleware for more information about configuring your middleware export default authMiddleware({ - publicRoutes : ["/", "/demo", "/sign-up", "/profile", "/api/User", "/api/teacher", "/api/User/projects/(.*)","/api/teacher/student","/api/teacher/student/(.*)","/api/teacher/(.*)"] + publicRoutes : ["/", "/demo", "/sign-up", "/profile", "/api/User", "/api/teacher", "/api/User/projects/(.*)","/api/teacher/student","/api/teacher/student/(.*)","/api/teacher/(.*)","/api/pusher","/api/message"] }); export const config = { - matcher: ["/((?!.*\\..*|_next).*)", "/", "/(api|trpc)/(.*)", "/api/User", "/api/User/projects/(.*)","/api/teacher/student", "/api/teacher/student/(.*)", "/api/teacher/(.*)"], + matcher: ["/((?!.*\\..*|_next).*)", "/", "/(api|trpc)/(.*)", "/api/User", "/api/User/projects/(.*)","/api/teacher/student", "/api/teacher/student/(.*)", "/api/teacher/(.*)","/api/pusher","/api/message"], }; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index f3c425c..ccaa750 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,9 +23,12 @@ "install": "^0.13.0", "monaco-editor": "^0.38.0", "mongoose": "^7.4.3", + "nanoid": "^5.0.1", "next": "13.4.10", "openai": "^3.3.0", "openai-edge": "^1.2.2", + "pusher": "^5.1.3", + "pusher-js": "^8.3.0", "react": "18.2.0", "react-dom": "18.2.0", "react-icons": "^4.10.1", @@ -1146,6 +1149,17 @@ "integrity": "sha512-7OjdcV8vQ74eiz1TZLzZP4JwqM5fA94K6yntPS5Z25r9HDuGNzaGdgvwKYq6S+MxwF0TFRwe50fIR/MYnakdkQ==", "peer": true }, + "node_modules/abort-controller": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", + "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", + "dependencies": { + "event-target-shim": "^5.0.0" + }, + "engines": { + "node": ">=6.5" + } + }, "node_modules/acorn": { "version": "8.10.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz", @@ -1195,6 +1209,23 @@ } } }, + "node_modules/ai/node_modules/nanoid": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz", + "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, "node_modules/ansi-styles": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", @@ -1838,6 +1869,14 @@ "@types/estree": "^1.0.0" } }, + "node_modules/event-target-shim": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", + "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", + "engines": { + "node": ">=6" + } + }, "node_modules/eventsource-parser": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/eventsource-parser/-/eventsource-parser-1.0.0.tgz", @@ -2166,6 +2205,15 @@ "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==" }, + "node_modules/is-base64": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-base64/-/is-base64-1.1.0.tgz", + "integrity": "sha512-Nlhg7Z2dVC4/PTvIFkgVVNvPHSO2eR/Yd0XzhGiXCXEvWnptXlXa/clQ8aePPiMuxEGcWfzWbGw2Fe3d+Y3v1g==", + "bin": { + "is_base64": "bin/is-base64", + "is-base64": "bin/is-base64" + } + }, "node_modules/is-binary-path": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", @@ -3042,9 +3090,9 @@ } }, "node_modules/nanoid": { - "version": "3.3.6", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz", - "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==", + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-5.0.1.tgz", + "integrity": "sha512-vWeVtV5Cw68aML/QaZvqN/3QQXc6fBfIieAlu05m7FZW2Dgb+3f0xc0TTxuJW+7u30t7iSDTV/j3kVI0oJqIfQ==", "funding": [ { "type": "github", @@ -3052,10 +3100,10 @@ } ], "bin": { - "nanoid": "bin/nanoid.cjs" + "nanoid": "bin/nanoid.js" }, "engines": { - "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + "node": "^18 || >=20" } }, "node_modules/next": { @@ -3108,6 +3156,23 @@ } } }, + "node_modules/next/node_modules/nanoid": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz", + "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, "node_modules/next/node_modules/postcss": { "version": "8.4.14", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.14.tgz", @@ -3484,6 +3549,23 @@ "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz", "integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==" }, + "node_modules/postcss/node_modules/nanoid": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz", + "integrity": "sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, "node_modules/prop-types": { "version": "15.8.1", "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", @@ -3516,6 +3598,30 @@ "node": ">=6" } }, + "node_modules/pusher": { + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/pusher/-/pusher-5.1.3.tgz", + "integrity": "sha512-Bmy5guFxQsbYSFLF3CM7GA2qE1zDJYn51PnNme9QlSjGguvkqUg4nj31PbgiLVDFK2sJvxPfx4JrB2HLgM3kaw==", + "dependencies": { + "@types/node-fetch": "^2.5.7", + "abort-controller": "^3.0.0", + "is-base64": "^1.1.0", + "node-fetch": "^2.6.1", + "tweetnacl": "^1.0.0", + "tweetnacl-util": "^0.15.0" + }, + "engines": { + "node": ">= 4.0.0" + } + }, + "node_modules/pusher-js": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/pusher-js/-/pusher-js-8.3.0.tgz", + "integrity": "sha512-6GohP06WlVeomAQQe9qWh1IDzd3+InluWt+ZUOcecVK1SEQkg6a8uYVsvxSJm7cbccfmHhE0jDkmhKIhue8vmA==", + "dependencies": { + "tweetnacl": "^1.0.3" + } + }, "node_modules/pvtsutils": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/pvtsutils/-/pvtsutils-1.3.5.tgz", @@ -4254,6 +4360,16 @@ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" }, + "node_modules/tweetnacl": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz", + "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==" + }, + "node_modules/tweetnacl-util": { + "version": "0.15.1", + "resolved": "https://registry.npmjs.org/tweetnacl-util/-/tweetnacl-util-0.15.1.tgz", + "integrity": "sha512-RKJBIj8lySrShN4w6i/BonWp2Z/uxwC3h4y7xsRrpP59ZboCd0GpEVsOnMDYLMmKBpYhb5TgHzZXy7wTfYFBRw==" + }, "node_modules/type-fest": { "version": "2.19.0", "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-2.19.0.tgz", diff --git a/package.json b/package.json index 44e1dcd..5ce4b89 100644 --- a/package.json +++ b/package.json @@ -24,9 +24,12 @@ "install": "^0.13.0", "monaco-editor": "^0.38.0", "mongoose": "^7.4.3", + "nanoid": "^5.0.1", "next": "13.4.10", "openai": "^3.3.0", "openai-edge": "^1.2.2", + "pusher": "^5.1.3", + "pusher-js": "^8.3.0", "react": "18.2.0", "react-dom": "18.2.0", "react-icons": "^4.10.1", From 20184813febc591410eccb701775bae75c6e0582 Mon Sep 17 00:00:00 2001 From: Jared E Plummer <113934345+JaredPlummer5@users.noreply.github.com> Date: Thu, 28 Sep 2023 15:02:44 -0500 Subject: [PATCH 02/12] Recommit --- app/api/message/route.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/api/message/route.ts b/app/api/message/route.ts index 36b25cc..6c2a85b 100644 --- a/app/api/message/route.ts +++ b/app/api/message/route.ts @@ -6,4 +6,5 @@ export async function POST(req: Request) { let trigger = pusherServer.trigger("my-channel", 'incoming-message', text) return NextResponse.json(text); -} \ No newline at end of file +} + From fd1feae240977a15c18a76b6d018c886101ec3a5 Mon Sep 17 00:00:00 2001 From: Jared E Plummer <113934345+JaredPlummer5@users.noreply.github.com> Date: Thu, 28 Sep 2023 15:26:05 -0500 Subject: [PATCH 03/12] Fixing Particles --- app/ParticlesContainer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/ParticlesContainer.tsx b/app/ParticlesContainer.tsx index 32b47d7..748958d 100644 --- a/app/ParticlesContainer.tsx +++ b/app/ParticlesContainer.tsx @@ -1,5 +1,5 @@ import React, { Component } from "react"; -import Particles from "react-particles"; +import Particles from "react-tsparticles"; import type { Engine } from "tsparticles-engine"; import { loadFirePreset } from "tsparticles-preset-fire"; From 46a191eb49c832c39c1601de45efe994b4f58cab Mon Sep 17 00:00:00 2001 From: Jared E Plummer <113934345+JaredPlummer5@users.noreply.github.com> Date: Mon, 2 Oct 2023 09:41:23 -0500 Subject: [PATCH 04/12] Revert "Fixing Particles" This reverts commit fd1feae240977a15c18a76b6d018c886101ec3a5. --- app/ParticlesContainer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/ParticlesContainer.tsx b/app/ParticlesContainer.tsx index 748958d..32b47d7 100644 --- a/app/ParticlesContainer.tsx +++ b/app/ParticlesContainer.tsx @@ -1,5 +1,5 @@ import React, { Component } from "react"; -import Particles from "react-tsparticles"; +import Particles from "react-particles"; import type { Engine } from "tsparticles-engine"; import { loadFirePreset } from "tsparticles-preset-fire"; From 27fa3f51aaa5cf0c0ae16e40993fc3201327fd64 Mon Sep 17 00:00:00 2001 From: Jared E Plummer <113934345+JaredPlummer5@users.noreply.github.com> Date: Mon, 2 Oct 2023 09:43:19 -0500 Subject: [PATCH 05/12] Revert "Revert "Fixing Particles"" This reverts commit 46a191eb49c832c39c1601de45efe994b4f58cab. --- app/ParticlesContainer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/ParticlesContainer.tsx b/app/ParticlesContainer.tsx index 32b47d7..748958d 100644 --- a/app/ParticlesContainer.tsx +++ b/app/ParticlesContainer.tsx @@ -1,5 +1,5 @@ import React, { Component } from "react"; -import Particles from "react-particles"; +import Particles from "react-tsparticles"; import type { Engine } from "tsparticles-engine"; import { loadFirePreset } from "tsparticles-preset-fire"; From 9c94281f3b41960a87fb151591b75fbe375a8cc9 Mon Sep 17 00:00:00 2001 From: Jared E Plummer <113934345+JaredPlummer5@users.noreply.github.com> Date: Mon, 2 Oct 2023 09:44:40 -0500 Subject: [PATCH 06/12] Revert "Revert "Revert "Fixing Particles""" This reverts commit 27fa3f51aaa5cf0c0ae16e40993fc3201327fd64. --- app/ParticlesContainer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/ParticlesContainer.tsx b/app/ParticlesContainer.tsx index 748958d..32b47d7 100644 --- a/app/ParticlesContainer.tsx +++ b/app/ParticlesContainer.tsx @@ -1,5 +1,5 @@ import React, { Component } from "react"; -import Particles from "react-tsparticles"; +import Particles from "react-particles"; import type { Engine } from "tsparticles-engine"; import { loadFirePreset } from "tsparticles-preset-fire"; From e4b7695be66ab85e406c643fb904c8e37055f22f Mon Sep 17 00:00:00 2001 From: Jared E Plummer <113934345+JaredPlummer5@users.noreply.github.com> Date: Mon, 2 Oct 2023 09:48:53 -0500 Subject: [PATCH 07/12] Revert "Merge branch 'main' into JaredsBranch" This reverts commit f5eab8188e10c5991767e5046b8143f62a0ce9f1, reversing changes made to 20184813febc591410eccb701775bae75c6e0582. --- app/ParticlesContainer.tsx | 36 --- app/components/Header.tsx | 30 +-- app/globals.css | 46 ---- app/layout.tsx | 7 +- app/page.tsx | 34 +-- package-lock.json | 463 +------------------------------------ package.json | 8 +- 7 files changed, 33 insertions(+), 591 deletions(-) delete mode 100644 app/ParticlesContainer.tsx diff --git a/app/ParticlesContainer.tsx b/app/ParticlesContainer.tsx deleted file mode 100644 index 32b47d7..0000000 --- a/app/ParticlesContainer.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import React, { Component } from "react"; -import Particles from "react-particles"; -import type { Engine } from "tsparticles-engine"; -import { loadFirePreset } from "tsparticles-preset-fire"; - -interface IProps { - // Define your props interface if needed -} - -class ParticlesContainer extends Component { - async customInit(engine: Engine): Promise { - // Load the "fire" preset for tsParticles - await loadFirePreset(engine); - } - - render() { - const options = { - preset: "fire", // Use the "fire" preset - particles: { - color: { - value: "#FFFFFF" - }, - links: { - color: "#FFFFFF" // Set the links (connections between particles) color to blue - } - }, - background: { - image: "radial-gradient(circle, #0081A7 , #111827)", // Radial gradient with calming blue - } - }; - - return ; - } -} - -export default ParticlesContainer; diff --git a/app/components/Header.tsx b/app/components/Header.tsx index 814e245..6ba3dcc 100644 --- a/app/components/Header.tsx +++ b/app/components/Header.tsx @@ -5,24 +5,24 @@ const Header = async ({}) => { const { userId } = auth(); return ( -