├── .gitignore
├── client
├── .eslintrc.cjs
├── README.md
├── index.html
├── package-lock.json
├── package.json
├── postcss.config.js
├── public
│ ├── logos
│ │ └── conversify-logo.png
│ └── vite.svg
├── src
│ ├── App.tsx
│ ├── assets
│ │ ├── react.svg
│ │ └── sounds
│ │ │ └── notification.mp3
│ ├── components
│ │ ├── LoginForm.tsx
│ │ ├── MessageScreen.tsx
│ │ ├── SignupForm.tsx
│ │ ├── UserCard.tsx
│ │ ├── UserChat.tsx
│ │ ├── UserMessges.tsx
│ │ └── ui
│ │ │ ├── Dropdown.tsx
│ │ │ ├── InputField.tsx
│ │ │ ├── LandingButton.tsx
│ │ │ ├── LoginInputField.tsx
│ │ │ └── UsersDashboard.tsx
│ ├── context
│ │ ├── AuthContext.tsx
│ │ ├── ConversationContext.tsx
│ │ ├── MessagesContext.tsx
│ │ ├── SocketContext.tsx
│ │ └── UsersContext.tsx
│ ├── hooks
│ │ ├── useGetConversations.ts
│ │ ├── useGetmessages.ts
│ │ ├── useListenMessages.ts
│ │ ├── useLogin.ts
│ │ ├── useLogout.ts
│ │ ├── useSendMessage.ts
│ │ └── useSignup.ts
│ ├── index.css
│ ├── main.tsx
│ ├── pages
│ │ ├── ChatPage.tsx
│ │ ├── HomePage.tsx
│ │ ├── LoginPage.tsx
│ │ └── SignupPage.tsx
│ ├── utils
│ │ └── calculateTime.ts
│ └── vite-env.d.ts
├── tailwind.config.js
├── tsconfig.json
├── tsconfig.node.json
└── vite.config.ts
├── package-lock.json
├── package.json
└── server
├── index.js
├── middleware
└── protectedRoutes.js
├── prisma
└── schema.prisma
├── routes
├── auth
│ └── index.js
├── messages
│ └── index.js
└── user
│ └── index.js
├── schema
└── index.js
├── socket
└── socket.js
└── utils
└── generateToken.js
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 | pnpm-debug.log*
8 | lerna-debug.log*
9 |
10 | node_modules
11 | dist
12 | dist-ssr
13 | *.local
14 | *.env
15 | .env*.local
16 | server/.env
17 | client/.env
18 |
19 | # Editor directories and files
20 | .vscode/*
21 | !.vscode/extensions.json
22 | .idea
23 | .DS_Store
24 | *.suo
25 | *.ntvs*
26 | *.njsproj
27 | *.sln
28 | *.sw?
29 |
--------------------------------------------------------------------------------
/client/.eslintrc.cjs:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | root: true,
3 | env: { browser: true, es2020: true },
4 | extends: [
5 | 'eslint:recommended',
6 | 'plugin:@typescript-eslint/recommended',
7 | 'plugin:react-hooks/recommended',
8 | ],
9 | ignorePatterns: ['dist', '.eslintrc.cjs'],
10 | parser: '@typescript-eslint/parser',
11 | plugins: ['react-refresh'],
12 | rules: {
13 | 'react-refresh/only-export-components': [
14 | 'warn',
15 | { allowConstantExport: true },
16 | ],
17 | },
18 | }
19 |
--------------------------------------------------------------------------------
/client/README.md:
--------------------------------------------------------------------------------
1 | # React + TypeScript + Vite
2 |
3 | This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
4 |
5 | Currently, two official plugins are available:
6 |
7 | - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
8 | - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
9 |
10 | ## Expanding the ESLint configuration
11 |
12 | If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:
13 |
14 | - Configure the top-level `parserOptions` property like this:
15 |
16 | ```js
17 | export default {
18 | // other rules...
19 | parserOptions: {
20 | ecmaVersion: 'latest',
21 | sourceType: 'module',
22 | project: ['./tsconfig.json', './tsconfig.node.json'],
23 | tsconfigRootDir: __dirname,
24 | },
25 | }
26 | ```
27 |
28 | - Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
29 | - Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
30 | - Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list
31 |
--------------------------------------------------------------------------------
/client/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Vondroy
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/client/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "client",
3 | "private": true,
4 | "version": "0.0.0",
5 | "type": "module",
6 | "scripts": {
7 | "dev": "vite",
8 | "build": "tsc && vite build",
9 | "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
10 | "preview": "vite preview"
11 | },
12 | "dependencies": {
13 | "lucide-react": "^0.335.0",
14 | "react": "^18.2.0",
15 | "react-dom": "^18.2.0",
16 | "react-hot-toast": "^2.4.1",
17 | "react-router-dom": "^6.22.0",
18 | "server": "file:..",
19 | "socket.io-client": "^4.7.4",
20 | "zod": "^3.22.4"
21 | },
22 | "devDependencies": {
23 | "@types/react": "^18.2.43",
24 | "@types/react-dom": "^18.2.17",
25 | "@typescript-eslint/eslint-plugin": "^6.14.0",
26 | "@typescript-eslint/parser": "^6.14.0",
27 | "@vitejs/plugin-react": "^4.2.1",
28 | "autoprefixer": "^10.4.17",
29 | "eslint": "^8.55.0",
30 | "eslint-plugin-react-hooks": "^4.6.0",
31 | "eslint-plugin-react-refresh": "^0.4.5",
32 | "postcss": "^8.4.35",
33 | "tailwindcss": "^3.4.1",
34 | "typescript": "^5.2.2",
35 | "vite": "^5.0.8"
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/client/postcss.config.js:
--------------------------------------------------------------------------------
1 | export default {
2 | plugins: {
3 | tailwindcss: {},
4 | autoprefixer: {},
5 | },
6 | }
7 |
--------------------------------------------------------------------------------
/client/public/logos/conversify-logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SwetanshuSingh/vondroy/2e98909f9edbdda88dbe52243bf76a98487bcc52/client/public/logos/conversify-logo.png
--------------------------------------------------------------------------------
/client/public/vite.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/client/src/App.tsx:
--------------------------------------------------------------------------------
1 | import { BrowserRouter, Navigate, Route, Routes } from "react-router-dom";
2 | import LoginPage from "./pages/LoginPage";
3 | import SignupPage from "./pages/SignupPage";
4 | import HomePage from "./pages/HomePage";
5 | import ChatPage from "./pages/ChatPage";
6 | import { Toaster } from "react-hot-toast";
7 | import { useContext } from "react";
8 | import { AuthContext, AuthContextType } from "./context/AuthContext";
9 |
10 | const App = (): React.JSX.Element => {
11 |
12 | const { auth } = useContext(AuthContext)!;
13 |
14 | return (
15 |
16 |
17 |
18 | } />
19 | : } />
20 | : } />
21 | : } />
22 |
23 |
24 | );
25 | };
26 |
27 | export default App;
--------------------------------------------------------------------------------
/client/src/assets/react.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/client/src/assets/sounds/notification.mp3:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SwetanshuSingh/vondroy/2e98909f9edbdda88dbe52243bf76a98487bcc52/client/src/assets/sounds/notification.mp3
--------------------------------------------------------------------------------
/client/src/components/LoginForm.tsx:
--------------------------------------------------------------------------------
1 | import { FormEvent, useState } from "react";
2 | import LoginInputField from "./ui/LoginInputField";
3 | import useLogin from "../hooks/useLogin";
4 | import { Loader2 } from "lucide-react";
5 |
6 | interface FormData {
7 | [key : string] : string
8 | }
9 |
10 | type Event = FormEvent | React.MouseEvent
11 |
12 | const LoginForm = () : React.JSX.Element => {
13 |
14 | const [formData, setFormData] = useState({username : '', email : '', password : ''});
15 |
16 | const {loading, login} = useLogin();
17 |
18 | const handleSubmit = async (evt : Event) => {
19 | evt.preventDefault();
20 | await login(formData);
21 | }
22 |
23 | return (
24 |
33 | )
34 | }
35 |
36 | export default LoginForm;
--------------------------------------------------------------------------------
/client/src/components/MessageScreen.tsx:
--------------------------------------------------------------------------------
1 | import { MutableRefObject, useContext, useEffect, useRef } from "react";
2 | import useGetMessages from "../hooks/useGetmessages";
3 | import { AuthContext, AuthContextType } from "../context/AuthContext";
4 | import { ConversationContext, ConversationContextType } from "../context/ConversationContext";
5 | import useListenMessages from "../hooks/useListenMessages";
6 | import { Loader } from "lucide-react";
7 |
8 | const MessageScreen = (): React.JSX.Element => {
9 |
10 | const { loading, messages } = useGetMessages();
11 | useListenMessages();
12 | const { auth } = useContext(AuthContext)!;
13 | const { selectedConversation } = useContext(ConversationContext)!;
14 | const lastMessageRef : MutableRefObject = useRef(null);
15 |
16 | useEffect(() => {
17 | setTimeout(() => {
18 | lastMessageRef.current?.scrollIntoView({behavior : "smooth"})
19 | }, 100);
20 | }, [messages])
21 |
22 | return (
23 |
24 | {!loading &&
25 | messages != undefined &&
26 | messages?.length > 0
27 | && messages?.map((message) => {
28 | const fromMe = auth?.id === message.senderId
29 | const chatClassname = fromMe ? 'flex-row-reverse' : 'flex-row';
30 | const borderClassname = fromMe ? 'rounded-l-md rounded-br-md' : 'rounded-r-md rounded-bl-md';
31 | const profilePic = fromMe ? auth.profile : selectedConversation?.profilePic;
32 |
33 | return (
34 |
35 |

40 |
41 | {message.body}
42 |
43 |
44 | );
45 | })}
46 |
47 | {loading &&
}
48 | {!loading && (messages?.length == 0 || messages == undefined) && (
49 |
Send a message to start conversation
50 | )}
51 |
52 | );
53 | };
54 |
55 | export default MessageScreen;
56 |
--------------------------------------------------------------------------------
/client/src/components/SignupForm.tsx:
--------------------------------------------------------------------------------
1 | import { FormEvent, useState } from "react";
2 | import InputField from "./ui/InputField";
3 | import Dropdown from "./ui/Dropdown";
4 | import useSignup from "../hooks/useSignup";
5 | import { Loader2 } from "lucide-react";
6 | import { Link } from "react-router-dom";
7 |
8 | interface FormData {
9 | [key : string] : string
10 | }
11 |
12 | type Event = FormEvent | React.MouseEvent
13 |
14 | const SignupForm = () : React.JSX.Element => {
15 |
16 | const [formData, setFormData] = useState({firstname : '', lastname : '', username : '', email : '', password : '', gender : ''});
17 | const { loading , signup } = useSignup()
18 |
19 | const handleSubmit = async (evt : Event) => {
20 | evt.preventDefault()
21 | await signup(formData);
22 | }
23 |
24 | return(
25 |
49 | )
50 | }
51 |
52 | export default SignupForm;
--------------------------------------------------------------------------------
/client/src/components/UserCard.tsx:
--------------------------------------------------------------------------------
1 | import { useContext } from "react";
2 | import { ConversationContext, ConversationContextType } from "../context/ConversationContext";
3 | import { useSocketContext } from "../context/SocketContext";
4 |
5 | type UserDetailsProps = {
6 | userDetails : {
7 | email : string,
8 | firstname : string,
9 | lastname : string,
10 | id : string,
11 | profilePic : string,
12 | username : string
13 | }
14 | }
15 |
16 | const UserCard = ({ userDetails } : UserDetailsProps) : React.JSX.Element => {
17 |
18 | const {selectedConversation, setSelectedConversation} = useContext(ConversationContext)!;
19 | const isSelected = selectedConversation?.id === userDetails.id
20 | const { onlineUsers } = useSocketContext() as { onlineUsers : string[] };
21 | const isOnline = onlineUsers.includes(userDetails.id);
22 |
23 | return (
24 | {setSelectedConversation(userDetails)}} className={`${isSelected ? "bg-gray-200" : ""} p-2 w-72 font-0 flex border border-gray-500 rounded-lg justify-between cursor-default hover:bg-gray-200`}>
25 |
26 |
27 | {isOnline ? (
) : null}
28 |

29 |
30 |
31 |
{ userDetails.firstname }
32 |
33 |
34 |
35 | {/*
Just Now
*/}
36 |
37 |
38 | )
39 | }
40 | export default UserCard;
--------------------------------------------------------------------------------
/client/src/components/UserChat.tsx:
--------------------------------------------------------------------------------
1 | import { useContext } from "react";
2 | import { ConversationContext, ConversationContextType } from "../context/ConversationContext";
3 | import { AuthContext, AuthContextType } from "../context/AuthContext";
4 | import UserMessages from "./UserMessges";
5 | import { useSocketContext } from "../context/SocketContext";
6 |
7 | const UserChat = () => {
8 | const { selectedConversation } = useContext(ConversationContext)!;
9 | const { auth } = useContext(AuthContext)!;
10 | const { onlineUsers } = useSocketContext() as { onlineUsers : string[] };
11 | const isOnline = onlineUsers.includes(selectedConversation?.id ?? "");
12 |
13 | return (
14 |
15 | {selectedConversation ? (
16 | <>
17 |
18 |
19 |

24 |
25 |
26 |
{selectedConversation.firstname} {selectedConversation.lastname}
27 | {isOnline ? (
Online
) : null}
28 |
29 |
30 |
31 |
32 | >
33 | ) : (
34 |
35 |
Welcome {auth?.firstname} 👋
36 |
Select to chat to start messaging
37 |
38 | )}
39 |
40 | );
41 | };
42 |
43 | export default UserChat;
44 |
--------------------------------------------------------------------------------
/client/src/components/UserMessges.tsx:
--------------------------------------------------------------------------------
1 | import { ChangeEvent, FormEvent, MouseEvent, useState } from "react";
2 | import useSendMessage from "../hooks/useSendMessage";
3 | import MessageScreen from "./MessageScreen";
4 |
5 | const UserMessages = () : React.JSX.Element => {
6 |
7 | const [message, setUserMessage] = useState('');
8 | const {sendMessage} = useSendMessage();
9 |
10 | const handleChange = (evt : ChangeEvent) => {
11 | setUserMessage(evt.target.value)
12 | }
13 |
14 | const handleSubmit = async(evt : FormEvent | MouseEvent) => {
15 | evt.preventDefault();
16 | if(!message){
17 | return
18 | }
19 | await sendMessage(message)
20 | setUserMessage('');
21 | }
22 |
23 | return (
24 | <>
25 |
26 |
27 |
38 | >
39 | )
40 | }
41 |
42 | export default UserMessages;
--------------------------------------------------------------------------------
/client/src/components/ui/Dropdown.tsx:
--------------------------------------------------------------------------------
1 | import { ChangeEvent } from "react";
2 |
3 | interface FormData {
4 | [key : string] : string
5 | }
6 |
7 | interface DropdownProps {
8 | labelName : string,
9 | fieldName : string,
10 | formData : FormData,
11 | setFormData : React.Dispatch>
12 | }
13 |
14 | const Dropdown = ({ labelName, fieldName, formData, setFormData } : DropdownProps) : React.JSX.Element => {
15 |
16 | const handleChange = (evt : ChangeEvent) => {
17 | setFormData((prev : FormData) => {
18 | prev[evt.target.name] = evt.target.value;
19 | return { ...prev }
20 | })
21 | }
22 |
23 | return(
24 |
25 |
28 |
38 |
39 | )
40 | }
41 |
42 | export default Dropdown;
--------------------------------------------------------------------------------
/client/src/components/ui/InputField.tsx:
--------------------------------------------------------------------------------
1 | import { ChangeEvent } from "react";
2 |
3 | interface FormData {
4 | [key : string] : string
5 | }
6 |
7 | interface InputFieldProps {
8 | labelName : string,
9 | fieldName : string,
10 | formData : FormData,
11 | placeholderText : string,
12 | fieldType : string,
13 | setFormData : React.Dispatch>
14 | }
15 |
16 | const InputField = ({ labelName, fieldName, formData, placeholderText, fieldType, setFormData } : InputFieldProps): React.JSX.Element => {
17 |
18 | const handleChange = (evt : ChangeEvent) => {
19 | setFormData((prev : FormData) => {
20 | prev[evt.target.name] = evt.target.value;
21 | return { ...prev }
22 | })
23 | }
24 |
25 | return (
26 |
27 |
30 | {
35 | handleChange(evt);
36 | }}
37 | placeholder={placeholderText}
38 | className="w-full border border-gray-300 outline-none px-2 py-2 rounded-md shadow-sm font-light text-sm placeholder:text-sm placeholder:font-normal"
39 | />
40 |
41 | );
42 | };
43 |
44 | export default InputField;
--------------------------------------------------------------------------------
/client/src/components/ui/LandingButton.tsx:
--------------------------------------------------------------------------------
1 | interface LandingButtonProps {
2 | text : string
3 | }
4 |
5 | const LandingButton = ( { text } : LandingButtonProps) : React.JSX.Element => {
6 | return (
7 |
10 | );
11 | };
12 |
13 | export default LandingButton;
--------------------------------------------------------------------------------
/client/src/components/ui/LoginInputField.tsx:
--------------------------------------------------------------------------------
1 | import { ChangeEvent } from "react";
2 |
3 | interface FormData {
4 | [key : string] : string
5 | }
6 |
7 | interface LoginInputFieldProps {
8 | labelName : string,
9 | fieldName : string,
10 | formData : FormData,
11 | placeholderText : string,
12 | fieldType : string,
13 | setFormData : React.Dispatch>
14 | }
15 |
16 | const LoginInputField = ({ labelName, fieldName, formData, placeholderText, fieldType, setFormData } : LoginInputFieldProps): React.JSX.Element => {
17 |
18 | const handleChange = (evt : ChangeEvent) => {
19 | setFormData((prev : FormData) => {
20 | prev[evt.target.name] = evt.target.value;
21 | return { ...prev }
22 | })
23 | }
24 |
25 | return (
26 |
27 |
30 | {
35 | handleChange(evt);
36 | }}
37 | placeholder={placeholderText}
38 | className="w-full border border-gray-300 outline-none px-2 py-2 rounded-md shadow-sm font-light text-sm placeholder:text-sm placeholder:font-normal"
39 | />
40 |
41 | );
42 | };
43 |
44 | export default LoginInputField;
--------------------------------------------------------------------------------
/client/src/components/ui/UsersDashboard.tsx:
--------------------------------------------------------------------------------
1 | import { Loader2 } from "lucide-react";
2 | import useGetConversation from "../../hooks/useGetConversations";
3 | import UserCard from "../UserCard";
4 |
5 | const UsersDashboard = () : React.JSX.Element => {
6 |
7 | const {loading, users} = useGetConversation();
8 |
9 | return (
10 |
11 | Message
12 |
13 | {users && users.map((user) => {
14 | return
15 | })}
16 | {loading ?
: null}
17 |
18 |
19 | )
20 | }
21 |
22 | export default UsersDashboard;
--------------------------------------------------------------------------------
/client/src/context/AuthContext.tsx:
--------------------------------------------------------------------------------
1 | import { ReactNode, createContext, useContext, useState } from "react";
2 |
3 | type Auth = {
4 | email : string,
5 | firstname : string,
6 | id : string,
7 | lastname : string,
8 | profile : string,
9 | username : string
10 | }
11 |
12 | export type AuthContextType = {
13 | auth : Auth | null,
14 | setAuthUser : React.Dispatch>
15 | }
16 |
17 | type AuthContextProviderProps = {
18 | children : ReactNode
19 | }
20 |
21 | export const AuthContext = createContext(null);
22 |
23 | // eslint-disable-next-line react-refresh/only-export-components
24 | export const useAuthContext = () => {
25 | return useContext(AuthContext);
26 | }
27 |
28 | export const AuthContextProvider = ({ children } : AuthContextProviderProps) => {
29 | const [auth, setAuthUser] = useState(JSON.parse(localStorage.getItem("chat-user")!) || null)
30 |
31 | return
32 | { children }
33 |
34 | }
--------------------------------------------------------------------------------
/client/src/context/ConversationContext.tsx:
--------------------------------------------------------------------------------
1 | import { ReactNode, createContext, useState } from "react";
2 |
3 | type SelectedConversation = {
4 | email : string,
5 | firstname : string,
6 | lastname : string,
7 | id : string,
8 | profilePic : string,
9 | username : string
10 | }
11 |
12 | export type ConversationContextType = {
13 | selectedConversation : SelectedConversation | null,
14 | setSelectedConversation : React.Dispatch>
15 | }
16 |
17 | type ConversationContextProviderProps = {
18 | children : ReactNode
19 | }
20 |
21 | export const ConversationContext = createContext(null);
22 |
23 | export const ConversationContextProvider = ({ children } : ConversationContextProviderProps) => {
24 |
25 | const [selectedConversation, setSelectedConversation] = useState(null);
26 |
27 | return
28 | { children }
29 |
30 | }
--------------------------------------------------------------------------------
/client/src/context/MessagesContext.tsx:
--------------------------------------------------------------------------------
1 | import { ReactNode, createContext, useState } from "react";
2 |
3 | type Messages = {
4 | body : string,
5 | conversationId : Array,
6 | createdAt : string,
7 | senderId : string,
8 | messageId : string,
9 | receiverId : string
10 | }[]
11 |
12 | export type MessagesContextType = {
13 | messages : Messages | null,
14 | setMessages : React.Dispatch>
15 | }
16 |
17 | type MessagesContextProviderProps = {
18 | children : ReactNode
19 | }
20 |
21 | export const MessagesContext = createContext(null);
22 |
23 | export const MessagesContextProvider = ({ children } : MessagesContextProviderProps) => {
24 |
25 | const [messages, setMessages] = useState(null);
26 |
27 | return
28 | { children }
29 |
30 | }
--------------------------------------------------------------------------------
/client/src/context/SocketContext.tsx:
--------------------------------------------------------------------------------
1 | import { ReactNode, createContext, useContext, useEffect, useState } from "react";
2 | import { AuthContextType, useAuthContext } from "./AuthContext";
3 | import io, { Socket } from "socket.io-client";
4 |
5 | export type SocketContextType = {
6 | socket? : Socket;
7 | onlineUsers : string[]
8 | }
9 |
10 | type SocketContextProviderProps = {
11 | children : ReactNode
12 | }
13 |
14 | const SocketContext = createContext(undefined);
15 |
16 | // eslint-disable-next-line react-refresh/only-export-components
17 | export const useSocketContext = () : SocketContextType | undefined => {
18 | return useContext(SocketContext)
19 | }
20 |
21 | export const SocketContextProvider = ({children} : SocketContextProviderProps) => {
22 |
23 | const [socket, setSocket] = useState();
24 | const [onlineUsers, setOnlineUsers] = useState([]);
25 | const {auth} = useAuthContext() as AuthContextType;
26 |
27 | useEffect(() => {
28 | if(auth) {
29 | const socket = io("https://vondroy.onrender.com", {
30 | query : {
31 | userId : auth.id,
32 | }
33 | });
34 | setSocket(socket);
35 |
36 | socket.on("getOnlineUsers", (users) => {
37 | setOnlineUsers(users);
38 | })
39 |
40 | return () => {
41 | if(socket){
42 | socket.close();
43 | }
44 | };
45 | } else {
46 | if (socket) {
47 | socket.close();
48 | setSocket(undefined);
49 | }
50 | }
51 | },[auth])
52 |
53 | return
54 | {children}
55 |
56 | }
--------------------------------------------------------------------------------
/client/src/context/UsersContext.tsx:
--------------------------------------------------------------------------------
1 | import { ReactNode, createContext, useState } from "react";
2 |
3 | export type Users = {
4 | email : string,
5 | firstname : string,
6 | lastname : string,
7 | id : string,
8 | profilePic : string,
9 | username : string
10 | }[]
11 |
12 | export type UsersContextType = {
13 | users : Users | null,
14 | setUsers : React.Dispatch>
15 | }
16 |
17 | type UsersContextProviderProps = {
18 | children : ReactNode
19 | }
20 |
21 | export const UsersContext = createContext(null);
22 |
23 | export const UsersContextProvider = ({ children } : UsersContextProviderProps) => {
24 | const [users, setUsers] = useState(null);
25 |
26 | return
27 | { children }
28 |
29 | }
--------------------------------------------------------------------------------
/client/src/hooks/useGetConversations.ts:
--------------------------------------------------------------------------------
1 | import { useContext, useEffect, useState } from "react";
2 | import { UsersContext, UsersContextType } from "../context/UsersContext";
3 | import toast from "react-hot-toast";
4 |
5 | const useGetConversation = () => {
6 | const [loading, setIsLoading] = useState(false);
7 | const { users, setUsers } = useContext(UsersContext)!;
8 |
9 | useEffect(() => {
10 | const fetchConversation = async() => {
11 | setIsLoading(true)
12 |
13 | try {
14 | const response = await fetch("/api/users")
15 | const conversations = await response.json();
16 | setUsers(conversations.message);
17 | } catch (error) {
18 | toast.error("Internal Server Eroor")
19 | } finally{
20 | setIsLoading(false)
21 | }
22 | }
23 | fetchConversation();
24 | }, [])
25 | return { loading, users };
26 | }
27 |
28 | export default useGetConversation;
--------------------------------------------------------------------------------
/client/src/hooks/useGetmessages.ts:
--------------------------------------------------------------------------------
1 | import { useContext, useEffect, useState } from "react";
2 | import toast from "react-hot-toast";
3 | import { ConversationContext, ConversationContextType } from "../context/ConversationContext";
4 | import { MessagesContext, MessagesContextType } from "../context/MessagesContext";
5 |
6 | const useGetMessages = () => {
7 | const [loading, setIsLoading] = useState(false);
8 | const {selectedConversation} = useContext(ConversationContext)!;
9 | const {messages, setMessages} = useContext(MessagesContext)!;
10 |
11 | const getMessages = async() => {
12 | setIsLoading(true);
13 |
14 | try {
15 | const response = await fetch(`/api/messages/${selectedConversation?.id}`);
16 | const data = await response.json();
17 | setMessages(data.messages.messages);
18 |
19 | } catch (error) {
20 | return toast.error("Internal Server Error")
21 | } finally {
22 | setIsLoading(false)
23 | }
24 | }
25 |
26 | useEffect(() => {
27 | if(selectedConversation?.id){
28 | getMessages()
29 | }
30 | }, [selectedConversation?.id])
31 |
32 | return { loading, messages, setMessages }
33 | }
34 |
35 | export default useGetMessages;
--------------------------------------------------------------------------------
/client/src/hooks/useListenMessages.ts:
--------------------------------------------------------------------------------
1 | import { useContext, useEffect } from "react";
2 | import { SocketContextType, useSocketContext } from "../context/SocketContext";
3 | import { MessagesContext, MessagesContextType } from "../context/MessagesContext";
4 | import notificationSound from "../assets/sounds/notification.mp3"
5 |
6 | const useListenMessages = () => {
7 | const {socket} = useSocketContext() as SocketContextType;
8 | const { messages, setMessages } = useContext(MessagesContext) as MessagesContextType;
9 |
10 | useEffect(() => {
11 | socket?.on("newMessage", (newMessage) => {
12 | const sound = new Audio(notificationSound);
13 | sound.play();
14 | setMessages([...(messages ?? []), newMessage])
15 | })
16 |
17 | return () => {
18 | socket?.off("newMessage");
19 | }
20 | }, [socket,setMessages,messages])
21 | }
22 |
23 | export default useListenMessages;
--------------------------------------------------------------------------------
/client/src/hooks/useLogin.ts:
--------------------------------------------------------------------------------
1 | import { useContext, useState } from "react";
2 | import toast from "react-hot-toast";
3 | import zod from "zod";
4 | import { AuthContext, AuthContextType } from "../context/AuthContext";
5 |
6 | interface FormData {
7 | [key : string] : string
8 | }
9 |
10 | const userLoginSchema = zod.object({
11 | username: zod.string(),
12 | password: zod.string().min(6),
13 | email: zod.string().email(),
14 | })
15 |
16 | const useLogin = () => {
17 | const [loading, setIsLoading] = useState(false);
18 | const { setAuthUser } = useContext(AuthContext)!;
19 |
20 | const login = async (formData : FormData) => {
21 | const { success } = userLoginSchema.safeParse(formData);
22 | if(!success){
23 | return toast.error("Invalid Form Details");
24 | }
25 |
26 | setIsLoading(true);
27 |
28 | try {
29 | const response = await fetch("/api/auth/login", {
30 | method : "POST",
31 | headers : {"Content-Type" : "application/json"},
32 | body : JSON.stringify(formData)
33 | })
34 |
35 | const data = await response.json();
36 |
37 | if(response.status !== 200){
38 | return toast.error(data.message);
39 | }
40 |
41 | localStorage.setItem("chat-user", JSON.stringify(data.credentials))
42 | setAuthUser(data.credentials)
43 | return toast.success(data.message);
44 |
45 | } catch (error) {
46 | toast.error("Internal Server Error");
47 | } finally {
48 | setIsLoading(false);
49 | }
50 | }
51 |
52 | return { loading, login }
53 | }
54 |
55 | export default useLogin;
--------------------------------------------------------------------------------
/client/src/hooks/useLogout.ts:
--------------------------------------------------------------------------------
1 | import { useContext } from "react";
2 | import toast from "react-hot-toast";
3 | import { AuthContext, AuthContextType } from "../context/AuthContext";
4 |
5 | const useLogout = () => {
6 |
7 | const { setAuthUser } = useContext(AuthContext)!;
8 |
9 | const logout = async() => {
10 | try {
11 | const res = await fetch("/api/auth/logout",);
12 | const data = await res.json();
13 |
14 | if(data.error){
15 | return toast.error("Failed to Logout")
16 | }
17 |
18 | localStorage.removeItem("chat-user");
19 | setAuthUser(null);
20 | return toast.success(data.message);
21 |
22 | } catch (error) {
23 | toast.error("Internal Server Error")
24 | }
25 | }
26 |
27 | return logout;
28 | }
29 |
30 | export default useLogout;
--------------------------------------------------------------------------------
/client/src/hooks/useSendMessage.ts:
--------------------------------------------------------------------------------
1 | import { useContext, useState } from "react";
2 | import { MessagesContext, MessagesContextType } from "../context/MessagesContext";
3 | import toast from "react-hot-toast";
4 | import { ConversationContext, ConversationContextType } from "../context/ConversationContext";
5 |
6 | const useSendMessage = () => {
7 | const [loading, setIsLoading] = useState(false);
8 | const {setMessages} = useContext(MessagesContext)!;
9 | const { selectedConversation } = useContext(ConversationContext)!;
10 |
11 | const sendMessage = async(message : string) => {
12 | setIsLoading(true);
13 | try {
14 | const response = await fetch(`/api/messages/send/${selectedConversation?.id}`, {
15 | method : "POST",
16 | headers : {
17 | "Content-Type" : "application/json"
18 | },
19 | body : JSON.stringify({message : message})
20 | })
21 |
22 | const data = await response.json();
23 | if(data.error){
24 | return toast.error("Cannot send message")
25 | }
26 | setMessages(data.messages)
27 |
28 | } catch (error) {
29 | toast.error("Internal Server Error");
30 | } finally{
31 | setIsLoading(false);
32 | }
33 | }
34 | return {loading, sendMessage};
35 | }
36 |
37 | export default useSendMessage;
--------------------------------------------------------------------------------
/client/src/hooks/useSignup.ts:
--------------------------------------------------------------------------------
1 | import { useContext, useState } from "react";
2 | import zod from "zod"
3 | import toast from "react-hot-toast";
4 | import { AuthContext, AuthContextType } from "../context/AuthContext";
5 |
6 | interface FormData {
7 | [key : string] : string
8 | }
9 |
10 | const userSchema = zod.object({
11 | username: zod.string(),
12 | password: zod.string().min(6),
13 | email: zod.string().email(),
14 | firstname: zod.string(),
15 | lastname: zod.string(),
16 | gender : zod.string()
17 | });
18 |
19 | const useSignup = () => {
20 | const [loading, setIsLoading] = useState(false);
21 |
22 | const { setAuthUser } = useContext(AuthContext)!
23 |
24 | const signup = async (formData : FormData) => {
25 |
26 |
27 | const passwordLength = formData.password.length
28 | if(passwordLength < 6){
29 | return toast.error("Passwords should be atleast 6 characters long")
30 | }
31 |
32 | const { success } = userSchema.safeParse(formData);
33 | if(!success) {
34 | return toast.error("Invalid Form Details");
35 | }
36 |
37 | setIsLoading(true);
38 | try {
39 | const response = await fetch("/api/auth/signup", {
40 | method : "POST",
41 | headers : {
42 | "Content-Type" : "application/json"
43 | },
44 | body : JSON.stringify(formData)
45 | });
46 |
47 | const data = await response.json();
48 | if(response.status !== 200){
49 | return toast.error(data.message);
50 | }
51 |
52 | localStorage.setItem("chat-user", JSON.stringify(data.credentials));
53 | setAuthUser(data.credentials);
54 | return toast.success(data.message);
55 |
56 | } catch (error) {
57 | toast.error("Internal Server Error")
58 | } finally{
59 | setIsLoading(false);
60 | }
61 | }
62 |
63 | return { loading, signup }
64 | }
65 |
66 | export default useSignup;
--------------------------------------------------------------------------------
/client/src/index.css:
--------------------------------------------------------------------------------
1 | @import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap');
2 | @tailwind base;
3 | @tailwind components;
4 | @tailwind utilities;
5 |
6 | .users::-webkit-scrollbar{
7 | display: none;
8 | scrollbar-width: none;
9 | }
10 |
11 | .messages::-webkit-scrollbar{
12 | display: none;
13 | scrollbar-width: none;
14 | }
--------------------------------------------------------------------------------
/client/src/main.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react'
2 | import ReactDOM from 'react-dom/client'
3 | import App from './App.tsx'
4 | import './index.css'
5 | import { AuthContextProvider } from './context/AuthContext.tsx'
6 | import { UsersContextProvider } from './context/UsersContext.tsx'
7 | import { ConversationContextProvider } from './context/ConversationContext.tsx'
8 | import { MessagesContextProvider } from './context/MessagesContext.tsx'
9 | import { SocketContextProvider } from './context/SocketContext.tsx'
10 |
11 | ReactDOM.createRoot(document.getElementById('root')!).render(
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | ,
25 | )
26 |
--------------------------------------------------------------------------------
/client/src/pages/ChatPage.tsx:
--------------------------------------------------------------------------------
1 | import UserChat from "../components/UserChat";
2 | import UsersDashboard from "../components/ui/UsersDashboard";
3 |
4 | const ChatPage = () : React.JSX.Element => {
5 | return (
6 |
7 |
8 |
9 |
10 | )
11 | }
12 |
13 | export default ChatPage;
--------------------------------------------------------------------------------
/client/src/pages/HomePage.tsx:
--------------------------------------------------------------------------------
1 | import { Link } from "react-router-dom";
2 | import LandingButton from "../components/ui/LandingButton";
3 |
4 | const HomePage = (): React.JSX.Element => {
5 | return (
6 |
7 |
8 |

13 |
Vondroy
14 |
15 |
16 |
17 | The next-gen. realtime chat app created using React, TypeScript, Prisma,
18 | Socket.io and MongoDB.
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 | );
31 | };
32 |
33 | export default HomePage;
34 |
--------------------------------------------------------------------------------
/client/src/pages/LoginPage.tsx:
--------------------------------------------------------------------------------
1 | import { Link } from "react-router-dom";
2 | import LoginForm from "../components/LoginForm";
3 |
4 | const LoginPage = (): React.JSX.Element => {
5 | return (
6 |
7 |
8 |
9 |
10 |
11 |

12 |
Welcome Back
13 |
14 |
Glad to see you again 👋
15 |
Login to your account below
16 |
17 |
18 |
19 |
20 |
21 | Don't have an account? Signup
22 |
23 |
24 | )
25 | };
26 |
27 | export default LoginPage;
28 |
--------------------------------------------------------------------------------
/client/src/pages/SignupPage.tsx:
--------------------------------------------------------------------------------
1 | import { Link } from "react-router-dom";
2 | import SignupForm from "../components/SignupForm";
3 |
4 | const SignupPage = (): React.JSX.Element => {
5 | return (
6 |
7 |
8 |
9 |
10 |
11 |

12 |
Sign Up
13 |
Enter your details below to create your account and get started.
14 |
15 |
16 |
17 |
18 | Already have an account? Login
19 |
20 |
21 | )
22 | };
23 |
24 | export default SignupPage;
25 |
--------------------------------------------------------------------------------
/client/src/utils/calculateTime.ts:
--------------------------------------------------------------------------------
1 | // const time : number = 1;
--------------------------------------------------------------------------------
/client/src/vite-env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
--------------------------------------------------------------------------------
/client/tailwind.config.js:
--------------------------------------------------------------------------------
1 | /** @type {import('tailwindcss').Config} */
2 | export default {
3 | content: [
4 | "./index.html",
5 | "./src/**/*.{js,ts,jsx,tsx}",
6 | ],
7 | theme: {
8 | extend: {
9 | fontFamily : ["Poppins", "sans-serif"]
10 | },
11 | },
12 | plugins: [],
13 | }
--------------------------------------------------------------------------------
/client/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ES2020",
4 | "useDefineForClassFields": true,
5 | "lib": ["ES2020", "DOM", "DOM.Iterable"],
6 | "module": "ESNext",
7 | "skipLibCheck": true,
8 |
9 | /* Bundler mode */
10 | "moduleResolution": "bundler",
11 | "allowImportingTsExtensions": true,
12 | "resolveJsonModule": true,
13 | "isolatedModules": true,
14 | "noEmit": true,
15 | "jsx": "react-jsx",
16 |
17 | /* Linting */
18 | "strict": true,
19 | "noUnusedLocals": true,
20 | "noUnusedParameters": true,
21 | "noFallthroughCasesInSwitch": true
22 | },
23 | "include": ["src"],
24 | "references": [{ "path": "./tsconfig.node.json" }]
25 | }
26 |
--------------------------------------------------------------------------------
/client/tsconfig.node.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "composite": true,
4 | "skipLibCheck": true,
5 | "module": "ESNext",
6 | "moduleResolution": "bundler",
7 | "allowSyntheticDefaultImports": true
8 | },
9 | "include": ["vite.config.ts"]
10 | }
11 |
--------------------------------------------------------------------------------
/client/vite.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite'
2 | import react from '@vitejs/plugin-react'
3 |
4 | // https://vitejs.dev/config/
5 | export default defineConfig({
6 | plugins: [react()],
7 | server : {
8 | port : 3000,
9 | proxy : {
10 | "/api" : {
11 | target : "http://localhost:5000",
12 | }
13 | },
14 | }
15 | })
16 |
--------------------------------------------------------------------------------
/package-lock.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "server",
3 | "version": "1.0.0",
4 | "lockfileVersion": 3,
5 | "requires": true,
6 | "packages": {
7 | "": {
8 | "name": "server",
9 | "version": "1.0.0",
10 | "hasInstallScript": true,
11 | "license": "ISC",
12 | "dependencies": {
13 | "@prisma/client": "^5.9.1",
14 | "bcryptjs": "^2.4.3",
15 | "cookie-parser": "^1.4.6",
16 | "cors": "^2.8.5",
17 | "dotenv": "^16.4.1",
18 | "express": "^4.18.2",
19 | "jsonwebtoken": "^9.0.2",
20 | "socket.io": "^4.7.4",
21 | "zod": "^3.22.4"
22 | },
23 | "devDependencies": {
24 | "prisma": "^5.9.1"
25 | }
26 | },
27 | "node_modules/@prisma/client": {
28 | "version": "5.10.2",
29 | "resolved": "https://registry.npmjs.org/@prisma/client/-/client-5.10.2.tgz",
30 | "integrity": "sha512-ef49hzB2yJZCvM5gFHMxSFL9KYrIP9udpT5rYo0CsHD4P9IKj473MbhU1gjKKftiwWBTIyrt9jukprzZXazyag==",
31 | "hasInstallScript": true,
32 | "engines": {
33 | "node": ">=16.13"
34 | },
35 | "peerDependencies": {
36 | "prisma": "*"
37 | },
38 | "peerDependenciesMeta": {
39 | "prisma": {
40 | "optional": true
41 | }
42 | }
43 | },
44 | "node_modules/@prisma/debug": {
45 | "version": "5.10.2",
46 | "resolved": "https://registry.npmjs.org/@prisma/debug/-/debug-5.10.2.tgz",
47 | "integrity": "sha512-bkBOmH9dpEBbMKFJj8V+Zp8IZHIBjy3fSyhLhxj4FmKGb/UBSt9doyfA6k1UeUREsMJft7xgPYBbHSOYBr8XCA==",
48 | "devOptional": true
49 | },
50 | "node_modules/@prisma/engines": {
51 | "version": "5.10.2",
52 | "resolved": "https://registry.npmjs.org/@prisma/engines/-/engines-5.10.2.tgz",
53 | "integrity": "sha512-HkSJvix6PW8YqEEt3zHfCYYJY69CXsNdhU+wna+4Y7EZ+AwzeupMnUThmvaDA7uqswiHkgm5/SZ6/4CStjaGmw==",
54 | "devOptional": true,
55 | "hasInstallScript": true,
56 | "dependencies": {
57 | "@prisma/debug": "5.10.2",
58 | "@prisma/engines-version": "5.10.0-34.5a9203d0590c951969e85a7d07215503f4672eb9",
59 | "@prisma/fetch-engine": "5.10.2",
60 | "@prisma/get-platform": "5.10.2"
61 | }
62 | },
63 | "node_modules/@prisma/engines-version": {
64 | "version": "5.10.0-34.5a9203d0590c951969e85a7d07215503f4672eb9",
65 | "resolved": "https://registry.npmjs.org/@prisma/engines-version/-/engines-version-5.10.0-34.5a9203d0590c951969e85a7d07215503f4672eb9.tgz",
66 | "integrity": "sha512-uCy/++3Jx/O3ufM+qv2H1L4tOemTNqcP/gyEVOlZqTpBvYJUe0tWtW0y3o2Ueq04mll4aM5X3f6ugQftOSLdFQ==",
67 | "devOptional": true
68 | },
69 | "node_modules/@prisma/fetch-engine": {
70 | "version": "5.10.2",
71 | "resolved": "https://registry.npmjs.org/@prisma/fetch-engine/-/fetch-engine-5.10.2.tgz",
72 | "integrity": "sha512-dSmXcqSt6DpTmMaLQ9K8ZKzVAMH3qwGCmYEZr/uVnzVhxRJ1EbT/w2MMwIdBNq1zT69Rvh0h75WMIi0mrIw7Hg==",
73 | "devOptional": true,
74 | "dependencies": {
75 | "@prisma/debug": "5.10.2",
76 | "@prisma/engines-version": "5.10.0-34.5a9203d0590c951969e85a7d07215503f4672eb9",
77 | "@prisma/get-platform": "5.10.2"
78 | }
79 | },
80 | "node_modules/@prisma/get-platform": {
81 | "version": "5.10.2",
82 | "resolved": "https://registry.npmjs.org/@prisma/get-platform/-/get-platform-5.10.2.tgz",
83 | "integrity": "sha512-nqXP6vHiY2PIsebBAuDeWiUYg8h8mfjBckHh6Jezuwej0QJNnjDiOq30uesmg+JXxGk99nqyG3B7wpcOODzXvg==",
84 | "devOptional": true,
85 | "dependencies": {
86 | "@prisma/debug": "5.10.2"
87 | }
88 | },
89 | "node_modules/@socket.io/component-emitter": {
90 | "version": "3.1.0",
91 | "resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.0.tgz",
92 | "integrity": "sha512-+9jVqKhRSpsc591z5vX+X5Yyw+he/HCB4iQ/RYxw35CEPaY1gnsNE43nf9n9AaYjAQrTiI/mOwKUKdUs9vf7Xg=="
93 | },
94 | "node_modules/@types/cookie": {
95 | "version": "0.4.1",
96 | "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.4.1.tgz",
97 | "integrity": "sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q=="
98 | },
99 | "node_modules/@types/cors": {
100 | "version": "2.8.17",
101 | "resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.17.tgz",
102 | "integrity": "sha512-8CGDvrBj1zgo2qE+oS3pOCyYNqCPryMWY2bGfwA0dcfopWGgxs+78df0Rs3rc9THP4JkOhLsAa+15VdpAqkcUA==",
103 | "dependencies": {
104 | "@types/node": "*"
105 | }
106 | },
107 | "node_modules/@types/node": {
108 | "version": "20.11.20",
109 | "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.20.tgz",
110 | "integrity": "sha512-7/rR21OS+fq8IyHTgtLkDK949uzsa6n8BkziAKtPVpugIkO6D+/ooXMvzXxDnZrmtXVfjb1bKQafYpb8s89LOg==",
111 | "dependencies": {
112 | "undici-types": "~5.26.4"
113 | }
114 | },
115 | "node_modules/accepts": {
116 | "version": "1.3.8",
117 | "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
118 | "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==",
119 | "dependencies": {
120 | "mime-types": "~2.1.34",
121 | "negotiator": "0.6.3"
122 | },
123 | "engines": {
124 | "node": ">= 0.6"
125 | }
126 | },
127 | "node_modules/array-flatten": {
128 | "version": "1.1.1",
129 | "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
130 | "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg=="
131 | },
132 | "node_modules/base64id": {
133 | "version": "2.0.0",
134 | "resolved": "https://registry.npmjs.org/base64id/-/base64id-2.0.0.tgz",
135 | "integrity": "sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog==",
136 | "engines": {
137 | "node": "^4.5.0 || >= 5.9"
138 | }
139 | },
140 | "node_modules/bcryptjs": {
141 | "version": "2.4.3",
142 | "resolved": "https://registry.npmjs.org/bcryptjs/-/bcryptjs-2.4.3.tgz",
143 | "integrity": "sha512-V/Hy/X9Vt7f3BbPJEi8BdVFMByHi+jNXrYkW3huaybV/kQ0KJg0Y6PkEMbn+zeT+i+SiKZ/HMqJGIIt4LZDqNQ=="
144 | },
145 | "node_modules/body-parser": {
146 | "version": "1.20.1",
147 | "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz",
148 | "integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==",
149 | "dependencies": {
150 | "bytes": "3.1.2",
151 | "content-type": "~1.0.4",
152 | "debug": "2.6.9",
153 | "depd": "2.0.0",
154 | "destroy": "1.2.0",
155 | "http-errors": "2.0.0",
156 | "iconv-lite": "0.4.24",
157 | "on-finished": "2.4.1",
158 | "qs": "6.11.0",
159 | "raw-body": "2.5.1",
160 | "type-is": "~1.6.18",
161 | "unpipe": "1.0.0"
162 | },
163 | "engines": {
164 | "node": ">= 0.8",
165 | "npm": "1.2.8000 || >= 1.4.16"
166 | }
167 | },
168 | "node_modules/buffer-equal-constant-time": {
169 | "version": "1.0.1",
170 | "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz",
171 | "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA=="
172 | },
173 | "node_modules/bytes": {
174 | "version": "3.1.2",
175 | "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
176 | "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==",
177 | "engines": {
178 | "node": ">= 0.8"
179 | }
180 | },
181 | "node_modules/call-bind": {
182 | "version": "1.0.7",
183 | "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz",
184 | "integrity": "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==",
185 | "dependencies": {
186 | "es-define-property": "^1.0.0",
187 | "es-errors": "^1.3.0",
188 | "function-bind": "^1.1.2",
189 | "get-intrinsic": "^1.2.4",
190 | "set-function-length": "^1.2.1"
191 | },
192 | "engines": {
193 | "node": ">= 0.4"
194 | },
195 | "funding": {
196 | "url": "https://github.com/sponsors/ljharb"
197 | }
198 | },
199 | "node_modules/content-disposition": {
200 | "version": "0.5.4",
201 | "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
202 | "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==",
203 | "dependencies": {
204 | "safe-buffer": "5.2.1"
205 | },
206 | "engines": {
207 | "node": ">= 0.6"
208 | }
209 | },
210 | "node_modules/content-type": {
211 | "version": "1.0.5",
212 | "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz",
213 | "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==",
214 | "engines": {
215 | "node": ">= 0.6"
216 | }
217 | },
218 | "node_modules/cookie": {
219 | "version": "0.4.1",
220 | "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.1.tgz",
221 | "integrity": "sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA==",
222 | "engines": {
223 | "node": ">= 0.6"
224 | }
225 | },
226 | "node_modules/cookie-parser": {
227 | "version": "1.4.6",
228 | "resolved": "https://registry.npmjs.org/cookie-parser/-/cookie-parser-1.4.6.tgz",
229 | "integrity": "sha512-z3IzaNjdwUC2olLIB5/ITd0/setiaFMLYiZJle7xg5Fe9KWAceil7xszYfHHBtDFYLSgJduS2Ty0P1uJdPDJeA==",
230 | "dependencies": {
231 | "cookie": "0.4.1",
232 | "cookie-signature": "1.0.6"
233 | },
234 | "engines": {
235 | "node": ">= 0.8.0"
236 | }
237 | },
238 | "node_modules/cookie-signature": {
239 | "version": "1.0.6",
240 | "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
241 | "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ=="
242 | },
243 | "node_modules/cors": {
244 | "version": "2.8.5",
245 | "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz",
246 | "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==",
247 | "dependencies": {
248 | "object-assign": "^4",
249 | "vary": "^1"
250 | },
251 | "engines": {
252 | "node": ">= 0.10"
253 | }
254 | },
255 | "node_modules/debug": {
256 | "version": "2.6.9",
257 | "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
258 | "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
259 | "dependencies": {
260 | "ms": "2.0.0"
261 | }
262 | },
263 | "node_modules/define-data-property": {
264 | "version": "1.1.4",
265 | "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz",
266 | "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==",
267 | "dependencies": {
268 | "es-define-property": "^1.0.0",
269 | "es-errors": "^1.3.0",
270 | "gopd": "^1.0.1"
271 | },
272 | "engines": {
273 | "node": ">= 0.4"
274 | },
275 | "funding": {
276 | "url": "https://github.com/sponsors/ljharb"
277 | }
278 | },
279 | "node_modules/depd": {
280 | "version": "2.0.0",
281 | "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
282 | "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==",
283 | "engines": {
284 | "node": ">= 0.8"
285 | }
286 | },
287 | "node_modules/destroy": {
288 | "version": "1.2.0",
289 | "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz",
290 | "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==",
291 | "engines": {
292 | "node": ">= 0.8",
293 | "npm": "1.2.8000 || >= 1.4.16"
294 | }
295 | },
296 | "node_modules/dotenv": {
297 | "version": "16.4.5",
298 | "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz",
299 | "integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==",
300 | "engines": {
301 | "node": ">=12"
302 | },
303 | "funding": {
304 | "url": "https://dotenvx.com"
305 | }
306 | },
307 | "node_modules/ecdsa-sig-formatter": {
308 | "version": "1.0.11",
309 | "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz",
310 | "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==",
311 | "dependencies": {
312 | "safe-buffer": "^5.0.1"
313 | }
314 | },
315 | "node_modules/ee-first": {
316 | "version": "1.1.1",
317 | "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
318 | "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow=="
319 | },
320 | "node_modules/encodeurl": {
321 | "version": "1.0.2",
322 | "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
323 | "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==",
324 | "engines": {
325 | "node": ">= 0.8"
326 | }
327 | },
328 | "node_modules/engine.io": {
329 | "version": "6.5.4",
330 | "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.5.4.tgz",
331 | "integrity": "sha512-KdVSDKhVKyOi+r5uEabrDLZw2qXStVvCsEB/LN3mw4WFi6Gx50jTyuxYVCwAAC0U46FdnzP/ScKRBTXb/NiEOg==",
332 | "dependencies": {
333 | "@types/cookie": "^0.4.1",
334 | "@types/cors": "^2.8.12",
335 | "@types/node": ">=10.0.0",
336 | "accepts": "~1.3.4",
337 | "base64id": "2.0.0",
338 | "cookie": "~0.4.1",
339 | "cors": "~2.8.5",
340 | "debug": "~4.3.1",
341 | "engine.io-parser": "~5.2.1",
342 | "ws": "~8.11.0"
343 | },
344 | "engines": {
345 | "node": ">=10.2.0"
346 | }
347 | },
348 | "node_modules/engine.io-parser": {
349 | "version": "5.2.2",
350 | "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.2.2.tgz",
351 | "integrity": "sha512-RcyUFKA93/CXH20l4SoVvzZfrSDMOTUS3bWVpTt2FuFP+XYrL8i8oonHP7WInRyVHXh0n/ORtoeiE1os+8qkSw==",
352 | "engines": {
353 | "node": ">=10.0.0"
354 | }
355 | },
356 | "node_modules/engine.io/node_modules/debug": {
357 | "version": "4.3.4",
358 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
359 | "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==",
360 | "dependencies": {
361 | "ms": "2.1.2"
362 | },
363 | "engines": {
364 | "node": ">=6.0"
365 | },
366 | "peerDependenciesMeta": {
367 | "supports-color": {
368 | "optional": true
369 | }
370 | }
371 | },
372 | "node_modules/engine.io/node_modules/ms": {
373 | "version": "2.1.2",
374 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
375 | "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
376 | },
377 | "node_modules/es-define-property": {
378 | "version": "1.0.0",
379 | "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz",
380 | "integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==",
381 | "dependencies": {
382 | "get-intrinsic": "^1.2.4"
383 | },
384 | "engines": {
385 | "node": ">= 0.4"
386 | }
387 | },
388 | "node_modules/es-errors": {
389 | "version": "1.3.0",
390 | "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
391 | "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
392 | "engines": {
393 | "node": ">= 0.4"
394 | }
395 | },
396 | "node_modules/escape-html": {
397 | "version": "1.0.3",
398 | "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
399 | "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow=="
400 | },
401 | "node_modules/etag": {
402 | "version": "1.8.1",
403 | "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
404 | "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==",
405 | "engines": {
406 | "node": ">= 0.6"
407 | }
408 | },
409 | "node_modules/express": {
410 | "version": "4.18.2",
411 | "resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz",
412 | "integrity": "sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==",
413 | "dependencies": {
414 | "accepts": "~1.3.8",
415 | "array-flatten": "1.1.1",
416 | "body-parser": "1.20.1",
417 | "content-disposition": "0.5.4",
418 | "content-type": "~1.0.4",
419 | "cookie": "0.5.0",
420 | "cookie-signature": "1.0.6",
421 | "debug": "2.6.9",
422 | "depd": "2.0.0",
423 | "encodeurl": "~1.0.2",
424 | "escape-html": "~1.0.3",
425 | "etag": "~1.8.1",
426 | "finalhandler": "1.2.0",
427 | "fresh": "0.5.2",
428 | "http-errors": "2.0.0",
429 | "merge-descriptors": "1.0.1",
430 | "methods": "~1.1.2",
431 | "on-finished": "2.4.1",
432 | "parseurl": "~1.3.3",
433 | "path-to-regexp": "0.1.7",
434 | "proxy-addr": "~2.0.7",
435 | "qs": "6.11.0",
436 | "range-parser": "~1.2.1",
437 | "safe-buffer": "5.2.1",
438 | "send": "0.18.0",
439 | "serve-static": "1.15.0",
440 | "setprototypeof": "1.2.0",
441 | "statuses": "2.0.1",
442 | "type-is": "~1.6.18",
443 | "utils-merge": "1.0.1",
444 | "vary": "~1.1.2"
445 | },
446 | "engines": {
447 | "node": ">= 0.10.0"
448 | }
449 | },
450 | "node_modules/express/node_modules/cookie": {
451 | "version": "0.5.0",
452 | "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz",
453 | "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==",
454 | "engines": {
455 | "node": ">= 0.6"
456 | }
457 | },
458 | "node_modules/finalhandler": {
459 | "version": "1.2.0",
460 | "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz",
461 | "integrity": "sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==",
462 | "dependencies": {
463 | "debug": "2.6.9",
464 | "encodeurl": "~1.0.2",
465 | "escape-html": "~1.0.3",
466 | "on-finished": "2.4.1",
467 | "parseurl": "~1.3.3",
468 | "statuses": "2.0.1",
469 | "unpipe": "~1.0.0"
470 | },
471 | "engines": {
472 | "node": ">= 0.8"
473 | }
474 | },
475 | "node_modules/forwarded": {
476 | "version": "0.2.0",
477 | "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
478 | "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==",
479 | "engines": {
480 | "node": ">= 0.6"
481 | }
482 | },
483 | "node_modules/fresh": {
484 | "version": "0.5.2",
485 | "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
486 | "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==",
487 | "engines": {
488 | "node": ">= 0.6"
489 | }
490 | },
491 | "node_modules/function-bind": {
492 | "version": "1.1.2",
493 | "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
494 | "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
495 | "funding": {
496 | "url": "https://github.com/sponsors/ljharb"
497 | }
498 | },
499 | "node_modules/get-intrinsic": {
500 | "version": "1.2.4",
501 | "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz",
502 | "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==",
503 | "dependencies": {
504 | "es-errors": "^1.3.0",
505 | "function-bind": "^1.1.2",
506 | "has-proto": "^1.0.1",
507 | "has-symbols": "^1.0.3",
508 | "hasown": "^2.0.0"
509 | },
510 | "engines": {
511 | "node": ">= 0.4"
512 | },
513 | "funding": {
514 | "url": "https://github.com/sponsors/ljharb"
515 | }
516 | },
517 | "node_modules/gopd": {
518 | "version": "1.0.1",
519 | "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz",
520 | "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==",
521 | "dependencies": {
522 | "get-intrinsic": "^1.1.3"
523 | },
524 | "funding": {
525 | "url": "https://github.com/sponsors/ljharb"
526 | }
527 | },
528 | "node_modules/has-property-descriptors": {
529 | "version": "1.0.2",
530 | "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz",
531 | "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==",
532 | "dependencies": {
533 | "es-define-property": "^1.0.0"
534 | },
535 | "funding": {
536 | "url": "https://github.com/sponsors/ljharb"
537 | }
538 | },
539 | "node_modules/has-proto": {
540 | "version": "1.0.3",
541 | "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.3.tgz",
542 | "integrity": "sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==",
543 | "engines": {
544 | "node": ">= 0.4"
545 | },
546 | "funding": {
547 | "url": "https://github.com/sponsors/ljharb"
548 | }
549 | },
550 | "node_modules/has-symbols": {
551 | "version": "1.0.3",
552 | "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz",
553 | "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==",
554 | "engines": {
555 | "node": ">= 0.4"
556 | },
557 | "funding": {
558 | "url": "https://github.com/sponsors/ljharb"
559 | }
560 | },
561 | "node_modules/hasown": {
562 | "version": "2.0.1",
563 | "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.1.tgz",
564 | "integrity": "sha512-1/th4MHjnwncwXsIW6QMzlvYL9kG5e/CpVvLRZe4XPa8TOUNbCELqmvhDmnkNsAjwaG4+I8gJJL0JBvTTLO9qA==",
565 | "dependencies": {
566 | "function-bind": "^1.1.2"
567 | },
568 | "engines": {
569 | "node": ">= 0.4"
570 | }
571 | },
572 | "node_modules/http-errors": {
573 | "version": "2.0.0",
574 | "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz",
575 | "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==",
576 | "dependencies": {
577 | "depd": "2.0.0",
578 | "inherits": "2.0.4",
579 | "setprototypeof": "1.2.0",
580 | "statuses": "2.0.1",
581 | "toidentifier": "1.0.1"
582 | },
583 | "engines": {
584 | "node": ">= 0.8"
585 | }
586 | },
587 | "node_modules/iconv-lite": {
588 | "version": "0.4.24",
589 | "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
590 | "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
591 | "dependencies": {
592 | "safer-buffer": ">= 2.1.2 < 3"
593 | },
594 | "engines": {
595 | "node": ">=0.10.0"
596 | }
597 | },
598 | "node_modules/inherits": {
599 | "version": "2.0.4",
600 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
601 | "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
602 | },
603 | "node_modules/ipaddr.js": {
604 | "version": "1.9.1",
605 | "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
606 | "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==",
607 | "engines": {
608 | "node": ">= 0.10"
609 | }
610 | },
611 | "node_modules/jsonwebtoken": {
612 | "version": "9.0.2",
613 | "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.2.tgz",
614 | "integrity": "sha512-PRp66vJ865SSqOlgqS8hujT5U4AOgMfhrwYIuIhfKaoSCZcirrmASQr8CX7cUg+RMih+hgznrjp99o+W4pJLHQ==",
615 | "dependencies": {
616 | "jws": "^3.2.2",
617 | "lodash.includes": "^4.3.0",
618 | "lodash.isboolean": "^3.0.3",
619 | "lodash.isinteger": "^4.0.4",
620 | "lodash.isnumber": "^3.0.3",
621 | "lodash.isplainobject": "^4.0.6",
622 | "lodash.isstring": "^4.0.1",
623 | "lodash.once": "^4.0.0",
624 | "ms": "^2.1.1",
625 | "semver": "^7.5.4"
626 | },
627 | "engines": {
628 | "node": ">=12",
629 | "npm": ">=6"
630 | }
631 | },
632 | "node_modules/jsonwebtoken/node_modules/ms": {
633 | "version": "2.1.3",
634 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
635 | "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
636 | },
637 | "node_modules/jwa": {
638 | "version": "1.4.1",
639 | "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz",
640 | "integrity": "sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA==",
641 | "dependencies": {
642 | "buffer-equal-constant-time": "1.0.1",
643 | "ecdsa-sig-formatter": "1.0.11",
644 | "safe-buffer": "^5.0.1"
645 | }
646 | },
647 | "node_modules/jws": {
648 | "version": "3.2.2",
649 | "resolved": "https://registry.npmjs.org/jws/-/jws-3.2.2.tgz",
650 | "integrity": "sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==",
651 | "dependencies": {
652 | "jwa": "^1.4.1",
653 | "safe-buffer": "^5.0.1"
654 | }
655 | },
656 | "node_modules/lodash.includes": {
657 | "version": "4.3.0",
658 | "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz",
659 | "integrity": "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w=="
660 | },
661 | "node_modules/lodash.isboolean": {
662 | "version": "3.0.3",
663 | "resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz",
664 | "integrity": "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg=="
665 | },
666 | "node_modules/lodash.isinteger": {
667 | "version": "4.0.4",
668 | "resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz",
669 | "integrity": "sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA=="
670 | },
671 | "node_modules/lodash.isnumber": {
672 | "version": "3.0.3",
673 | "resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz",
674 | "integrity": "sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw=="
675 | },
676 | "node_modules/lodash.isplainobject": {
677 | "version": "4.0.6",
678 | "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz",
679 | "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA=="
680 | },
681 | "node_modules/lodash.isstring": {
682 | "version": "4.0.1",
683 | "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz",
684 | "integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw=="
685 | },
686 | "node_modules/lodash.once": {
687 | "version": "4.1.1",
688 | "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz",
689 | "integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg=="
690 | },
691 | "node_modules/lru-cache": {
692 | "version": "6.0.0",
693 | "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
694 | "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
695 | "dependencies": {
696 | "yallist": "^4.0.0"
697 | },
698 | "engines": {
699 | "node": ">=10"
700 | }
701 | },
702 | "node_modules/media-typer": {
703 | "version": "0.3.0",
704 | "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
705 | "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==",
706 | "engines": {
707 | "node": ">= 0.6"
708 | }
709 | },
710 | "node_modules/merge-descriptors": {
711 | "version": "1.0.1",
712 | "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz",
713 | "integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w=="
714 | },
715 | "node_modules/methods": {
716 | "version": "1.1.2",
717 | "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
718 | "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==",
719 | "engines": {
720 | "node": ">= 0.6"
721 | }
722 | },
723 | "node_modules/mime": {
724 | "version": "1.6.0",
725 | "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
726 | "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
727 | "bin": {
728 | "mime": "cli.js"
729 | },
730 | "engines": {
731 | "node": ">=4"
732 | }
733 | },
734 | "node_modules/mime-db": {
735 | "version": "1.52.0",
736 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
737 | "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
738 | "engines": {
739 | "node": ">= 0.6"
740 | }
741 | },
742 | "node_modules/mime-types": {
743 | "version": "2.1.35",
744 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
745 | "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
746 | "dependencies": {
747 | "mime-db": "1.52.0"
748 | },
749 | "engines": {
750 | "node": ">= 0.6"
751 | }
752 | },
753 | "node_modules/ms": {
754 | "version": "2.0.0",
755 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
756 | "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A=="
757 | },
758 | "node_modules/negotiator": {
759 | "version": "0.6.3",
760 | "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz",
761 | "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==",
762 | "engines": {
763 | "node": ">= 0.6"
764 | }
765 | },
766 | "node_modules/object-assign": {
767 | "version": "4.1.1",
768 | "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
769 | "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==",
770 | "engines": {
771 | "node": ">=0.10.0"
772 | }
773 | },
774 | "node_modules/object-inspect": {
775 | "version": "1.13.1",
776 | "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.1.tgz",
777 | "integrity": "sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ==",
778 | "funding": {
779 | "url": "https://github.com/sponsors/ljharb"
780 | }
781 | },
782 | "node_modules/on-finished": {
783 | "version": "2.4.1",
784 | "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz",
785 | "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==",
786 | "dependencies": {
787 | "ee-first": "1.1.1"
788 | },
789 | "engines": {
790 | "node": ">= 0.8"
791 | }
792 | },
793 | "node_modules/parseurl": {
794 | "version": "1.3.3",
795 | "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
796 | "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==",
797 | "engines": {
798 | "node": ">= 0.8"
799 | }
800 | },
801 | "node_modules/path-to-regexp": {
802 | "version": "0.1.7",
803 | "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
804 | "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ=="
805 | },
806 | "node_modules/prisma": {
807 | "version": "5.10.2",
808 | "resolved": "https://registry.npmjs.org/prisma/-/prisma-5.10.2.tgz",
809 | "integrity": "sha512-hqb/JMz9/kymRE25pMWCxkdyhbnIWrq+h7S6WysJpdnCvhstbJSNP/S6mScEcqiB8Qv2F+0R3yG+osRaWqZacQ==",
810 | "devOptional": true,
811 | "hasInstallScript": true,
812 | "dependencies": {
813 | "@prisma/engines": "5.10.2"
814 | },
815 | "bin": {
816 | "prisma": "build/index.js"
817 | },
818 | "engines": {
819 | "node": ">=16.13"
820 | }
821 | },
822 | "node_modules/proxy-addr": {
823 | "version": "2.0.7",
824 | "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
825 | "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==",
826 | "dependencies": {
827 | "forwarded": "0.2.0",
828 | "ipaddr.js": "1.9.1"
829 | },
830 | "engines": {
831 | "node": ">= 0.10"
832 | }
833 | },
834 | "node_modules/qs": {
835 | "version": "6.11.0",
836 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz",
837 | "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==",
838 | "dependencies": {
839 | "side-channel": "^1.0.4"
840 | },
841 | "engines": {
842 | "node": ">=0.6"
843 | },
844 | "funding": {
845 | "url": "https://github.com/sponsors/ljharb"
846 | }
847 | },
848 | "node_modules/range-parser": {
849 | "version": "1.2.1",
850 | "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
851 | "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==",
852 | "engines": {
853 | "node": ">= 0.6"
854 | }
855 | },
856 | "node_modules/raw-body": {
857 | "version": "2.5.1",
858 | "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz",
859 | "integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==",
860 | "dependencies": {
861 | "bytes": "3.1.2",
862 | "http-errors": "2.0.0",
863 | "iconv-lite": "0.4.24",
864 | "unpipe": "1.0.0"
865 | },
866 | "engines": {
867 | "node": ">= 0.8"
868 | }
869 | },
870 | "node_modules/safe-buffer": {
871 | "version": "5.2.1",
872 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
873 | "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
874 | "funding": [
875 | {
876 | "type": "github",
877 | "url": "https://github.com/sponsors/feross"
878 | },
879 | {
880 | "type": "patreon",
881 | "url": "https://www.patreon.com/feross"
882 | },
883 | {
884 | "type": "consulting",
885 | "url": "https://feross.org/support"
886 | }
887 | ]
888 | },
889 | "node_modules/safer-buffer": {
890 | "version": "2.1.2",
891 | "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
892 | "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
893 | },
894 | "node_modules/semver": {
895 | "version": "7.6.0",
896 | "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.0.tgz",
897 | "integrity": "sha512-EnwXhrlwXMk9gKu5/flx5sv/an57AkRplG3hTK68W7FRDN+k+OWBj65M7719OkA82XLBxrcX0KSHj+X5COhOVg==",
898 | "dependencies": {
899 | "lru-cache": "^6.0.0"
900 | },
901 | "bin": {
902 | "semver": "bin/semver.js"
903 | },
904 | "engines": {
905 | "node": ">=10"
906 | }
907 | },
908 | "node_modules/send": {
909 | "version": "0.18.0",
910 | "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz",
911 | "integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==",
912 | "dependencies": {
913 | "debug": "2.6.9",
914 | "depd": "2.0.0",
915 | "destroy": "1.2.0",
916 | "encodeurl": "~1.0.2",
917 | "escape-html": "~1.0.3",
918 | "etag": "~1.8.1",
919 | "fresh": "0.5.2",
920 | "http-errors": "2.0.0",
921 | "mime": "1.6.0",
922 | "ms": "2.1.3",
923 | "on-finished": "2.4.1",
924 | "range-parser": "~1.2.1",
925 | "statuses": "2.0.1"
926 | },
927 | "engines": {
928 | "node": ">= 0.8.0"
929 | }
930 | },
931 | "node_modules/send/node_modules/ms": {
932 | "version": "2.1.3",
933 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
934 | "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
935 | },
936 | "node_modules/serve-static": {
937 | "version": "1.15.0",
938 | "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz",
939 | "integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==",
940 | "dependencies": {
941 | "encodeurl": "~1.0.2",
942 | "escape-html": "~1.0.3",
943 | "parseurl": "~1.3.3",
944 | "send": "0.18.0"
945 | },
946 | "engines": {
947 | "node": ">= 0.8.0"
948 | }
949 | },
950 | "node_modules/set-function-length": {
951 | "version": "1.2.1",
952 | "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.1.tgz",
953 | "integrity": "sha512-j4t6ccc+VsKwYHso+kElc5neZpjtq9EnRICFZtWyBsLojhmeF/ZBd/elqm22WJh/BziDe/SBiOeAt0m2mfLD0g==",
954 | "dependencies": {
955 | "define-data-property": "^1.1.2",
956 | "es-errors": "^1.3.0",
957 | "function-bind": "^1.1.2",
958 | "get-intrinsic": "^1.2.3",
959 | "gopd": "^1.0.1",
960 | "has-property-descriptors": "^1.0.1"
961 | },
962 | "engines": {
963 | "node": ">= 0.4"
964 | }
965 | },
966 | "node_modules/setprototypeof": {
967 | "version": "1.2.0",
968 | "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
969 | "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw=="
970 | },
971 | "node_modules/side-channel": {
972 | "version": "1.0.5",
973 | "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.5.tgz",
974 | "integrity": "sha512-QcgiIWV4WV7qWExbN5llt6frQB/lBven9pqliLXfGPB+K9ZYXxDozp0wLkHS24kWCm+6YXH/f0HhnObZnZOBnQ==",
975 | "dependencies": {
976 | "call-bind": "^1.0.6",
977 | "es-errors": "^1.3.0",
978 | "get-intrinsic": "^1.2.4",
979 | "object-inspect": "^1.13.1"
980 | },
981 | "engines": {
982 | "node": ">= 0.4"
983 | },
984 | "funding": {
985 | "url": "https://github.com/sponsors/ljharb"
986 | }
987 | },
988 | "node_modules/socket.io": {
989 | "version": "4.7.4",
990 | "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-4.7.4.tgz",
991 | "integrity": "sha512-DcotgfP1Zg9iP/dH9zvAQcWrE0TtbMVwXmlV4T4mqsvY+gw+LqUGPfx2AoVyRk0FLME+GQhufDMyacFmw7ksqw==",
992 | "dependencies": {
993 | "accepts": "~1.3.4",
994 | "base64id": "~2.0.0",
995 | "cors": "~2.8.5",
996 | "debug": "~4.3.2",
997 | "engine.io": "~6.5.2",
998 | "socket.io-adapter": "~2.5.2",
999 | "socket.io-parser": "~4.2.4"
1000 | },
1001 | "engines": {
1002 | "node": ">=10.2.0"
1003 | }
1004 | },
1005 | "node_modules/socket.io-adapter": {
1006 | "version": "2.5.4",
1007 | "resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-2.5.4.tgz",
1008 | "integrity": "sha512-wDNHGXGewWAjQPt3pyeYBtpWSq9cLE5UW1ZUPL/2eGK9jtse/FpXib7epSTsz0Q0m+6sg6Y4KtcFTlah1bdOVg==",
1009 | "dependencies": {
1010 | "debug": "~4.3.4",
1011 | "ws": "~8.11.0"
1012 | }
1013 | },
1014 | "node_modules/socket.io-adapter/node_modules/debug": {
1015 | "version": "4.3.4",
1016 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
1017 | "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==",
1018 | "dependencies": {
1019 | "ms": "2.1.2"
1020 | },
1021 | "engines": {
1022 | "node": ">=6.0"
1023 | },
1024 | "peerDependenciesMeta": {
1025 | "supports-color": {
1026 | "optional": true
1027 | }
1028 | }
1029 | },
1030 | "node_modules/socket.io-adapter/node_modules/ms": {
1031 | "version": "2.1.2",
1032 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
1033 | "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
1034 | },
1035 | "node_modules/socket.io-parser": {
1036 | "version": "4.2.4",
1037 | "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.2.4.tgz",
1038 | "integrity": "sha512-/GbIKmo8ioc+NIWIhwdecY0ge+qVBSMdgxGygevmdHj24bsfgtCmcUUcQ5ZzcylGFHsN3k4HB4Cgkl96KVnuew==",
1039 | "dependencies": {
1040 | "@socket.io/component-emitter": "~3.1.0",
1041 | "debug": "~4.3.1"
1042 | },
1043 | "engines": {
1044 | "node": ">=10.0.0"
1045 | }
1046 | },
1047 | "node_modules/socket.io-parser/node_modules/debug": {
1048 | "version": "4.3.4",
1049 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
1050 | "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==",
1051 | "dependencies": {
1052 | "ms": "2.1.2"
1053 | },
1054 | "engines": {
1055 | "node": ">=6.0"
1056 | },
1057 | "peerDependenciesMeta": {
1058 | "supports-color": {
1059 | "optional": true
1060 | }
1061 | }
1062 | },
1063 | "node_modules/socket.io-parser/node_modules/ms": {
1064 | "version": "2.1.2",
1065 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
1066 | "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
1067 | },
1068 | "node_modules/socket.io/node_modules/debug": {
1069 | "version": "4.3.4",
1070 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
1071 | "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==",
1072 | "dependencies": {
1073 | "ms": "2.1.2"
1074 | },
1075 | "engines": {
1076 | "node": ">=6.0"
1077 | },
1078 | "peerDependenciesMeta": {
1079 | "supports-color": {
1080 | "optional": true
1081 | }
1082 | }
1083 | },
1084 | "node_modules/socket.io/node_modules/ms": {
1085 | "version": "2.1.2",
1086 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
1087 | "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
1088 | },
1089 | "node_modules/statuses": {
1090 | "version": "2.0.1",
1091 | "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz",
1092 | "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==",
1093 | "engines": {
1094 | "node": ">= 0.8"
1095 | }
1096 | },
1097 | "node_modules/toidentifier": {
1098 | "version": "1.0.1",
1099 | "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
1100 | "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==",
1101 | "engines": {
1102 | "node": ">=0.6"
1103 | }
1104 | },
1105 | "node_modules/type-is": {
1106 | "version": "1.6.18",
1107 | "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
1108 | "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==",
1109 | "dependencies": {
1110 | "media-typer": "0.3.0",
1111 | "mime-types": "~2.1.24"
1112 | },
1113 | "engines": {
1114 | "node": ">= 0.6"
1115 | }
1116 | },
1117 | "node_modules/undici-types": {
1118 | "version": "5.26.5",
1119 | "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
1120 | "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA=="
1121 | },
1122 | "node_modules/unpipe": {
1123 | "version": "1.0.0",
1124 | "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
1125 | "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==",
1126 | "engines": {
1127 | "node": ">= 0.8"
1128 | }
1129 | },
1130 | "node_modules/utils-merge": {
1131 | "version": "1.0.1",
1132 | "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
1133 | "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==",
1134 | "engines": {
1135 | "node": ">= 0.4.0"
1136 | }
1137 | },
1138 | "node_modules/vary": {
1139 | "version": "1.1.2",
1140 | "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
1141 | "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==",
1142 | "engines": {
1143 | "node": ">= 0.8"
1144 | }
1145 | },
1146 | "node_modules/ws": {
1147 | "version": "8.11.0",
1148 | "resolved": "https://registry.npmjs.org/ws/-/ws-8.11.0.tgz",
1149 | "integrity": "sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==",
1150 | "engines": {
1151 | "node": ">=10.0.0"
1152 | },
1153 | "peerDependencies": {
1154 | "bufferutil": "^4.0.1",
1155 | "utf-8-validate": "^5.0.2"
1156 | },
1157 | "peerDependenciesMeta": {
1158 | "bufferutil": {
1159 | "optional": true
1160 | },
1161 | "utf-8-validate": {
1162 | "optional": true
1163 | }
1164 | }
1165 | },
1166 | "node_modules/yallist": {
1167 | "version": "4.0.0",
1168 | "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
1169 | "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A=="
1170 | },
1171 | "node_modules/zod": {
1172 | "version": "3.22.4",
1173 | "resolved": "https://registry.npmjs.org/zod/-/zod-3.22.4.tgz",
1174 | "integrity": "sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==",
1175 | "funding": {
1176 | "url": "https://github.com/sponsors/colinhacks"
1177 | }
1178 | }
1179 | }
1180 | }
1181 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "server",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "type": "module",
7 | "scripts": {
8 | "test": "echo \"Error: no test specified\" && exit 1",
9 | "start": "node server/index.js",
10 | "build": "npm install && npm install --prefix client && npm run build --prefix client",
11 | "postinstall": "prisma generate --schema=./server/prisma/schema.prisma"
12 | },
13 | "keywords": [],
14 | "author": "",
15 | "license": "ISC",
16 | "dependencies": {
17 | "@prisma/client": "^5.9.1",
18 | "bcryptjs": "^2.4.3",
19 | "cookie-parser": "^1.4.6",
20 | "cors": "^2.8.5",
21 | "dotenv": "^16.4.1",
22 | "express": "^4.18.2",
23 | "jsonwebtoken": "^9.0.2",
24 | "socket.io": "^4.7.4",
25 | "zod": "^3.22.4"
26 | },
27 | "devDependencies": {
28 | "prisma": "^5.9.1"
29 | }
30 | }
--------------------------------------------------------------------------------
/server/index.js:
--------------------------------------------------------------------------------
1 | import path from "path";
2 | import express from "express";
3 | import dotenv from "dotenv";
4 | import cookieParser from "cookie-parser";
5 |
6 | import authRoutes from "./routes/auth/index.js";
7 | import messageRoutes from "./routes/messages/index.js";
8 | import userRoutes from "./routes/user/index.js";
9 | import { app, server } from "./socket/socket.js";
10 |
11 | dotenv.config();
12 | const PORT = process.env.PORT || 5000;
13 |
14 | const __dirname = path.resolve();
15 |
16 | // app.use(cors());
17 | app.use(cookieParser());
18 | app.use(express.json());
19 |
20 | app.use("/api/auth", authRoutes);
21 | app.use("/api/messages", messageRoutes);
22 | app.use("/api/users", userRoutes);
23 |
24 | app.use(express.static(path.join(__dirname, "/client/dist")));
25 |
26 | app.get("*", (req, res) => {
27 | res.sendFile(path.join(__dirname,"client", "dist", "index.html"))
28 | })
29 |
30 | server.listen(PORT, () => {
31 | console.log("Server running");
32 | });
--------------------------------------------------------------------------------
/server/middleware/protectedRoutes.js:
--------------------------------------------------------------------------------
1 | import jwt from "jsonwebtoken";
2 | import { PrismaClient } from "@prisma/client";
3 |
4 | const prisma = new PrismaClient();
5 |
6 | const protectedRoutes = async (req, res, next) => {
7 | try {
8 | const token = req.cookies.jwt;
9 | if (!token) {
10 | res.status(403).json({
11 | message: "Unauthorized access",
12 | });
13 | }
14 |
15 | const decoded = jwt.verify(token, process.env.JWT_SECRET);
16 |
17 | if (!decoded) {
18 | res.status(403).json({
19 | message: "Invalid Credentials",
20 | });
21 | }
22 |
23 | const user = await prisma.user.findFirst({
24 | where: {
25 | username: decoded.username,
26 | },
27 | });
28 |
29 | if (!user) {
30 | res.status(403).json({
31 | message: "User not found",
32 | });
33 | }
34 |
35 | req.senderId = user.id;
36 | next();
37 | } catch (error) {
38 | res.status(500).json({
39 | message: "Internal Server Error",
40 | });
41 | }
42 | };
43 |
44 | export default protectedRoutes;
45 |
--------------------------------------------------------------------------------
/server/prisma/schema.prisma:
--------------------------------------------------------------------------------
1 | generator client {
2 | provider = "prisma-client-js"
3 | }
4 |
5 | datasource db {
6 | provider = "mongodb"
7 | url = env("DATABASE_URL")
8 | }
9 |
10 | model User {
11 | id String @id @default(auto()) @map("_id") @db.ObjectId
12 | username String @unique
13 | password String
14 | email String @unique
15 | firstname String
16 | lastname String
17 | profilePic String
18 | conversationId String[] @db.ObjectId
19 | messagesSent Message[] @relation(name: "sender")
20 | messagesReceived Message[] @relation(name: "receiver")
21 | conversation Conversation[] @relation(fields: [conversationId], references: [conversationId])
22 | }
23 |
24 | model Message {
25 | messageId String @id @default(auto()) @map("_id") @db.ObjectId
26 | body String
27 | senderId String @db.ObjectId
28 | receiverId String @db.ObjectId
29 | conversationId String[] @db.ObjectId
30 | createdAt DateTime @default(now())
31 | sender User @relation(name: "sender", fields: [senderId], references: [id])
32 | receiver User @relation(name: "receiver", fields: [receiverId], references: [id])
33 | coversation Conversation[] @relation(fields: [conversationId], references: [conversationId])
34 | }
35 |
36 | model Conversation {
37 | conversationId String @id @default(auto()) @map("_id") @db.ObjectId
38 | participantsId String[] @db.ObjectId
39 | messagesId String[] @db.ObjectId
40 | createdAt DateTime @default(now())
41 | participants User[] @relation(fields: [participantsId], references: [id])
42 | messages Message[] @relation(fields: [messagesId], references: [messageId])
43 | }
--------------------------------------------------------------------------------
/server/routes/auth/index.js:
--------------------------------------------------------------------------------
1 | import express from "express";
2 | import { userSchema, loginSchema } from "../../schema/index.js";
3 | import { PrismaClient } from "@prisma/client";
4 | import bcrypt from "bcryptjs";
5 | import genereateTokenandSetcookie from "../../utils/generateToken.js";
6 |
7 | const router = express.Router();
8 | const prisma = new PrismaClient();
9 |
10 | router.post("/signup", async (req, res) => {
11 | const result = userSchema.safeParse(req.body);
12 |
13 | if (result.success !== true) {
14 | return res.status(403).json({
15 | message: "Invalid form details",
16 | });
17 | }
18 |
19 | const isExistingUser = await prisma.user.findFirst({
20 | where: {
21 | username: req.body.username,
22 | },
23 | });
24 |
25 | if (isExistingUser !== null) {
26 | return res.status(403).json({
27 | message: "User aleardy Exists",
28 | });
29 | }
30 |
31 | const profileAvatar =
32 | req.body.gender === "male"
33 | ? `https://avatar.iran.liara.run/public/boy?username=${req.body.firstname}`
34 | : `https://avatar.iran.liara.run/public/girl?username=${req.body.firstname}`;
35 |
36 | const hashedPassword = await bcrypt.hash(req.body.password, 10);
37 | genereateTokenandSetcookie(req.body.username, req.body.email, res);
38 |
39 | try {
40 | const user = await prisma.user.create({
41 | data: {
42 | username: req.body.username,
43 | password: hashedPassword,
44 | email: req.body.email,
45 | firstname: req.body.firstname,
46 | lastname: req.body.lastname,
47 | profilePic: profileAvatar,
48 | },
49 | });
50 |
51 | return res.status(200).json({
52 | message: `User successfully created with username ${user.username}`,
53 | credentials : {id : user.id, username : user.username, email : user.email, firstname : user.firstname, lastname : user.lastname, profile : user.profilePic}
54 | });
55 | } catch (err) {
56 | return res.status(500).json({
57 | error : "Internal Server Error",
58 | });
59 | }
60 | });
61 |
62 | router.post("/login", async (req, res) => {
63 | const result = loginSchema.safeParse(req.body);
64 |
65 | if (result.success !== true) {
66 | return res.status(403).json({
67 | message: "Invalid form details",
68 | });
69 | }
70 |
71 | try {
72 | const user = await prisma.user.findFirst({
73 | where: {
74 | username: req.body.username,
75 | },
76 | });
77 |
78 | if (user === null) {
79 | return res.status(403).json({
80 | message: "User does not exists",
81 | });
82 | }
83 |
84 | const isCorrectpassword = await bcrypt.compare(
85 | req.body.password,
86 | user.password
87 | );
88 |
89 | if (!isCorrectpassword) {
90 | return res.status(403).json({
91 | message: "Invalid Password",
92 | });
93 | }
94 |
95 | genereateTokenandSetcookie(req.body.username, req.body.email, res);
96 | res.json({
97 | message: "Successfully logged in",
98 | credentials : {id : user.id, username : user.username, email : user.email, firstname : user.firstname, lastname : user.lastname, profile : user.profilePic}
99 | });
100 | } catch (error) {
101 | res.status(500).json({
102 | error: "Internal Server Erorr",
103 | });
104 | }
105 | });
106 |
107 | router.get("/logout", (req, res) => {
108 | try {
109 | res.cookie("jwt", "", {
110 | maxAge: 0,
111 | });
112 | res.status(200).json({
113 | message: "Logged out successfully",
114 | });
115 | } catch (error) {
116 | res.status(500).json({
117 | error: "Internal Server Error",
118 | });
119 | }
120 | });
121 |
122 | export default router;
--------------------------------------------------------------------------------
/server/routes/messages/index.js:
--------------------------------------------------------------------------------
1 | import express from "express";
2 | import protectedRoutes from "../../middleware/protectedRoutes.js";
3 | import { PrismaClient } from "@prisma/client";
4 | import { getReceiverSocketId, io } from "../../socket/socket.js";
5 |
6 | const router = express.Router();
7 | const prisma = new PrismaClient();
8 |
9 | router.post("/send/:receiverId", protectedRoutes, async (req, res) => {
10 | const { receiverId } = req.params;
11 | const { message } = req.body;
12 | const { senderId } = req;
13 |
14 | try {
15 | let conversation = await prisma.conversation.findFirst({
16 | where: {
17 | participantsId: { hasEvery: [senderId, receiverId] },
18 | },
19 | });
20 |
21 | if (!conversation) {
22 | conversation = await prisma.conversation.create({
23 | data: {
24 | participantsId: [senderId, receiverId],
25 | },
26 | });
27 | }
28 |
29 | const previousMessageIds = conversation.messagesId;
30 |
31 | const newMessage = await prisma.message.create({
32 | data: {
33 | body: message,
34 | senderId: senderId,
35 | receiverId: receiverId,
36 | },
37 | });
38 |
39 | if (newMessage) {
40 | const data = await prisma.conversation.update({
41 | where: {
42 | conversationId: conversation.conversationId,
43 | },
44 | data: {
45 | messagesId: [...previousMessageIds, newMessage.messageId],
46 | },
47 | include : {
48 | messages : true
49 | }
50 | });
51 |
52 | const receiverSocketId = getReceiverSocketId(receiverId);
53 | if(receiverSocketId){
54 | io.to(receiverSocketId).emit("newMessage", newMessage);
55 | }
56 |
57 | return res.json({
58 | message: "message sent",
59 | messages : data.messages
60 | });
61 | }
62 |
63 | } catch (error) {
64 | res.status(500).json({
65 | error : "Internal Server Error"
66 | })
67 | }
68 | });
69 |
70 | router.get("/:userToChatWith", protectedRoutes, async (req, res) => {
71 | const { userToChatWith } = req.params;
72 | const { senderId } = req;
73 |
74 | try {
75 | const conversation = await prisma.conversation.findFirst({
76 | where: {
77 | participantsId: { hasEvery: [senderId, userToChatWith] },
78 | },
79 | select: { messages: true },
80 | });
81 |
82 | if (!conversation) {
83 | return res.status(403).json({
84 | messages: [],
85 | });
86 | }
87 |
88 | return res.status(200).json({
89 | messages: conversation,
90 | });
91 |
92 | } catch (error) {
93 | res.status(500).json({
94 | message: "Internal Server Error",
95 | });
96 | }
97 | });
98 |
99 | export default router;
--------------------------------------------------------------------------------
/server/routes/user/index.js:
--------------------------------------------------------------------------------
1 | import express from "express";
2 | import protectedRoutes from "../../middleware/protectedRoutes.js";
3 | import { PrismaClient } from "@prisma/client";
4 |
5 | const router = express.Router();
6 | const prisma = new PrismaClient()
7 |
8 | router.get("/", protectedRoutes, async (req, res) => {
9 | const { senderId } = req
10 |
11 | try {
12 | const users = await prisma.user.findMany({
13 | where : {
14 | NOT : {
15 | id : senderId
16 | }
17 | },
18 | select : {
19 | id : true,
20 | username : true,
21 | email : true,
22 | firstname : true,
23 | lastname : true,
24 | profilePic : true
25 | }
26 | })
27 |
28 | if(!users){
29 | return res.status(403).json({
30 | message : "No users found"
31 | })
32 | }
33 |
34 | return res.status(200).json({
35 | message : users
36 | })
37 |
38 | } catch (error) {
39 | res.json(500).json({
40 | error : "Internal Server Error"
41 | })
42 | }
43 | })
44 |
45 | export default router;
--------------------------------------------------------------------------------
/server/schema/index.js:
--------------------------------------------------------------------------------
1 | import zod from "zod";
2 |
3 | const userSchema = zod.object({
4 | username: zod.string(),
5 | password: zod.string().min(6),
6 | email: zod.string().email(),
7 | firstname: zod.string(),
8 | lastname: zod.string(),
9 | gender : zod.string()
10 | });
11 |
12 | const loginSchema = zod.object({
13 | username : zod.string(),
14 | email : zod.string().email(),
15 | password : zod.string().min(6)
16 | })
17 |
18 | export { userSchema, loginSchema };
--------------------------------------------------------------------------------
/server/socket/socket.js:
--------------------------------------------------------------------------------
1 | import { Server } from "socket.io";
2 | import http from "http";
3 | import express from "express";
4 |
5 | const app = express();
6 |
7 | const server = http.createServer(app);
8 | const io = new Server(server, {
9 | cors : {
10 | origin : ["http://localhost:3000", "https://vondroy.onrender.com"],
11 | methods : ["GET", "POST"]
12 | }
13 | });
14 |
15 | const userSocketMap = {};
16 |
17 | export const getReceiverSocketId = (receiverId) => {
18 | return userSocketMap[receiverId]
19 | }
20 |
21 | io.on("connection", (socket) => {
22 | const userId = socket.handshake.query.userId;
23 | if(userId != undefined){
24 | userSocketMap[userId] = socket.id
25 | }
26 |
27 | io.emit("getOnlineUsers", Object.keys(userSocketMap));
28 |
29 | socket.on("disconnect", () => {
30 | delete userSocketMap[userId]
31 | io.emit("getOnlineUsers", Object.keys(userSocketMap));
32 | })
33 | })
34 |
35 | export { app, io, server };
--------------------------------------------------------------------------------
/server/utils/generateToken.js:
--------------------------------------------------------------------------------
1 | import jwt from "jsonwebtoken"
2 |
3 | const genereateTokenandSetcookie = (username, email, res) => {
4 | const token = jwt.sign({username, email}, process.env.JWT_SECRET, {
5 | expiresIn : "15d"
6 | });
7 |
8 | res.cookie("jwt", token, {
9 | maxAge : 15 * 24 * 60 * 60 * 1000,
10 | httpOnly : true,
11 | sameSite : "strict",
12 | secure : process.env.NODE_ENV !== "development"
13 | })
14 | }
15 |
16 | export default genereateTokenandSetcookie;
--------------------------------------------------------------------------------