From 3128ef6578de80eeb30751607b109e91597da5f2 Mon Sep 17 00:00:00 2001 From: prakhar singh Date: Mon, 30 Sep 2024 00:53:04 +0530 Subject: [PATCH 1/2] all comitted --- .env-sample | 7 ------- backend/db/connectMongoDB.js | 1 + backend/server.js | 9 --------- frontend/src/pages/profile/ProfilePage.jsx | 2 +- package.json | 4 ++-- 5 files changed, 4 insertions(+), 19 deletions(-) delete mode 100644 .env-sample diff --git a/.env-sample b/.env-sample deleted file mode 100644 index 965e893..0000000 --- a/.env-sample +++ /dev/null @@ -1,7 +0,0 @@ -MONGO_URI= -PORT= -JWT_SECRET= -NODE_ENV= -CLOUDINARY_CLOUD_NAME= -CLOUDINARY_API_KEY= -CLOUDINARY_API_SECRET= \ No newline at end of file diff --git a/backend/db/connectMongoDB.js b/backend/db/connectMongoDB.js index 02749dd..47f2ee1 100644 --- a/backend/db/connectMongoDB.js +++ b/backend/db/connectMongoDB.js @@ -1,5 +1,6 @@ import mongoose from "mongoose"; + const connectMongoDB = async () => { try { const conn = await mongoose.connect(process.env.MONGO_URI); diff --git a/backend/server.js b/backend/server.js index 10551a3..d5dc0b4 100644 --- a/backend/server.js +++ b/backend/server.js @@ -1,4 +1,3 @@ -import path from "path"; import express from "express"; import dotenv from "dotenv"; import cookieParser from "cookie-parser"; @@ -21,7 +20,6 @@ cloudinary.config({ const app = express(); const PORT = process.env.PORT || 5000; -const __dirname = path.resolve(); app.use(express.json({ limit: "5mb" })); // to parse req.body // limit shouldn't be too high to prevent DOS @@ -34,13 +32,6 @@ app.use("/api/users", userRoutes); app.use("/api/posts", postRoutes); app.use("/api/notifications", notificationRoutes); -if (process.env.NODE_ENV === "production") { - app.use(express.static(path.join(__dirname, "/frontend/dist"))); - - app.get("*", (req, res) => { - res.sendFile(path.resolve(__dirname, "frontend", "dist", "index.html")); - }); -} app.listen(PORT, () => { console.log(`Server is running on port ${PORT}`); diff --git a/frontend/src/pages/profile/ProfilePage.jsx b/frontend/src/pages/profile/ProfilePage.jsx index a2b2e0a..0a3fa18 100644 --- a/frontend/src/pages/profile/ProfilePage.jsx +++ b/frontend/src/pages/profile/ProfilePage.jsx @@ -175,7 +175,7 @@ const ProfilePage = () => { <> Date: Mon, 30 Sep 2024 23:46:31 +0530 Subject: [PATCH 2/2] not required --- LICENSE | 21 - UI-DESIGN-STEPS.md | 1343 -------------------------------------------- 2 files changed, 1364 deletions(-) delete mode 100644 LICENSE delete mode 100644 UI-DESIGN-STEPS.md diff --git a/LICENSE b/LICENSE deleted file mode 100644 index f744acd..0000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2024 Burak - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/UI-DESIGN-STEPS.md b/UI-DESIGN-STEPS.md deleted file mode 100644 index 172f5a5..0000000 --- a/UI-DESIGN-STEPS.md +++ /dev/null @@ -1,1343 +0,0 @@ -# Install Tailwind && Daisy UI (check out the docs) - -# Update Tailwind config file for daisy UI - -```js -import daisyui from "daisyui"; -import daisyUIThemes from "daisyui/src/theming/themes"; -/** @type {import('tailwindcss').Config} */ -export default { - content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"], - theme: { - extend: {}, - }, - plugins: [daisyui], - - daisyui: { - themes: [ - "light", - { - black: { - ...daisyUIThemes["black"], - primary: "rgb(29, 155, 240)", - secondary: "rgb(24, 24, 24)", - }, - }, - ], - }, -}; -``` - -# Add data-theme="black" to the HTML TAG - -```html - - - - - - - Vite + React - - -
- - - -``` - -# Install React Router and React Icons - -```bash - npm install react-router-dom react-icons -``` - -# SETUP REACT ROUTER - -- Wrap the App component with BrowserRouter in main.js - -# APP.jsx - -```jsx -function App() { - return ( -
- - } /> - } /> - } /> - -
- ); -} -``` - -# SIGN UP PAGE => /src/pages/auth/signup/SignUpPage.jsx - -```jsx -import { Link } from "react-router-dom"; -import { useState } from "react"; - -import XSvg from "../../../components/svgs/X"; - -import { MdOutlineMail } from "react-icons/md"; -import { FaUser } from "react-icons/fa"; -import { MdPassword } from "react-icons/md"; -import { MdDriveFileRenameOutline } from "react-icons/md"; - -const SignUpPage = () => { - const [formData, setFormData] = useState({ - email: "", - username: "", - fullName: "", - password: "", - }); - - const handleSubmit = (e) => { - e.preventDefault(); - console.log(formData); - }; - - const handleInputChange = (e) => { - setFormData({ ...formData, [e.target.name]: e.target.value }); - }; - - const isError = false; - - return ( -
-
- -
-
-
- -

Join today.

- -
- - -
- - - {isError &&

Something went wrong

} - -
-

Already have an account?

- - - -
-
-
- ); -}; -export default SignUpPage; -``` - -# XSvg Component => /src/components/svgs/X.jsx - -```jsx -const XSvg = (props) => ( - -); -export default XSvg; -``` - -# LOGIN PAGE => /src/pages/auth/login/LoginPage.jsx - -```jsx -import { useState } from "react"; -import { Link } from "react-router-dom"; - -import XSvg from "../../../components/svgs/X"; - -import { MdOutlineMail } from "react-icons/md"; -import { MdPassword } from "react-icons/md"; - -const LoginPage = () => { - const [formData, setFormData] = useState({ - username: "", - password: "", - }); - - const handleSubmit = (e) => { - e.preventDefault(); - console.log(formData); - }; - - const handleInputChange = (e) => { - setFormData({ ...formData, [e.target.name]: e.target.value }); - }; - - const isError = false; - - return ( -
-
- -
-
-
- -

{"Let's"} go.

- - - - - {isError &&

Something went wrong

} - -
-

{"Don't"} have an account?

- - - -
-
-
- ); -}; -export default LoginPage; -``` - -# HOME PAGE => /src/pages/home/HomePage.jsx - -```jsx -import { useState } from "react"; - -import Posts from "../../components/common/Posts"; -import CreatePost from "./CreatePost"; - -const HomePage = () => { - const [feedType, setFeedType] = useState("forYou"); - - return ( - <> -
- {/* Header */} -
-
setFeedType("forYou")} - > - For you - {feedType === "forYou" && ( -
- )} -
-
setFeedType("following")} - > - Following - {feedType === "following" && ( -
- )} -
-
- - {/* CREATE POST INPUT */} - - - {/* POSTS */} - -
- - ); -}; -export default HomePage; -``` - -## Temporarily add CreatePost and Posts components with boilerplate code for now, we will update them in a second - -- /src/pages/home/CreatePost.jsx -- /src/components/common/Posts.jsx - -# SIDEBAR COMPONENT => /src/components/common/Sidebar.jsx - -```jsx -import XSvg from "../svgs/X"; - -import { MdHomeFilled } from "react-icons/md"; -import { IoNotifications } from "react-icons/io5"; -import { FaUser } from "react-icons/fa"; -import { Link } from "react-router-dom"; -import { BiLogOut } from "react-icons/bi"; - -const Sidebar = () => { - const data = { - fullName: "John Doe", - username: "johndoe", - profileImg: "/avatars/boy1.png", - }; - - return ( -
-
- - - -
    -
  • - - - Home - -
  • -
  • - - - Notifications - -
  • - -
  • - - - Profile - -
  • -
- {data && ( - -
-
- -
-
-
-
-

{data?.fullName}

-

@{data?.username}

-
- -
- - )} -
-
- ); -}; -export default Sidebar; -``` - -# ADD SOME DUMMY DATA => /src/utils/db/dummy.js - -```js -export const POSTS = [ - { - _id: "1", - text: "Let's build a fullstack WhatsApp clone with NEXT.JS 14 ๐Ÿ˜", - img: "/posts/post1.png", - user: { - username: "johndoe", - profileImg: "/avatars/boy1.png", - fullName: "John Doe", - }, - comments: [ - { - _id: "1", - text: "Nice Tutorial", - user: { - username: "janedoe", - profileImg: "/avatars/girl1.png", - fullName: "Jane Doe", - }, - }, - ], - likes: ["6658s891", "6658s892", "6658s893", "6658s894"], - }, - { - _id: "2", - text: "How you guys doing? ๐Ÿ˜Š", - user: { - username: "johndoe", - profileImg: "/avatars/boy2.png", - fullName: "John Doe", - }, - comments: [ - { - _id: "1", - text: "Nice Tutorial", - user: { - username: "janedoe", - profileImg: "/avatars/girl2.png", - fullName: "Jane Doe", - }, - }, - ], - likes: ["6658s891", "6658s892", "6658s893", "6658s894"], - }, - { - _id: "3", - text: "Astronaut in a room of drawers, generated by Midjourney. ๐Ÿš€", - img: "/posts/post2.png", - user: { - username: "johndoe", - profileImg: "/avatars/boy3.png", - fullName: "John Doe", - }, - comments: [], - likes: ["6658s891", "6658s892", "6658s893", "6658s894", "6658s895", "6658s896"], - }, - { - _id: "4", - text: "I'm learning GO this week. Any tips? ๐Ÿค”", - img: "/posts/post3.png", - user: { - username: "johndoe", - profileImg: "/avatars/boy3.png", - fullName: "John Doe", - }, - comments: [ - { - _id: "1", - text: "Nice Tutorial", - user: { - username: "janedoe", - profileImg: "/avatars/girl3.png", - fullName: "Jane Doe", - }, - }, - ], - likes: [ - "6658s891", - "6658s892", - "6658s893", - "6658s894", - "6658s895", - "6658s896", - "6658s897", - "6658s898", - "6658s899", - ], - }, -]; - -export const USERS_FOR_RIGHT_PANEL = [ - { - _id: "1", - fullName: "John Doe", - username: "johndoe", - profileImg: "/avatars/boy2.png", - }, - { - _id: "2", - fullName: "Jane Doe", - username: "janedoe", - profileImg: "/avatars/girl1.png", - }, - { - _id: "3", - fullName: "Bob Doe", - username: "bobdoe", - profileImg: "/avatars/boy3.png", - }, - { - _id: "4", - fullName: "Daisy Doe", - username: "daisydoe", - profileImg: "/avatars/girl2.png", - }, -]; -``` - -# RIGHT PANEL COMPONENT => /src/components/common/RightPanel.jsx - -```jsx -import { Link } from "react-router-dom"; -import RightPanelSkeleton from "../skeletons/RightPanelSkeleton"; -import { USERS_FOR_RIGHT_PANEL } from "../../utils/db/dummy"; - -const RightPanel = () => { - const isLoading = false; - - return ( -
-
-

Who to follow

-
- {/* item */} - {isLoading && ( - <> - - - - - - )} - {!isLoading && - USERS_FOR_RIGHT_PANEL?.map((user) => ( - -
-
-
- -
-
-
- - {user.fullName} - - @{user.username} -
-
-
- -
- - ))} -
-
-
- ); -}; -export default RightPanel; -``` - -# RIGHT PANEL SKELETON => /src/components/skeletons/RightPanelSkeleton.jsx - -```jsx -const RightPanelSkeleton = () => { - return ( -
-
-
-
-
-
-
-
-
-
-
-
- ); -}; -export default RightPanelSkeleton; -``` - -# CREATE POST COMPONENT => /src/pages/home/CreatePost.jsx - -```jsx -import { CiImageOn } from "react-icons/ci"; -import { BsEmojiSmileFill } from "react-icons/bs"; -import { useRef, useState } from "react"; -import { IoCloseSharp } from "react-icons/io5"; - -const CreatePost = () => { - const [text, setText] = useState(""); - const [img, setImg] = useState(null); - - const imgRef = useRef(null); - - const isPending = false; - const isError = false; - - const data = { - profileImg: "/avatars/boy1.png", - }; - - const handleSubmit = (e) => { - e.preventDefault(); - alert("Post created successfully"); - }; - - const handleImgChange = (e) => { - const file = e.target.files[0]; - if (file) { - const reader = new FileReader(); - reader.onload = () => { - setImg(reader.result); - }; - reader.readAsDataURL(file); - } - }; - - return ( -
-
-
- -
-
-
-