diff --git a/src/components/Chat.tsx b/src/components/Chat.tsx index 9f47cfea..81aec43a 100644 --- a/src/components/Chat.tsx +++ b/src/components/Chat.tsx @@ -25,7 +25,7 @@ import { useApp } from '@/context/AppContext'; import useChatUtils from '@/lib/chatSocket'; import MessageStatus from '@/components/Chat/MessageStatus'; import { useNotification } from '@/lib/notification'; -import events from '@/constants'; +import events from '@/shared/constants/constants'; import { createBrowserNotification } from '@/lib/browserNotification'; import chatHelper, { adjustTextareaHeight, getTime } from '../lib/chatHelper'; diff --git a/src/components/Chat/MessageInput.tsx b/src/components/Chat/MessageInput.tsx index 93e7e572..8ba42960 100644 --- a/src/components/Chat/MessageInput.tsx +++ b/src/components/Chat/MessageInput.tsx @@ -4,7 +4,7 @@ import { Icon } from '@iconify/react'; import EmojiPicker from './EmojiPicker'; import useKeyPress, { ShortcutFlags } from '@/hooks/useKeyPress'; -import events from '@/constants'; +import events from '@/shared/constants/constants'; import { useSocket } from '@/context/SocketContext'; import { useChat } from '@/context/ChatContext'; diff --git a/src/components/NavBar.tsx b/src/components/NavBar.tsx index 9acd1d66..8631dc46 100644 --- a/src/components/NavBar.tsx +++ b/src/components/NavBar.tsx @@ -13,7 +13,7 @@ import { useSocket } from '@/context/SocketContext'; import { useApp } from '@/context/AppContext'; // Lib -import constants from '@/constants'; +import constants from '@/shared/constants/constants'; import { IsActiveType } from '@/types/types'; import Image from 'next/image'; diff --git a/src/components/SignupAnonUser.tsx b/src/components/SignupAnonUser.tsx index 3f6ec52b..6e833740 100644 --- a/src/components/SignupAnonUser.tsx +++ b/src/components/SignupAnonUser.tsx @@ -2,7 +2,7 @@ import React, { RefObject, useRef, useState } from 'react'; import { AxiosError } from 'axios'; import { api } from '@/lib/axios'; -import statusCodes from '@/httpStatusCodes'; +import statusCodes from '@/shared/constants/httpStatusCodes'; import { useAuth } from '@/context/AuthContext'; const SignupAnonUser = () => { diff --git a/src/lib/chatSocket.ts b/src/lib/chatSocket.ts index 15a1dc1c..8ecc9d68 100644 --- a/src/lib/chatSocket.ts +++ b/src/lib/chatSocket.ts @@ -1,7 +1,7 @@ /** * @typedef {import('socket.io-client').Socket} Socket */ -import events from '@/constants'; +import events from '@/shared/constants/constants'; import { MessageType } from '@/types/types'; import { Socket } from 'socket.io-client'; diff --git a/src/pages/anonymous.tsx b/src/pages/anonymous.tsx index 89484d2f..1759fb65 100644 --- a/src/pages/anonymous.tsx +++ b/src/pages/anonymous.tsx @@ -8,7 +8,7 @@ import { } from 'react'; import { useRouter } from 'next/navigation'; -import events from '@/constants'; +import events from '@/shared/constants/constants'; import { Dropdown, IconButton, Tooltip, Whisper } from 'rsuite'; import { Icon } from '@iconify/react'; diff --git a/src/pages/api/server/index.ts b/src/pages/api/server/index.ts index ae4c794a..a8533a51 100644 --- a/src/pages/api/server/index.ts +++ b/src/pages/api/server/index.ts @@ -4,10 +4,10 @@ import { Server, Socket } from 'socket.io'; import type { Server as HTTPServer } from 'http'; import type { Socket as NetSocket } from 'net'; -import * as handlers from '@/handlers'; -import executeHandlers from '@/handlerDecorator'; +import * as handlers from '@/server/handlers'; +import executeHandlers from '@/server/handlerDecorator'; -import connectMongo from '@/service/mongo'; +import connectMongo from '@/server/service/mongo'; interface SocketServer extends HTTPServer { io?: Server | undefined; diff --git a/src/pages/api/user/index.ts b/src/pages/api/user/index.ts index a59d9204..b89e5e1f 100644 --- a/src/pages/api/user/index.ts +++ b/src/pages/api/user/index.ts @@ -1,9 +1,9 @@ import { NextApiRequest, NextApiResponse } from 'next'; import axios from 'axios'; -import statusCodes from '@/httpStatusCodes'; -import { UserModel } from '@/models/UserModel'; -import { emailValidator } from '@/lib/userAPI'; +import statusCodes from '@/shared/constants/httpStatusCodes'; +import { UserModel } from '@/server/models/UserModel'; +import { emailValidator } from '@/server/lib/userAPI'; let accessToken = process.env.ACCESS_TOKEN; const domain = process.env.DOMAIN; diff --git a/src/pages/api/user/login.ts b/src/pages/api/user/login.ts index 21cab94d..c35070fb 100644 --- a/src/pages/api/user/login.ts +++ b/src/pages/api/user/login.ts @@ -1,8 +1,8 @@ import { NextApiRequest, NextApiResponse } from 'next'; -import { UserModel } from '@/models/UserModel'; -import { createUserWithAutoId, emailValidator } from '@/lib/userAPI'; -import statusCodes from '@/httpStatusCodes'; +import { UserModel } from '@/server/models/UserModel'; +import { createUserWithAutoId, emailValidator } from '@/server/lib/userAPI'; +import statusCodes from '@/shared/constants/httpStatusCodes'; export default async (req: NextApiRequest, res: NextApiResponse) => { emailValidator(req, res, async () => { diff --git a/src/pages/api/user/profile/[email].ts b/src/pages/api/user/profile/[email].ts index 0f774c2c..27409de5 100644 --- a/src/pages/api/user/profile/[email].ts +++ b/src/pages/api/user/profile/[email].ts @@ -1,8 +1,8 @@ import { NextApiRequest, NextApiResponse } from 'next'; -import { UserModel } from '@/models/UserModel'; -import { emailValidator } from '@/lib/userAPI'; -import statusCodes from '@/httpStatusCodes'; +import { UserModel } from '@/server/models/UserModel'; +import { emailValidator } from '@/server/lib/userAPI'; +import statusCodes from '@/shared/constants/httpStatusCodes'; export default async (req: NextApiRequest, res: NextApiResponse) => { if (req.method === 'GET') { diff --git a/src/pages/api/user/profile/index.ts b/src/pages/api/user/profile/index.ts index 64cda929..36f12332 100644 --- a/src/pages/api/user/profile/index.ts +++ b/src/pages/api/user/profile/index.ts @@ -1,8 +1,8 @@ import { NextApiRequest, NextApiResponse } from 'next'; -import { UserModel } from '@/models/UserModel'; -import { emailValidator } from '@/lib/userAPI'; -import statusCodes from '@/httpStatusCodes'; +import { UserModel } from '@/server/models/UserModel'; +import { emailValidator } from '@/server/lib/userAPI'; +import statusCodes from '@/shared/constants/httpStatusCodes'; export default async (req: NextApiRequest, res: NextApiResponse) => { if (req.method === 'POST') { diff --git a/src/pages/api/verification/index.ts b/src/pages/api/verification/index.ts index 49aa926b..cfc93cb3 100644 --- a/src/pages/api/verification/index.ts +++ b/src/pages/api/verification/index.ts @@ -1,7 +1,7 @@ import { NextApiRequest, NextApiResponse } from 'next'; import { ApiError } from 'next/dist/server/api-utils'; -import httpStatusCodes from '@/httpStatusCodes'; +import httpStatusCodes from '@/shared/constants/httpStatusCodes'; import sendMail from '@/service/mailService'; export default async (req: NextApiRequest, res: NextApiResponse) => { diff --git a/src/pages/searching.tsx b/src/pages/searching.tsx index 01c9875a..d95f24c3 100644 --- a/src/pages/searching.tsx +++ b/src/pages/searching.tsx @@ -10,7 +10,7 @@ import { useAuth } from '@/context/AuthContext'; import { useApp } from '@/context/AppContext'; import { useChat } from '@/context/ChatContext'; -import events from '@/constants'; +import events from '@/shared/constants/constants'; import { useNotification } from '@/lib/notification'; import { createBrowserNotification } from '@/lib/browserNotification'; diff --git a/src/handlerDecorator.ts b/src/server/handlerDecorator.ts similarity index 100% rename from src/handlerDecorator.ts rename to src/server/handlerDecorator.ts diff --git a/src/handlers.ts b/src/server/handlers.ts similarity index 99% rename from src/handlers.ts rename to src/server/handlers.ts index 7357d002..c18c0000 100644 --- a/src/handlers.ts +++ b/src/server/handlers.ts @@ -1,6 +1,6 @@ import { Server, Socket } from 'socket.io'; -import constants from '@/constants'; +import constants from '@/shared/constants/constants'; import { ChatIdType, OnlineStatus } from '@/types/types'; import { chatExists, @@ -17,7 +17,7 @@ import { delWaitingUser, seenMessage, addMessage, -} from '@/lib/lib'; +} from '@/server/lib/lib'; export const CloseChatHandler = (socket: Socket) => { socket.on( diff --git a/src/lib/lib.ts b/src/server/lib/lib.ts similarity index 98% rename from src/lib/lib.ts rename to src/server/lib/lib.ts index 58240a50..fd77e425 100644 --- a/src/lib/lib.ts +++ b/src/server/lib/lib.ts @@ -2,9 +2,9 @@ import { Socket } from 'socket.io'; import mongoose from 'mongoose'; import CryptoJS from 'crypto-js'; -import ActiveUser from '../models/ActiveUserModel'; -import Chat from '../models/ChatModel'; -import Message from '../models/MessageModel'; +import ActiveUser from '@/server/models/ActiveUserModel'; +import Chat from '@/server/models/ChatModel'; +import Message from '@/server/models/MessageModel'; import { ChatIdType, activeUserIdType, diff --git a/src/lib/userAPI.ts b/src/server/lib/userAPI.ts similarity index 84% rename from src/lib/userAPI.ts rename to src/server/lib/userAPI.ts index ffba8b7f..350c7b1a 100644 --- a/src/lib/userAPI.ts +++ b/src/server/lib/userAPI.ts @@ -3,9 +3,9 @@ import { NextApiRequest, NextApiResponse } from 'next'; import validator from 'validator'; import { v4 as uuidv4 } from 'uuid'; -import { UserModel } from '@/models/UserModel'; -import statusCodes from '@/httpStatusCodes'; -import connectMongo from '@/service/mongo'; +import { UserModel } from '@/server/models/UserModel'; +import statusCodes from '@/shared/constants/httpStatusCodes'; +import connectMongo from '@/server/service/mongo'; export const createUserWithAutoId = async (email: string) => { // Logic to create a new user with an autogenerated ID diff --git a/src/models/ActiveUserModel.ts b/src/server/models/ActiveUserModel.ts similarity index 100% rename from src/models/ActiveUserModel.ts rename to src/server/models/ActiveUserModel.ts diff --git a/src/models/ChatModel.ts b/src/server/models/ChatModel.ts similarity index 100% rename from src/models/ChatModel.ts rename to src/server/models/ChatModel.ts diff --git a/src/models/MessageModel.ts b/src/server/models/MessageModel.ts similarity index 100% rename from src/models/MessageModel.ts rename to src/server/models/MessageModel.ts diff --git a/src/models/UserModel.ts b/src/server/models/UserModel.ts similarity index 100% rename from src/models/UserModel.ts rename to src/server/models/UserModel.ts diff --git a/src/service/mongo.ts b/src/server/service/mongo.ts similarity index 100% rename from src/service/mongo.ts rename to src/server/service/mongo.ts diff --git a/src/constants.ts b/src/shared/constants/constants.ts similarity index 100% rename from src/constants.ts rename to src/shared/constants/constants.ts diff --git a/src/httpStatusCodes.ts b/src/shared/constants/httpStatusCodes.ts similarity index 100% rename from src/httpStatusCodes.ts rename to src/shared/constants/httpStatusCodes.ts diff --git a/src/shared/lib/.gitkeep b/src/shared/lib/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/src/sound.d.ts b/src/types/sound.d.ts similarity index 100% rename from src/sound.d.ts rename to src/types/sound.d.ts