diff --git a/.gitignore b/.gitignore
index 7a6bbdc..662c3e1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,4 @@ node_modules
App.css
start_in_tmux.sh
default.json
+production.json
diff --git a/client/.gitignore b/client/.gitignore
deleted file mode 100644
index 4d29575..0000000
--- a/client/.gitignore
+++ /dev/null
@@ -1,23 +0,0 @@
-# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
-
-# dependencies
-/node_modules
-/.pnp
-.pnp.js
-
-# testing
-/coverage
-
-# production
-/build
-
-# misc
-.DS_Store
-.env.local
-.env.development.local
-.env.test.local
-.env.production.local
-
-npm-debug.log*
-yarn-debug.log*
-yarn-error.log*
diff --git a/client/package-lock.json b/client/package-lock.json
index 70796fd..bdbd150 100644
--- a/client/package-lock.json
+++ b/client/package-lock.json
@@ -13,7 +13,7 @@
"@mui/icons-material": "^6.1.1",
"@mui/material": "^6.1.1",
"@reduxjs/toolkit": "^1.9.5",
- "@testing-library/jest-dom": "^5.16.5",
+ "@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"@types/jest": "^27.5.2",
@@ -142,7 +142,7 @@
"@babel/helper-validator-option": "^7.24.8",
"browserslist": "^4.23.1",
"lru-cache": "^5.1.1",
- "semver": "^6.3.0"
+ "semver": "^6.3.1"
},
"engines": {
"node": ">=6.9.0"
@@ -175,6 +175,9 @@
},
"engines": {
"node": ">=6.9.0"
+ },
+ "peerDependencies": {
+ "@babel/core": "^7.0.0"
}
},
"node_modules/@babel/helper-plugin-utils": {
@@ -1656,10 +1659,10 @@
"@babel/code-frame": "^7.10.4",
"@babel/runtime": "^7.12.5",
"@types/aria-query": "^5.0.1",
- "aria-query": "^5.0.0",
+ "aria-query": "5.1.3",
"chalk": "^4.1.0",
"dom-accessibility-api": "^0.5.9",
- "lz-string": "^1.4.4",
+ "lz-string": "^1.5.0",
"pretty-format": "^27.0.2"
},
"engines": {
@@ -1809,7 +1812,7 @@
"dev": true,
"license": "MIT",
"dependencies": {
- "@babel/types": "^7.3.0"
+ "@babel/types": "^7.20.7"
}
},
"node_modules/@types/estree": {
@@ -1835,8 +1838,8 @@
"integrity": "sha512-mpT8LJJ4CMeeahobofYWIjFo0xonRS/HfxnVEPMPFSQdGUt1uHCnoPT7Zhb+sjDU2wz0oKV0OLUR0WzrHNgfeA==",
"license": "MIT",
"dependencies": {
- "expect": "^29.0.0",
- "pretty-format": "^29.0.0"
+ "jest-matcher-utils": "^27.0.0",
+ "pretty-format": "^27.0.0"
}
},
"node_modules/@types/parse-json": {
@@ -2027,6 +2030,10 @@
{
"type": "tidelift",
"url": "https://tidelift.com/funding/github/npm/browserslist"
+ },
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/ai"
}
],
"license": "MIT",
@@ -3527,7 +3534,7 @@
"react": "^16.8 || ^17.0 || ^18.0",
"react-dom": "^16.8 || ^17.0 || ^18.0",
"react-native": ">=0.59",
- "redux": "^4"
+ "redux": "^4 || ^5.0.0-beta.0"
},
"peerDependenciesMeta": {
"@types/react": {
diff --git a/client/src/App.js b/client/src/App.js
deleted file mode 100644
index aef9957..0000000
--- a/client/src/App.js
+++ /dev/null
@@ -1,99 +0,0 @@
-import React, { useEffect } from 'react';
-import { BrowserRouter as Router, Route, Routes } from 'react-router-dom';
-
-import Navbar from './components/layout/Navbar';
-import Landing from './components/layout/Landing';
-import Register from './components/auth/Register';
-import Login from './components/auth/Login';
-import Alert from './components/layout/Alert';
-import Dashboard from './components/dashboard/Dashboard';
-import ProfileForm from './components/profile-forms/ProfileForm';
-import AddExperience from './components/profile-forms/AddExperience';
-import AddEducation from './components/profile-forms/AddEducation';
-import Profiles from './components/profiles/Profiles';
-import Profile from './components/profile/Profile';
-import Posts from './components/posts/Posts';
-import Post from './components/post/Post';
-import NotFound from './components/layout/NotFound';
-import PrivateRoute from './components/routing/PrivateRoute';
-
-// Redux
-import { Provider } from 'react-redux';
-import store from './store';
-import { loadUser } from './actions/auth';
-import setAuthToken from './utils/setAuthToken';
-
-import './App.css';
-import { logOut } from './reducers/auth';
-
-// Level - 1
-//
-
-const App = () => {
- useEffect(() => {
- // check for token in LS when app first runs
- if (localStorage.token) {
- // if there is a token set axios headers for all requests
- setAuthToken(localStorage.token);
- }
- // try to fetch a user, if no token or invalid token we
- // will get a 401 response from our API
- store.dispatch(loadUser());
-
- // log user out from all tabs if they log out in one tab
- window.addEventListener("storage", () => {
- if (!localStorage.token) store.dispatch(logOut);
- });
- }, []);
-
- return (
-
-
-
-
-
- } />
- } />
- } />
- } />
- } />
- }
- />
- }
- />
- }
- />
- }
- />
- }
- />
- } />
- } />
- } />
-
-
-
- );
- /*
- return (
-
-
-
- } />
-
-
-
- );*/
-};
-
-export default App;
diff --git a/client/src/actions/alert.js b/client/src/actions/alert.js
deleted file mode 100644
index a409018..0000000
--- a/client/src/actions/alert.js
+++ /dev/null
@@ -1,9 +0,0 @@
-import { v4 as uuidv4 } from 'uuid';
-import {removeAlert, setAlert } from '../reducers/alert';
-
-export const createAlert = (msg, alertType, timeout = 5000) => dispatch => {
- const id = uuidv4();
- dispatch(setAlert({ msg, alertType, id }));
-
- setTimeout(() => dispatch(removeAlert(id)), timeout);
-};
diff --git a/client/src/actions/auth.js b/client/src/actions/auth.js
deleted file mode 100644
index 6f9cfc5..0000000
--- a/client/src/actions/auth.js
+++ /dev/null
@@ -1,68 +0,0 @@
-import api from "../utils/api";
-import { createAlert } from "./alert";
-import {
- loginSucces,
- authError,
- registerSuccess,
- logOut,
- userLoaded,
-} from "../reducers/auth";
-/*
- NOTE: we don't need a config object for axios as the
- default headers in axios are already Content-Type: application/json
- also axios stringifies and parses JSON for you, so no need for
- JSON.stringify or JSON.parse
-*/
-
-export const login = (email, password) => async (dispatch) => {
- const body = { email, password };
- try {
- const res = await api.post("/auth", body);
-
- dispatch(loginSucces(res.data));
-
- dispatch(loadUser());
- } catch (err) {
- const errors = err.response.data.errors;
- if (errors) {
- errors.forEach((error) => dispatch(createAlert(error.msg, "danger")));
- }
- dispatch({
- type: "auth/loginFail",
- });
- }
-};
-
-export const loadUser = () => async (dispatch) => {
- try {
- const res = await api.get("/auth");
-
- dispatch(userLoaded(res.data));
- } catch (err) {
- dispatch(authError());
- }
-};
-
-// Register User
-export const register = (formData) => async (dispatch) => {
- try {
- const res = await api.post("/users", formData);
-
- dispatch(registerSuccess(res.data));
- dispatch(loadUser());
- } catch (err) {
- const errors = err.response.data.errors;
-
- if (errors) {
- errors.forEach((error) => dispatch(createAlert(error.msg, "danger")));
- }
-
- dispatch({
- type: "auth/registerFail",
- });
- }
-};
-
-export const logout = () => async (dispatch) => {
- dispatch(logOut);
-};
diff --git a/client/src/actions/post.js b/client/src/actions/post.js
deleted file mode 100644
index 23d6666..0000000
--- a/client/src/actions/post.js
+++ /dev/null
@@ -1,124 +0,0 @@
-import {
- removeComment,
- addCommentAction,
- updateLikes,
- postError,
- deletePostAction,
- getPostAction,
- getPostsAction,
- addPostAction,
-} from "../reducers/post";
-import api from "../utils/api";
-import { createAlert } from "./alert";
-
-// Get posts
-export const getPosts = () => async (dispatch) => {
- try {
- const res = await api.get("/posts");
-
- dispatch(getPostsAction(res.data));
- } catch (err) {
- dispatch(
- postError({ msg: err.response.statusText, status: err.response.status })
- );
- }
-};
-
-// Add like
-export const addLike = (id) => async (dispatch) => {
- try {
- const res = await api.put(`/posts/like/${id}`);
-
- dispatch(updateLikes({ id, likes: res.data }));
- } catch (err) {
- dispatch(
- postError({ msg: err.response.statusText, status: err.response.status })
- );
- }
-};
-
-// Remove like
-export const removeLike = (id) => async (dispatch) => {
- try {
- const res = await api.put(`/posts/unlike/${id}`);
-
- dispatch(updateLikes({ id, likes: res.data }));
- } catch (err) {
- dispatch(
- postError({ msg: err.response.statusText, status: err.response.status })
- );
- }
-};
-
-// Delete post
-export const deletePost = (id) => async (dispatch) => {
- try {
- await api.delete(`/posts/${id}`);
-
- dispatch(deletePostAction(id));
-
- dispatch(createAlert("Post Removed", "success"));
- } catch (err) {
- dispatch(
- postError({ msg: err.response.statusText, status: err.response.status })
- );
- }
-};
-
-// Add post
-export const addPost = (formData) => async (dispatch) => {
- try {
- const res = await api.post("/posts", formData);
-
- dispatch(addPostAction(res.data));
-
- dispatch(createAlert("Post Created", "success"));
- } catch (err) {
- dispatch(
- postError({ msg: err.response.statusText, status: err.response.status })
- );
- }
-};
-
-// Get post
-export const getPost = (id) => async (dispatch) => {
- try {
- const res = await api.get(`/posts/${id}`);
-
- dispatch(getPostAction(res.data));
- } catch (err) {
- dispatch(
- postError({ msg: err.response.statusText, status: err.response.status })
- );
- }
-};
-
-// Add comment
-export const addComment = (postId, formData) => async (dispatch) => {
- try {
- const res = await api.post(`/posts/comment/${postId}`, formData);
-
- dispatch(addCommentAction(res.data));
-
- dispatch(createAlert("Comment Added", "success"));
- } catch (err) {
- dispatch(
- postError({ msg: err.response.statusText, status: err.response.status })
- );
- }
-};
-
-// Delete comment
-export const deleteComment = (postId, commentId) => async (dispatch) => {
- try {
- await api.delete(`/posts/comment/${postId}/${commentId}`);
-
- dispatch(removeComment(commentId));
-
- dispatch(createAlert("Comment Removed", "success"));
- } catch (err) {
- dispatch(
- postError({ msg: err.response.statusText, status: err.response.status })
- );
- }
-};
diff --git a/client/src/actions/profile.js b/client/src/actions/profile.js
deleted file mode 100644
index 1fca564..0000000
--- a/client/src/actions/profile.js
+++ /dev/null
@@ -1,210 +0,0 @@
-import api from "../utils/api";
-import { createAlert } from "./alert";
-import {
- noRepos,
- getRepos,
- clearProfile,
- profileError,
- getProfilesType,
- updateProfile,
- getProfile,
-} from "../reducers/profile";
-import { accountDeleted } from "../reducers/auth";
-
-
-// Get current users profile
-export const getCurrentProfile = () => async (dispatch) => {
- try {
- const res = await api.get("/profile/me");
-
- dispatch(getProfile(res.data));
- } catch (err) {
- dispatch(
- profileError({
- msg: err.response.statusText,
- status: err.response.status,
- })
- );
- }
-};
-
-// Get all profiles
-export const getProfiles = () => async (dispatch) => {
- dispatch(clearProfile());
-
- try {
- const res = await api.get("/profile");
-
- dispatch(getProfilesType(res.data));
- } catch (err) {
- dispatch(
- profileError({
- msg: err.response.statusText,
- status: err.response.status,
- })
- );
- }
-};
-
-// Get profile by ID
-export const getProfileById = (userId) => async (dispatch) => {
- try {
- const res = await api.get(`/profile/user/${userId}`);
-
- dispatch(getProfile(res.data));
- } catch (err) {
- dispatch(
- profileError({
- msg: err.response.statusText,
- status: err.response.status,
- })
- );
- }
-};
-
-// Get Github repos
-export const getGithubRepos = (username) => async (dispatch) => {
- try {
- const res = await api.get(`/profile/github/${username}`);
-
- dispatch(getRepos(res.data));
- } catch (err) {
- dispatch(noRepos());
- }
-};
-
-// Create or update profile
-export const createProfile =
- (formData, edit = false) =>
- async (dispatch) => {
- try {
- const res = await api.post("/profile", formData);
-
- dispatch(getProfile(res.data));
-
- dispatch(
- createAlert(edit ? "Profile Updated" : "Profile Created", "success")
- );
-
- } catch (err) {
- const errors = err.response.data.errors;
-
- if (errors) {
- errors.forEach((error) => dispatch(createAlert(error.msg, "danger")));
- }
-
- dispatch(
- profileError({
- msg: err.response.statusText,
- status: err.response.status,
- })
- );
- }
- };
-
-// Add Experience
-export const addExperience = (formData) => async (dispatch) => {
- try {
- const res = await api.put("/profile/experience", formData);
-
- dispatch(updateProfile(res.data));
-
- dispatch(createAlert("Experience Added", "success"));
-
- } catch (err) {
- const errors = err.response.data.errors;
-
- if (errors) {
- errors.forEach((error) => dispatch(createAlert(error.msg, "danger")));
- }
-
- dispatch(
- profileError({
- msg: err.response.statusText,
- status: err.response.status,
- })
- );
- }
-};
-
-// Add Education
-export const addEducation = (formData) => async (dispatch) => {
- try {
- const res = await api.put("/profile/education", formData);
-
- dispatch(updateProfile(res.data));
-
- dispatch(createAlert("Education Added", "success"));
-
- } catch (err) {
- const errors = err.response.data.errors;
-
- if (errors) {
- errors.forEach((error) => dispatch(createAlert(error.msg, "danger")));
- }
-
- dispatch(
- profileError({
- msg: err.response.statusText,
- status: err.response.status,
- })
- );
- }
-};
-
-// Delete experience
-export const deleteExperience = (id) => async (dispatch) => {
- try {
- const res = await api.delete(`/profile/experience/${id}`);
-
- dispatch(updateProfile(res.data));
-
- dispatch(createAlert("Experience Removed", "success"));
- } catch (err) {
- dispatch(
- profileError({
- msg: err.response.statusText,
- status: err.response.status,
- })
- );
- }
-};
-
-// Delete education
-export const deleteEducation = (id) => async (dispatch) => {
- try {
- const res = await api.delete(`/profile/education/${id}`);
-
- dispatch(updateProfile(res.data));
-
- dispatch(createAlert("Education Removed", "success"));
- } catch (err) {
- dispatch(
- profileError({
- msg: err.response.statusText,
- status: err.response.status,
- })
- );
- }
-};
-
-// Delete account & profile
-export const deleteAccount = () => async (dispatch) => {
- if (window.confirm("Are you sure? This can NOT be undone!")) {
- try {
- await api.delete("/profile");
-
- dispatch(clearProfile());
- dispatch(accountDeleted());
-
- dispatch(createAlert("Your account has been permanently deleted"));
- } catch (err) {
- dispatch(
- profileError({
- msg: err.response.statusText,
- status: err.response.status,
- })
- );
- }
- }
-};
diff --git a/client/src/components/auth/Login.js b/client/src/components/auth/Login.js
deleted file mode 100644
index b1963f6..0000000
--- a/client/src/components/auth/Login.js
+++ /dev/null
@@ -1,61 +0,0 @@
-import React, { useState } from "react";
-import { Link, Navigate } from "react-router-dom";
-import { useDispatch, useSelector } from "react-redux";
-import { login } from "../../actions/auth";
-
-const Login = () => {
- const [formData, setFormData] = useState({
- email: "",
- password: "",
- });
- const dispatch = useDispatch();
- const { email, password } = formData;
- const isAuthenticated = useSelector((state) => state.auth.isAuthenticated);
- const onChange = (e) =>
- setFormData({ ...formData, [e.target.name]: e.target.value });
-
- const onSubmit = async (e) => {
- e.preventDefault();
- await dispatch(login(email, password));
- };
-
- if (isAuthenticated) {
- return ;
- }
-
- return (
-
- Sign In
-
- Sign Into Your Account
-
-
-
- Don't have an account? Sign Up
-
-
- );
-};
-
-export default Login;
diff --git a/client/src/components/auth/Register.js b/client/src/components/auth/Register.js
deleted file mode 100644
index 79749e2..0000000
--- a/client/src/components/auth/Register.js
+++ /dev/null
@@ -1,91 +0,0 @@
-import React, { useState } from 'react';
-import { useDispatch,useSelector } from 'react-redux';
-import { Link, Navigate } from 'react-router-dom';
-import { createAlert } from '../../actions/alert';
-import { register } from '../../actions/auth';
-
-
-const Register = () => {
- const dispatch = useDispatch();
- const [formData, setFormData] = useState({
- name: '',
- email: '',
- password: '',
- password2: ''
- });
- const isAuthenticated = useSelector(state=>state.auth.isAuthenticated)
- const { name, email, password, password2 } = formData;
-
- const onChange = (e) =>
- setFormData({ ...formData, [e.target.name]: e.target.value });
-
- const onSubmit = async (e) => {
- e.preventDefault();
- if (password !== password2) {
- await dispatch(createAlert('Passwords do not match', 'danger'));
- } else {
- await dispatch(register({ name, email, password }));
- }
- };
-
- if (isAuthenticated) {
- return ;
- }
-
- return (
-
- Sign Up
-
- Create Your Account
-
-
-
- Already have an account? Sign In
-
-
- );
-};
-
-export default Register;
diff --git a/client/src/components/dashboard/Dashboard.js b/client/src/components/dashboard/Dashboard.js
deleted file mode 100644
index 677c54a..0000000
--- a/client/src/components/dashboard/Dashboard.js
+++ /dev/null
@@ -1,52 +0,0 @@
-import React, { useEffect } from "react";
-import { Link } from "react-router-dom";
-import { useDispatch, useSelector } from "react-redux";
-import DashboardActions from "./DashboardActions";
-import Experience from "./Experience";
-import Education from "./Education";
-import { getCurrentProfile, deleteAccount } from "../../actions/profile";
-
-const Dashboard = () => {
- const dispatch = useDispatch();
- useEffect(() => {
- function fetchData() {
- dispatch(getCurrentProfile());
- }
- fetchData();
- }, [dispatch]);
- const user = useSelector((state) => state.auth.user);
- const profile = useSelector((state) => state.profile.profile);
- return (
-
- Dashboard
-
- Welcome {user && user.name}
-
- {profile !== null ? (
- <>
-
-
-
-
-
-
-
- >
- ) : (
- <>
- You have not yet setup a profile, please add some info
-
- Create Profile
-
- >
- )}
-
- );
-};
-
-export default Dashboard;
diff --git a/client/src/components/dashboard/DashboardActions.js b/client/src/components/dashboard/DashboardActions.js
deleted file mode 100644
index 3a63e5d..0000000
--- a/client/src/components/dashboard/DashboardActions.js
+++ /dev/null
@@ -1,20 +0,0 @@
-import React from 'react';
-import { Link } from 'react-router-dom';
-
-const DashboardActions = () => {
- return (
-
-
- Edit Profile
-
-
- Add Experience
-
-
- Add Education
-
-
- );
-};
-
-export default DashboardActions;
diff --git a/client/src/components/dashboard/Education.js b/client/src/components/dashboard/Education.js
deleted file mode 100644
index 2c79532..0000000
--- a/client/src/components/dashboard/Education.js
+++ /dev/null
@@ -1,44 +0,0 @@
-import React, { Fragment } from "react";
-import {useDispatch } from "react-redux";
-import { deleteEducation } from "../../actions/profile";
-import formatDate from "../../utils/formatDate";
-
-const Education = ({education}) => {
- const dispatch = useDispatch();
- const educations = education.map((edu) => (
-
- | {edu.school} |
- {edu.degree} |
-
- {formatDate(edu.from)} - {edu.to ? formatDate(edu.to) : "Now"}
- |
-
-
- |
-
- ));
-
- return (
-
- Education Credentials
-
-
-
- | School |
- Degree |
- Years |
- |
-
-
- {educations}
-
-
- );
-};
-
-export default Education;
diff --git a/client/src/components/dashboard/Experience.js b/client/src/components/dashboard/Experience.js
deleted file mode 100644
index 5257f26..0000000
--- a/client/src/components/dashboard/Experience.js
+++ /dev/null
@@ -1,46 +0,0 @@
-import React, { Fragment } from 'react';
-import {useDispatch } from 'react-redux';
-import { deleteExperience } from '../../actions/profile';
-import formatDate from '../../utils/formatDate';
-
-const Experience = ({experience}) => {
- const dispatch = useDispatch();
- const experiences = experience.map((exp) => (
-
- | {exp.company} |
- {exp.title} |
-
- {formatDate(exp.from)} - {exp.to ? formatDate(exp.to) : 'Now'}
- |
-
-
- |
-
- ));
-
- return (
-
- Experience Credentials
-
-
-
- | Company |
- Title |
- Years |
- |
-
-
- {experiences}
-
-
- );
-};
-
-
-
-export default Experience;
diff --git a/client/src/components/layout/Alert.js b/client/src/components/layout/Alert.js
deleted file mode 100644
index 7767998..0000000
--- a/client/src/components/layout/Alert.js
+++ /dev/null
@@ -1,16 +0,0 @@
-import React from "react";
-import { useSelector } from "react-redux";
-const Alert = () => {
- const alerts = useSelector((state) => state.alert);
- return (
-
- {alerts.map((alert) => (
-
- {alert.msg}
-
- ))}
-
- );
-};
-
-export default Alert;
diff --git a/client/src/components/layout/Landing.js b/client/src/components/layout/Landing.js
deleted file mode 100644
index 2434df5..0000000
--- a/client/src/components/layout/Landing.js
+++ /dev/null
@@ -1,34 +0,0 @@
-import React from "react";
-import { Link, Navigate } from "react-router-dom";
-import { useSelector } from "react-redux";
-
-const Landing = () => {
- const isAuthenticated = useSelector((state) => state.auth.isAuthenticated);
- if (isAuthenticated) {
- return ;
- }
-
- return (
-
-
-
-
Developer Connector
-
- Create a developer profile/portfolio, share posts and get help from
- other developers
-
-
-
- Sign Up
-
-
- Login
-
-
-
-
-
- );
-};
-
-export default Landing;
diff --git a/client/src/components/layout/Navbar.js b/client/src/components/layout/Navbar.js
deleted file mode 100644
index 0adbbbd..0000000
--- a/client/src/components/layout/Navbar.js
+++ /dev/null
@@ -1,57 +0,0 @@
-import React, { Fragment } from "react";
-import { Link } from "react-router-dom";
-import { useDispatch, useSelector } from "react-redux";
-import { logOut } from "../../reducers/auth";
-
-const Navbar = () => {
- const isAuthenticated = useSelector((state) => state.auth.isAuthenticated);
- const dispatch = useDispatch();
- const authLinks = (
-
- );
-
- const guestLinks = (
-
- -
- Developers
-
- -
- Register
-
- -
- Login
-
-
- );
-
- return (
-
- );
-};
-
-export default Navbar;
diff --git a/client/src/components/layout/NotFound.js b/client/src/components/layout/NotFound.js
deleted file mode 100644
index 7a243da..0000000
--- a/client/src/components/layout/NotFound.js
+++ /dev/null
@@ -1,14 +0,0 @@
-import React from 'react';
-
-const NotFound = () => {
- return (
-
-
- Page Not Found
-
- Sorry, this page does not exist
-
- );
-};
-
-export default NotFound;
diff --git a/client/src/components/layout/Spinner.js b/client/src/components/layout/Spinner.js
deleted file mode 100644
index d4255c3..0000000
--- a/client/src/components/layout/Spinner.js
+++ /dev/null
@@ -1,14 +0,0 @@
-import React, { Fragment } from 'react';
-import spinner from './spinner.gif';
-
-const Spinner = () => (
-
-
-
-);
-
-export default Spinner;
diff --git a/client/src/components/post/CommentForm.js b/client/src/components/post/CommentForm.js
deleted file mode 100644
index 1fcf2d4..0000000
--- a/client/src/components/post/CommentForm.js
+++ /dev/null
@@ -1,39 +0,0 @@
-import React, { useState } from 'react';
-import { useDispatch } from 'react-redux';
-import { addComment } from '../../actions/post';
-
-const CommentForm = ({ postId }) => {
- const [text, setText] = useState('');
- const dispatch = useDispatch();
-
- return (
-
-
-
Leave a Comment
-
-
-
- );
-};
-
-
-export default CommentForm
-
diff --git a/client/src/components/post/CommentItem.js b/client/src/components/post/CommentItem.js
deleted file mode 100644
index be45842..0000000
--- a/client/src/components/post/CommentItem.js
+++ /dev/null
@@ -1,38 +0,0 @@
-import React from "react";
-import { Link } from "react-router-dom";
-import { useDispatch, useSelector } from "react-redux";
-import formatDate from "../../utils/formatDate";
-import { deleteComment } from "../../actions/post";
-
-const CommentItem = ({
- postId,
- comment: { _id, text, name, avatar, user, date },
-}) => {
- const dispatch = useDispatch();
- const auth = useSelector((state) => state.auth);
- return (
-
-
-
-

-
{name}
-
-
-
-
{text}
-
Posted on {formatDate(date)}
- {!auth.loading && user === auth.user._id && (
-
- )}
-
-
- );
-};
-
-export default CommentItem;
diff --git a/client/src/components/post/Post.js b/client/src/components/post/Post.js
deleted file mode 100644
index b8f4124..0000000
--- a/client/src/components/post/Post.js
+++ /dev/null
@@ -1,39 +0,0 @@
-import React, { useEffect } from "react";
-import { Link, useParams } from "react-router-dom";
-import { useDispatch, useSelector } from "react-redux";
-import Spinner from "../layout/Spinner";
-import PostItem from "../posts/PostItem";
-import CommentForm from "../post/CommentForm";
-import CommentItem from "../post/CommentItem";
-import { getPost } from "../../actions/post";
-
-const Post = () => {
- const dispatch = useDispatch();
- const { post, loading } = useSelector((state) => state.post);
- const { id } = useParams();
- useEffect(() => {
- async function fetchData() {
- await dispatch(getPost(id));
- }
- fetchData();
- }, [dispatch, id]);
-
- return loading || post === null ? (
-
- ) : (
-
-
- Back To Posts
-
-
-
-
- {post.comments.map((comment) => (
-
- ))}
-
-
- );
-};
-
-export default Post;
diff --git a/client/src/components/posts/PostForm.js b/client/src/components/posts/PostForm.js
deleted file mode 100644
index 2881eab..0000000
--- a/client/src/components/posts/PostForm.js
+++ /dev/null
@@ -1,36 +0,0 @@
-import React, { useState } from "react";
-import { useDispatch } from "react-redux";
-import { addPost } from "../../actions/post";
-
-const PostForm = () => {
- const [text, setText] = useState("");
- const dispatch = useDispatch();
- return (
-
-
-
Say Something...
-
-
-
- );
-};
-
-export default PostForm;
diff --git a/client/src/components/posts/PostItem.js b/client/src/components/posts/PostItem.js
deleted file mode 100644
index b26ef34..0000000
--- a/client/src/components/posts/PostItem.js
+++ /dev/null
@@ -1,57 +0,0 @@
-import React from "react";
-import { Link } from "react-router-dom";
-import formatDate from "../../utils/formatDate";
-import { useDispatch, useSelector } from "react-redux";
-import { addLike, removeLike, deletePost } from "../../actions/post";
-
-const PostItem = ({
- post: { _id, text, name, avatar, user, likes, comments, date },
-}) => {
- const dispatch = useDispatch();
- const auth = useSelector((state) => state.auth);
- return (
-
-
-
-

-
{name}
-
-
-
-
{text}
-
Posted on {formatDate(date)}
-
-
-
- Discussion{" "}
- {comments.length > 0 && (
-
{comments.length}
- )}
-
- {!auth.loading && user === auth.user._id && (
-
- )}
-
-
- );
-};
-export default PostItem;
diff --git a/client/src/components/posts/Posts.js b/client/src/components/posts/Posts.js
deleted file mode 100644
index 1d3bc9d..0000000
--- a/client/src/components/posts/Posts.js
+++ /dev/null
@@ -1,34 +0,0 @@
-import React, { useEffect } from "react";
-import { useDispatch, useSelector } from "react-redux";
-import PostItem from "./PostItem";
-import PostForm from "./PostForm";
-import { getPosts } from "../../actions/post";
-
-const Posts = () => {
- const dispatch = useDispatch();
- useEffect(() => {
- async function fetchData() {
- await dispatch(getPosts());
- }
- fetchData();
- }, [dispatch]);
- const posts = useSelector((state) => state.post.posts);
-
-
- return (
-
- Posts
-
- Welcome to the community
-
-
-
- {posts.map((post) => (
-
- ))}
-
-
- );
-};
-
-export default Posts;
diff --git a/client/src/components/profile-forms/AddEducation.js b/client/src/components/profile-forms/AddEducation.js
deleted file mode 100644
index e40f852..0000000
--- a/client/src/components/profile-forms/AddEducation.js
+++ /dev/null
@@ -1,116 +0,0 @@
-import React, { useState } from "react";
-import { Link, useNavigate } from "react-router-dom";
-import { useDispatch } from "react-redux";
-import { addEducation } from "../../actions/profile";
-
-const AddEducation = () => {
- const navigate = useNavigate();
- const dispatch = useDispatch();
- const [formData, setFormData] = useState({
- school: "",
- degree: "",
- fieldofstudy: "",
- from: "",
- to: "",
- current: false,
- description: "",
- });
-
- const { school, degree, fieldofstudy, from, to, description, current } =
- formData;
-
- const onChange = (e) =>
- setFormData({ ...formData, [e.target.name]: e.target.value });
-
- return (
-
- );
-};
-
-
-export default AddEducation;
\ No newline at end of file
diff --git a/client/src/components/profile-forms/AddExperience.js b/client/src/components/profile-forms/AddExperience.js
deleted file mode 100644
index fd8b166..0000000
--- a/client/src/components/profile-forms/AddExperience.js
+++ /dev/null
@@ -1,115 +0,0 @@
-import React, { useState } from 'react';
-import { Link, useNavigate } from 'react-router-dom';
-import { useDispatch } from 'react-redux';
-import { addExperience } from '../../actions/profile';
-
-const AddExperience = () => {
- const dispatch = useDispatch();
- const navigate = useNavigate();
- const [formData, setFormData] = useState({
- company: '',
- title: '',
- location: '',
- from: '',
- to: '',
- current: false,
- description: ''
- });
-
- const { company, title, location, from, to, current, description } = formData;
-
- const onChange = (e) =>
- setFormData({ ...formData, [e.target.name]: e.target.value });
-
- return (
-
- );
-};
-
-export default AddExperience;
diff --git a/client/src/components/profile-forms/ProfileForm.js b/client/src/components/profile-forms/ProfileForm.js
deleted file mode 100644
index 9b1fe57..0000000
--- a/client/src/components/profile-forms/ProfileForm.js
+++ /dev/null
@@ -1,266 +0,0 @@
-import React, { Fragment, useState, useEffect } from "react";
-import { Link, useMatch, useNavigate } from "react-router-dom";
-import { createProfile, getCurrentProfile } from "../../actions/profile";
-import { useDispatch, useSelector } from "react-redux";
-
-const initialState = {
- company: "",
- website: "",
- location: "",
- status: "",
- skills: "",
- githubusername: "",
- bio: "",
- twitter: "",
- facebook: "",
- linkedin: "",
- youtube: "",
- instagram: "",
-};
-
-const ProfileForm = () => {
-
- const dispatch = useDispatch();
-
- const { profile, loading } = useSelector((state) => state.profile);
-
- const [formData, setFormData] = useState(initialState);
-
- const creatingProfile = useMatch("/create-profile");
-
- const [displaySocialInputs, toggleSocialInputs] = useState(false);
-
- const navigate = useNavigate();
-
- useEffect(() => {
- // if there is no profile, attempt to fetch one
- async function fetchData(){
- await dispatch(getCurrentProfile())
- }
- if (!profile) fetchData();
-
- // if we finished loading and we do have a profile
- // then build our profileData
- if (!loading && profile) {
- const profileData = { ...initialState };
- for (const key in profile) {
- if (key in profileData) profileData[key] = profile[key];
- }
- for (const key in profile.social) {
- if (key in profileData) profileData[key] = profile.social[key];
- }
- // the skills may be an array from our API response
- if (Array.isArray(profileData.skills))
- profileData.skills = profileData.skills.join(", ");
- // set local state with the profileData
- setFormData(profileData);
- }
- }, [loading, dispatch, profile]);
-
- const {
- company,
- website,
- location,
- status,
- skills,
- githubusername,
- bio,
- twitter,
- facebook,
- linkedin,
- youtube,
- instagram,
- } = formData;
-
- const onChange = (e) =>
- setFormData({ ...formData, [e.target.name]: e.target.value });
-
- const onSubmit = async (e) => {
- const editing = profile ? true : false;
- e.preventDefault();
- await dispatch(createProfile(formData, editing)).then(() => {
- console.log(editing)
- if (!editing) navigate("/dashboard");
- });
- };
-
- return (
-
- );
-};
-
-export default ProfileForm;
diff --git a/client/src/components/profile/Profile.js b/client/src/components/profile/Profile.js
deleted file mode 100644
index 982557f..0000000
--- a/client/src/components/profile/Profile.js
+++ /dev/null
@@ -1,86 +0,0 @@
-import React, { Fragment, useEffect } from "react";
-import { Link, useParams } from "react-router-dom";
-import { useDispatch, useSelector } from "react-redux";
-import Spinner from "../layout/Spinner";
-import ProfileTop from "./ProfileTop";
-import ProfileAbout from "./ProfileAbout";
-import ProfileExperience from "./ProfileExperience";
-import ProfileEducation from "./ProfileEducation";
-import ProfileGithub from "./ProfileGithub";
-import { getProfileById } from "../../actions/profile";
-
-const Profile = () => {
- const profile = useSelector((state) => state.profile.profile);
- const auth = useSelector((state) => state.auth);
- const dispatch = useDispatch();
- const { id } = useParams();
-
- useEffect(() => {
- async function fetchData(){
- await dispatch(getProfileById(id));
- }
- fetchData();
- }, [dispatch,id]);
-
- return (
-
- {profile === null ? (
-
- ) : (
-
-
- Back To Profiles
-
- {auth.isAuthenticated &&
- auth.loading === false &&
- auth.user._id === profile.user._id && (
-
- Edit Profile
-
- )}
-
-
-
-
-
Experience
- {profile.experience.length > 0 ? (
-
- {profile.experience.map((experience) => (
-
- ))}
-
- ) : (
-
No experience credentials
- )}
-
-
-
-
Education
- {profile.education.length > 0 ? (
-
- {profile.education.map((education) => (
-
- ))}
-
- ) : (
-
No education credentials
- )}
-
-
- {profile.githubusername && (
-
- )}
-
-
- )}
-
- );
-};
-
-export default Profile;
diff --git a/client/src/components/profile/ProfileAbout.js b/client/src/components/profile/ProfileAbout.js
deleted file mode 100644
index abadb54..0000000
--- a/client/src/components/profile/ProfileAbout.js
+++ /dev/null
@@ -1,30 +0,0 @@
-import React, { Fragment } from 'react';
-
-const ProfileAbout = ({
- profile: {
- bio,
- skills,
- user: { name }
- }
-}) => (
-
- {bio && (
-
- {name.trim().split(' ')[0]}s Bio
- {bio}
-
-
- )}
-
Skill Set
-
- {skills.map((skill, index) => (
-
- {skill}
-
- ))}
-
-
-);
-
-
-export default ProfileAbout;
diff --git a/client/src/components/profile/ProfileEducation.js b/client/src/components/profile/ProfileEducation.js
deleted file mode 100644
index 325f6db..0000000
--- a/client/src/components/profile/ProfileEducation.js
+++ /dev/null
@@ -1,26 +0,0 @@
-import React from 'react';
-import formatDate from '../../utils/formatDate';
-
-const ProfileEducation = ({
- education: { school, degree, fieldofstudy, current, to, from, description }
-}) => (
-
-
{school}
-
- {formatDate(from)} - {to ? formatDate(to) : 'Now'}
-
-
- Degree: {degree}
-
-
- Field Of Study: {fieldofstudy}
-
-
- Description: {description}
-
-
-);
-
-
-
-export default ProfileEducation;
diff --git a/client/src/components/profile/ProfileExperience.js b/client/src/components/profile/ProfileExperience.js
deleted file mode 100644
index 064603f..0000000
--- a/client/src/components/profile/ProfileExperience.js
+++ /dev/null
@@ -1,25 +0,0 @@
-import React from 'react';
-import formatDate from '../../utils/formatDate';
-
-const ProfileExperience = ({
- experience: { company, title, location, current, to, from, description }
-}) => (
-
-
{company}
-
- {formatDate(from)} - {to ? formatDate(to) : 'Now'}
-
-
- Position: {title}
-
-
- Location: {location}
-
-
- Description: {description}
-
-
-);
-
-
-export default ProfileExperience;
diff --git a/client/src/components/profile/ProfileGithub.js b/client/src/components/profile/ProfileGithub.js
deleted file mode 100644
index a97a4eb..0000000
--- a/client/src/components/profile/ProfileGithub.js
+++ /dev/null
@@ -1,45 +0,0 @@
-import React, { useEffect } from "react";
-import { useDispatch, useSelector } from "react-redux";
-import { getGithubRepos } from "../../actions/profile";
-
-const ProfileGithub = ({ username }) => {
- const repos = useSelector((state) => state.profile.repos);
- const dispatch = useDispatch();
- useEffect(() => {
- async function fetchData() {
- await dispatch(getGithubRepos(username));
- }
- fetchData();
- }, [dispatch, username]);
-
- return (
-
-
Github Repos
- {repos.map((repo) => (
-
-
-
-
- -
- Stars: {repo.stargazers_count}
-
- -
- Watchers: {repo.watchers_count}
-
- - Forks: {repo.forks_count}
-
-
-
- ))}
-
- );
-};
-
-export default ProfileGithub;
diff --git a/client/src/components/profile/ProfileTop.js b/client/src/components/profile/ProfileTop.js
deleted file mode 100644
index d35fce2..0000000
--- a/client/src/components/profile/ProfileTop.js
+++ /dev/null
@@ -1,46 +0,0 @@
-import React from "react";
-
-const ProfileTop = ({
- profile: {
- status,
- company,
- location,
- website,
- social,
- user: { name, avatar },
- },
-}) => {
- return (
-
-

-
{name}
-
- {status} {company ? at {company} : null}
-
-
{location ? {location} : null}
-
- {website ? (
-
-
-
- ) : null}
- {social
- ? Object.entries(social)
- .filter(([_, value]) => value)
- .map(([key, value]) => (
-
-
-
- ))
- : null}
-
-
- );
-};
-
-export default ProfileTop;
diff --git a/client/src/components/profiles/ProfileItem.js b/client/src/components/profiles/ProfileItem.js
deleted file mode 100644
index 11e5efe..0000000
--- a/client/src/components/profiles/ProfileItem.js
+++ /dev/null
@@ -1,38 +0,0 @@
-import React from 'react';
-import { Link } from 'react-router-dom';
-
-const ProfileItem = ({
- profile: {
- user: { _id, name, avatar },
- status,
- company,
- location,
- skills
- }
-}) => {
- return (
-
-

-
-
{name}
-
- {status} {company && at {company}}
-
-
{location && {location}}
-
- View Profile
-
-
-
- {skills.slice(0, 4).map((skill, index) => (
- -
- {skill}
-
- ))}
-
-
- );
-};
-
-export default ProfileItem;
-
diff --git a/client/src/components/profiles/Profiles.js b/client/src/components/profiles/Profiles.js
deleted file mode 100644
index 4a78cb0..0000000
--- a/client/src/components/profiles/Profiles.js
+++ /dev/null
@@ -1,44 +0,0 @@
-import React, { Fragment, useEffect } from "react";
-import { useDispatch, useSelector } from "react-redux";
-import Spinner from "../layout/Spinner";
-import ProfileItem from "./ProfileItem";
-import { getProfiles } from "../../actions/profile";
-
-const Profiles = () => {
- const dispatch = useDispatch();
-
- useEffect(() => {
- async function fetchData() {
- await dispatch(getProfiles());
- }
- fetchData();
- }, [dispatch]);
-
- const { profiles, loading } = useSelector((state) => state.profile);
- return (
-
- {loading ? (
-
- ) : (
-
- Developers
-
- Browse and connect with
- developers
-
-
- {profiles.length > 0 ? (
- profiles.map((profile) => (
-
- ))
- ) : (
-
No profiles found...
- )}
-
-
- )}
-
- );
-};
-
-export default Profiles;
diff --git a/client/src/components/routing/PrivateRoute.js b/client/src/components/routing/PrivateRoute.js
deleted file mode 100644
index e169e6e..0000000
--- a/client/src/components/routing/PrivateRoute.js
+++ /dev/null
@@ -1,14 +0,0 @@
-import React from "react";
-import { Navigate } from "react-router-dom";
-import { useSelector } from "react-redux";
-import Spinner from "../layout/Spinner";
-
-const PrivateRoute = ({ component: Component }) => {
- const { isAuthenticated, loading } = useSelector((state) => state.auth);
- if (loading) return ;
- if (isAuthenticated) return ;
-
- return ;
-};
-
-export default PrivateRoute;
diff --git a/client/src/index.js b/client/src/index.js
deleted file mode 100644
index 84a5edd..0000000
--- a/client/src/index.js
+++ /dev/null
@@ -1,9 +0,0 @@
-import React from 'react';
-import {createRoot} from 'react-dom/client'
-import App from './App';
-
-// Level - 0
-//Program stars from Here. Imports and renders App.
-
-const root = createRoot(document.getElementById('root'));
-root.render()
diff --git a/client/src/reducers/alert.js b/client/src/reducers/alert.js
deleted file mode 100644
index a8f4ded..0000000
--- a/client/src/reducers/alert.js
+++ /dev/null
@@ -1,20 +0,0 @@
-import { createSlice } from "@reduxjs/toolkit";
-
-const initialState = [];
-
-const alertSlice = createSlice({
- name: "alert",
- initialState,
- reducers: {
- setAlert(state, action) {
- return [...state, action.payload];
- },
- removeAlert(state, action) {
- return state.filter((alert) => alert.id !== action.payload);
- },
- },
-});
-
-export const { setAlert, removeAlert } = alertSlice.actions;
-
-export default alertSlice.reducer;
diff --git a/client/src/reducers/auth.js b/client/src/reducers/auth.js
deleted file mode 100644
index 150ea2b..0000000
--- a/client/src/reducers/auth.js
+++ /dev/null
@@ -1,76 +0,0 @@
-import { createSlice } from "@reduxjs/toolkit";
-
-const initialState = {
- token: localStorage.getItem("token"),
- isAuthenticated: null,
- loading: true,
- user: null,
-};
-
-const authSlice = createSlice({
- name: "auth",
- initialState,
- reducers: {
- userLoaded(state, action) {
- return {
- ...state,
- isAuthenticated: true,
- loading: false,
- user: action.payload,
- };
- },
- registerSuccess(state, action) {
- return {
- ...state,
- ...action.payload,
- isAuthenticated: true,
- loading: false,
- };
- },
- loginSucces(state, action) {
- return {
- ...state,
- ...action.payload,
- isAuthenticated: true,
- loading: false,
- };
- },
- accountDeleted(state, action) {
- return {
- ...state,
- token: null,
- isAuthenticated: false,
- loading: false,
- user: null,
- };
- },
- authError(state, action) {
- return {
- ...state,
- token: null,
- isAuthenticated: false,
- loading: false,
- user: null,
- };
- },
- logOut(state, action) {
- return {
- ...state,
- token: null,
- isAuthenticated: false,
- loading: false,
- user: null,
- };
- },
- },
-});
-export const {
- logOut,
- userLoaded,
- loginSucces,
- registerSuccess,
- accountDeleted,
- authError,
-} = authSlice.actions;
-
-export default authSlice.reducer;
diff --git a/client/src/reducers/post.js b/client/src/reducers/post.js
deleted file mode 100644
index 6488923..0000000
--- a/client/src/reducers/post.js
+++ /dev/null
@@ -1,92 +0,0 @@
-import { createSlice } from "@reduxjs/toolkit";
-
-const initialState = {
- posts: [],
- post: null,
- loading: true,
- error: {},
-};
-
-const postSlice = createSlice({
- name: "post",
- initialState,
- reducers: {
- getPostsAction(state, action) {
- return {
- ...state,
- posts: action.payload,
- loading: false,
- };
- },
- getPostAction(state, action) {
- return {
- ...state,
- post: action.payload,
- loading: false,
- };
- },
- addPostAction(state, action) {
- return {
- ...state,
- posts: [action.payload, ...state.posts],
- loading: false,
- };
- },
- deletePostAction(state, action) {
- return {
- ...state,
- posts: state.posts.filter((post) => post._id !== action.payload),
- loading: false,
- };
- },
- postError(state, action) {
- return {
- ...state,
- error: action.payload,
- loading: false,
- };
- },
- updateLikes(state, action) {
- return {
- ...state,
- posts: state.posts.map((post) =>
- post._id === action.payload.id
- ? { ...post, likes: action.payload.likes }
- : post
- ),
- loading: false,
- };
- },
- addCommentAction(state, action) {
- return {
- ...state,
- post: { ...state.post, comments: action.payload },
- loading: false,
- };
- },
- removeComment(state, action) {
- return {
- ...state,
- post: {
- ...state.post,
- comments: state.post.comments.filter(
- (comment) => comment._id !== action.payload
- ),
- },
- loading: false,
- };
- },
- },
-});
-export const {
- removeComment,
- addCommentAction,
- updateLikes,
- postError,
- deletePostAction,
- getPostAction,
- getPostsAction,
- addPostAction,
-} = postSlice.actions;
-
-export default postSlice.reducer;
diff --git a/client/src/reducers/profile.js b/client/src/reducers/profile.js
deleted file mode 100644
index f88ec6c..0000000
--- a/client/src/reducers/profile.js
+++ /dev/null
@@ -1,75 +0,0 @@
-import { createSlice } from "@reduxjs/toolkit";
-
-const initialState = {
- profile: null,
- profiles: [],
- repos: [],
- loading: true,
- error: {},
-};
-const profileSlice = createSlice({
- name: "profile",
- initialState,
- reducers: {
- getProfile(state, action) {
- return {
- ...state,
- profile: action.payload,
- loading: false,
- };
- },
- updateProfile(state, action) {
- return {
- ...state,
- profile: action.payload,
- loading: false,
- };
- },
- getProfilesType(state, action) {
- return {
- ...state,
- profiles: action.payload,
- loading: false,
- };
- },
- profileError(state, action) {
- return {
- ...state,
- error: action.payload,
- loading: false,
- profile: null,
- };
- },
- clearProfile(state, action) {
- return {
- ...state,
- profile: null,
- repos: [],
- };
- },
- getRepos(state, action) {
- return {
- ...state,
- repos: action.payload,
- loading: false,
- };
- },
- noRepos(state, action) {
- return {
- ...state,
- repos: [],
- };
- },
- },
-});
-export const {
- noRepos,
- getRepos,
- clearProfile,
- profileError,
- getProfilesType,
- updateProfile,
- getProfile,
-} = profileSlice.actions;
-
-export default profileSlice.reducer;
diff --git a/client/src/store.js b/client/src/store.js
deleted file mode 100644
index 1ccb336..0000000
--- a/client/src/store.js
+++ /dev/null
@@ -1,32 +0,0 @@
-import setAuthToken from './utils/setAuthToken';
-import { configureStore } from '@reduxjs/toolkit';
-
-import alertReducer from './reducers/alert';
-import authReducer from './reducers/auth';
-import profileReducer from './reducers/profile'
-import postReducer from './reducers/post'
-
-
-const store = configureStore({
- reducer: {
- alert: alertReducer,
- auth: authReducer,
- profile: profileReducer,
- post: postReducer
-}})
-
-let currentState = store.getState();
-
-store.subscribe(() => {
- // keep track of the previous and current state to compare changes
- let previousState = currentState;
- currentState = store.getState();
- // if the token changes set the value in localStorage and axios headers
- if (previousState.auth.token !== currentState.auth.token) {
- const token = currentState.auth.token;
- setAuthToken(token);
- }
-});
-
-export default store;
-
diff --git a/client/src/utils/api.js b/client/src/utils/api.js
deleted file mode 100644
index 57148d5..0000000
--- a/client/src/utils/api.js
+++ /dev/null
@@ -1,20 +0,0 @@
-import axios from 'axios';
-import store from '../store';
-
-const api = axios.create({
- baseURL: '/api',
- headers: {
- 'Content-Type': 'application/json'
- }
-});
-api.interceptors.response.use(
- (res) => res,
- (err) => {
- if (err.response.status === 401) {
- store.dispatch({ type: 'auth/logOut' });
- }
- return Promise.reject(err);
- }
-);
-
-export default api;
diff --git a/client/src/utils/formatDate.js b/client/src/utils/formatDate.js
deleted file mode 100644
index 3dcf024..0000000
--- a/client/src/utils/formatDate.js
+++ /dev/null
@@ -1,5 +0,0 @@
-function formatDate(date) {
- return new Intl.DateTimeFormat().format(new Date(date));
-}
-
-export default formatDate;
diff --git a/client/src/utils/setAuthToken.js b/client/src/utils/setAuthToken.js
deleted file mode 100644
index bcafd72..0000000
--- a/client/src/utils/setAuthToken.js
+++ /dev/null
@@ -1,15 +0,0 @@
-import api from './api';
-
-// store our JWT in LS and set axios headers if we do have a token
-
-const setAuthToken = (token) => {
- if (token) {
- api.defaults.headers.common['x-auth-token'] = token;
- localStorage.setItem('token', token);
- } else {
- delete api.defaults.headers.common['x-auth-token'];
- localStorage.removeItem('token');
- }
-};
-
-export default setAuthToken;
diff --git a/server/package.json b/server/package.json
index b9bf995..593135a 100644
--- a/server/package.json
+++ b/server/package.json
@@ -7,8 +7,7 @@
"start": "ts-node server.ts",
"server": "ts-node-dev server.ts",
"client": "npm start --prefix client --trace-depracation",
- "dev": "concurrently \"npm run server\" \"npm run client\"",
- "render": "NPM_CONFIG_PRODUCTION=false npm install --prefix client && npm run build --prefix client"
+ "dev": "concurrently \"npm run server\" \"npm run client\""
},
"author": "",
"license": "ISC",
diff --git a/server/routers/api/auth.js b/server/routers/api/auth.js
deleted file mode 100644
index 4d06b43..0000000
--- a/server/routers/api/auth.js
+++ /dev/null
@@ -1,80 +0,0 @@
-const express = require("express");
-const router = express.Router();
-const bcrypt = require("bcryptjs");
-const auth = require("../../middleware/auth");
-const jwt = require("jsonwebtoken");
-const config = require("config");
-const { check, validationResult } = require("express-validator");
-
-const User = require("../../models/User");
-
-// @route GET api/auth
-// @desc Get user by token
-// @access Private
-router.get("/", auth, async (req, res) => {
- try {
- const user = await User.findById(req.user.id).select("-password");
- res.json(user);
- } catch (err) {
- console.error(err.message);
- res.status(500).send("Server Error");
- }
-});
-
-// @route POST api/auth
-// @desc Authenticate user & get token
-// @access Public
-router.post(
- "/",
- [
- check("email", "Please include a valid email").isEmail(),
- check("password", "Password is required").exists(),
- ],
- async (req, res) => {
- const errors = validationResult(req);
- if (!errors.isEmpty()) {
- return res.status(400).json({ errors: errors.array() });
- }
-
- const { email, password } = req.body;
-
- try {
- let user = await User.findOne({ email });
-
- if (!user) {
- return res
- .status(400)
- .json({ errors: [{ msg: "Invalid Credentials" }] });
- }
-
- const isMatch = await bcrypt.compare(password, user.password);
-
- if (!isMatch) {
- return res
- .status(400)
- .json({ errors: [{ msg: "Invalid Credentials" }] });
- }
-
- const payload = {
- user: {
- id: user.id,
- },
- };
-
- jwt.sign(
- payload,
- config.get("jwtSecret"),
- { expiresIn: 360000 },
- (err, token) => {
- if (err) throw err;
- res.json({ token });
- }
- );
- } catch (err) {
- console.error(err.message);
- res.status(500).send("Server error");
- }
- }
-);
-
-module.exports = router;
diff --git a/server/routers/api/posts.js b/server/routers/api/posts.js
deleted file mode 100644
index 11e87c3..0000000
--- a/server/routers/api/posts.js
+++ /dev/null
@@ -1,221 +0,0 @@
-const express = require("express");
-const router = express.Router();
-const { check, validationResult } = require("express-validator");
-const auth = require("../../middleware/auth");
-
-const Post = require("../../models/Post");
-const User = require("../../models/User");
-const checkObjectId = require("../../middleware/checkObjectId");
-
-// @route POST api/posts
-// @desc Create a post
-// @access Private
-
-router.post(
- "/",
- auth,
- check("text", "Text is required").notEmpty(),
- async (req, res) => {
- const errors = validationResult(req);
- if (!errors.isEmpty()) {
- return res.status(400).json({ errors: errors.array() });
- }
-
- try {
- const user = await User.findById(req.user.id).select("-password");
-
- const newPost = new Post({
- text: req.body.text,
- name: user.name,
- avatar: user.avatar,
- user: req.user.id,
- });
-
- const post = await newPost.save();
-
- res.json(post);
- } catch (err) {
- console.error(err.message);
- res.status(500).send("Server Error");
- }
- }
-);
-
-// @route GET api/posts
-// @desc Get all posts
-// @access Private
-router.get("/", auth, async (req, res) => {
- try {
- const posts = await Post.find().sort({ date: -1 });
- res.json(posts);
- } catch (err) {
- console.error(err.message);
- res.status(500).send("Server Error");
- }
-});
-
-// @route GET api/posts/:id
-// @desc Get post by ID
-// @access Private
-router.get("/:id", auth, checkObjectId("id"), async (req, res) => {
- try {
- const post = await Post.findById(req.params.id);
-
- if (!post) {
- return res.status(404).json({ msg: "Post not found" });
- }
-
- res.json(post);
- } catch (err) {
- console.error(err.message);
-
- res.status(500).send("Server Error");
- }
-});
-
-// @route DELETE api/posts/:id
-// @desc Delete a post
-// @access Private
-router.delete("/:id", [auth, checkObjectId("id")], async (req, res) => {
- try {
- const post = await Post.findById(req.params.id);
-
- if (!post) {
- return res.status(404).json({ msg: "Post not found" });
- }
-
- // Check user
- if (post.user.toString() !== req.user.id) {
- return res.status(401).json({ msg: "User not authorized" });
- }
-
- await post.remove();
-
- res.json({ msg: "Post removed" });
- } catch (err) {
- console.error(err.message);
-
- res.status(500).send("Server Error");
- }
-});
-
-// @route PUT api/posts/like/:id
-// @desc Like a post
-// @access Private
-router.put("/like/:id", auth, checkObjectId("id"), async (req, res) => {
- try {
- const post = await Post.findById(req.params.id);
-
- // Check if the post has already been liked
- if (post.likes.some((like) => like.user.toString() === req.user.id)) {
- return res.status(400).json({ msg: "Post already liked" });
- }
-
- post.likes.unshift({ user: req.user.id });
-
- await post.save();
-
- return res.json(post.likes);
- } catch (err) {
- console.error(err.message);
- res.status(500).send("Server Error");
- }
-});
-
-// @route PUT api/posts/unlike/:id
-// @desc Unlike a post
-// @access Private
-router.put("/unlike/:id", auth, checkObjectId("id"), async (req, res) => {
- try {
- const post = await Post.findById(req.params.id);
-
- // Check if the post has not yet been liked
- if (!post.likes.some((like) => like.user.toString() === req.user.id)) {
- return res.status(400).json({ msg: "Post has not yet been liked" });
- }
-
- // remove the like
- post.likes = post.likes.filter(
- ({ user }) => user.toString() !== req.user.id
- );
-
- await post.save();
-
- return res.json(post.likes);
- } catch (err) {
- console.error(err.message);
- res.status(500).send("Server Error");
- }
-});
-
-// @route POST api/posts/comment/:id
-// @desc Comment on a post
-// @access Private
-router.post(
- "/comment/:id",
- auth,
- checkObjectId("id"),
- check("text", "Text is required").notEmpty(),
- async (req, res) => {
- const errors = validationResult(req);
- if (!errors.isEmpty()) {
- return res.status(400).json({ errors: errors.array() });
- }
-
- try {
- const user = await User.findById(req.user.id).select("-password");
- const post = await Post.findById(req.params.id);
-
- const newComment = {
- text: req.body.text,
- name: user.name,
- avatar: user.avatar,
- user: req.user.id,
- };
-
- post.comments.unshift(newComment);
-
- await post.save();
-
- res.json(post.comments);
- } catch (err) {
- console.error(err.message);
- res.status(500).send("Server Error");
- }
- }
-);
-
-// @route DELETE api/posts/comment/:id/:comment_id
-// @desc Delete comment
-// @access Private
-router.delete("/comment/:id/:comment_id", auth, async (req, res) => {
- try {
- const post = await Post.findById(req.params.id);
-
- // Pull out comment
- const comment = post.comments.find(
- (comment) => comment.id === req.params.comment_id
- );
- // Make sure comment exists
- if (!comment) {
- return res.status(404).json({ msg: "Comment does not exist" });
- }
- // Check user
- if (comment.user.toString() !== req.user.id) {
- return res.status(401).json({ msg: "User not authorized" });
- }
-
- post.comments = post.comments.filter(
- ({ id }) => id !== req.params.comment_id
- );
-
- await post.save();
-
- return res.json(post.comments);
- } catch (err) {
- console.error(err.message);
- return res.status(500).send("Server Error");
- }
-});
-
-module.exports = router;