From 5a2b291bdd6f9c611a1fcd9ae3280903623e21b0 Mon Sep 17 00:00:00 2001 From: QkoSad Date: Mon, 16 Jun 2025 17:42:11 +0300 Subject: [PATCH] no idea what i did --- .gitignore | 2 ++ client/src/components/layout/Navbar.tsx | 3 +-- client/src/components/posts/PostForm.tsx | 2 +- .../components/profile-forms/ProfileForm.tsx | 8 +++---- client/src/reducers/post.ts | 2 +- mongo/mongo-init.js | 3 --- server/package-lock.json | 21 +++++++++++++++++++ server/package.json | 1 + server/server.ts | 9 +++++--- start_in_tmux.sh | 5 ++--- 10 files changed, 39 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index d0158b5..f17f33f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ node_modules start_in_tmux.sh default.json production.json +bin +obj diff --git a/client/src/components/layout/Navbar.tsx b/client/src/components/layout/Navbar.tsx index e121c3a..d680396 100755 --- a/client/src/components/layout/Navbar.tsx +++ b/client/src/components/layout/Navbar.tsx @@ -1,4 +1,3 @@ -import React from "react"; import { Link } from "react-router-dom"; import { logOut } from "../../reducers/auth"; import { useAppDispatch, useAppSelector } from "../../utils/hooks"; @@ -69,7 +68,7 @@ const Navbar = () => { - {/*Icon for big dislay*/} + {/*Icon for big display*/} {/*LOGO link for bi display*/} { // then build our profileData if (!loading && profile) { const profileData: any = { ...initialState }; - // cant figure out how to type key to be keyof profile so they are any now + // can't figure out how to type key to be keyof profile so they are any now for (const key in profile) { if (key in profileData) profileData[key] = profile[key]; } @@ -215,7 +215,7 @@ const ProfileForm = () => { - Please use comma separeted values (eg. HTML, CSS, JavaScript, PHP) + Please use comma separated values (eg. HTML, CSS, JavaScript, PHP) @@ -240,7 +240,7 @@ const ProfileForm = () => { labelId="status" name="status" required - placeholder="Select Profesional status" + placeholder="Select Professional status" defaultValue={""} > None @@ -258,7 +258,7 @@ const ProfileForm = () => { - Select Profesional Status + Select Professional Status diff --git a/client/src/reducers/post.ts b/client/src/reducers/post.ts index ae918c3..648775e 100755 --- a/client/src/reducers/post.ts +++ b/client/src/reducers/post.ts @@ -7,7 +7,7 @@ interface postState { post: Post | null; loading: boolean; error: {}; - //Todo erros + //Todo errors } const initialState: postState = { posts: [], diff --git a/mongo/mongo-init.js b/mongo/mongo-init.js index fad184a..48a0512 100644 --- a/mongo/mongo-init.js +++ b/mongo/mongo-init.js @@ -10,6 +10,3 @@ db.createUser({ }); db.createCollection("todos"); - -db.todos.insert({ text: "Write code", done: true }); -db.todos.insert({ text: "Learn about containers", done: false }); diff --git a/server/package-lock.json b/server/package-lock.json index 78d0d47..1e1cea1 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -26,6 +26,7 @@ "devDependencies": { "@types/bcryptjs": "^2.4.2", "@types/config": "^3.3.0", + "@types/cors": "^2.8.17", "@types/express": "^4.17.17", "@types/gravatar": "^1.8.3", "@types/jsonwebtoken": "^9.0.2", @@ -116,6 +117,16 @@ "@types/node": "*" } }, + "node_modules/@types/cors": { + "version": "2.8.17", + "resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.17.tgz", + "integrity": "sha512-8CGDvrBj1zgo2qE+oS3pOCyYNqCPryMWY2bGfwA0dcfopWGgxs+78df0Rs3rc9THP4JkOhLsAa+15VdpAqkcUA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/express": { "version": "4.17.17", "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.17.tgz", @@ -552,6 +563,7 @@ "version": "2.8.5", "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", + "license": "MIT", "dependencies": { "object-assign": "^4", "vary": "^1" @@ -2209,6 +2221,15 @@ "@types/node": "*" } }, + "@types/cors": { + "version": "2.8.17", + "resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.17.tgz", + "integrity": "sha512-8CGDvrBj1zgo2qE+oS3pOCyYNqCPryMWY2bGfwA0dcfopWGgxs+78df0Rs3rc9THP4JkOhLsAa+15VdpAqkcUA==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, "@types/express": { "version": "4.17.17", "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.17.tgz", diff --git a/server/package.json b/server/package.json index 445bcc9..03e0322 100644 --- a/server/package.json +++ b/server/package.json @@ -27,6 +27,7 @@ "devDependencies": { "@types/bcryptjs": "^2.4.2", "@types/config": "^3.3.0", + "@types/cors": "^2.8.17", "@types/express": "^4.17.17", "@types/gravatar": "^1.8.3", "@types/jsonwebtoken": "^9.0.2", diff --git a/server/server.ts b/server/server.ts index ad7e537..e8b51db 100644 --- a/server/server.ts +++ b/server/server.ts @@ -1,10 +1,13 @@ import express from "express"; - import connectDB from "./config/db"; - import path from "path"; +import cors from "cors"; + const app = express(); +// add cors otherwise fronend cannot access backedn +app.use(cors()); + connectDB(); app.use(express.json()); @@ -18,7 +21,7 @@ app.use("/api/posts", require("./routers/api/posts")); if (process.env.NODE_ENV === "production") { console.log("in production"); app.use(express.static("client/build")); - app.get("*", (req, res) => [ + app.get("*", (_, res) => [ res.sendFile(path.resolve(__dirname, "client", "build", "index.html")), ]); } diff --git a/start_in_tmux.sh b/start_in_tmux.sh index b9844de..ecfe269 100644 --- a/start_in_tmux.sh +++ b/start_in_tmux.sh @@ -3,11 +3,10 @@ # systemctl start mongodb.service sn=devCon -cd ~/dev-connect/ tmux new-session -s "$sn" -n etc -d "nvim .; exec zsh" -cd ~/dev-connect/client +cd client tmux new-window -t "$sn:2" -n "client" "npm run dev" -cd ~/dev-connect/server +cd ../server tmux new-window -t "$sn:3" -n "server" "npm run server" tmux select-window -t "$sn:1"