Skip to content

Commit 0241d9b

Browse files
author
developer-sujon
committed
backend complate
0 parents  commit 0241d9b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+36845
-0
lines changed

.env

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
APPLICATION_NAME = blog application
2+
PORT = 8080
3+
MONGODB_CONNECTION_URL = mongodb://0.0.0.0:27017
4+
MONGODB_DATABASE_USERNAME = developer-sujon
5+
MONGODB_DATABASE_PASSWORD = developer-sujon
6+
JWT_SECRET_KEY = 0420943jfdlkfsdf

.gitignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# production
12+
/build
13+
14+
# misc
15+
.DS_Store
16+
.env.local
17+
.env.development.local
18+
.env.test.local
19+
.env.production.local
20+
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*

app.js

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
//external Lib imports
2+
const express = require("express");
3+
const morgan = require("morgan");
4+
const dotenv = require("dotenv");
5+
const path = require("path");
6+
const app = new express();
7+
8+
dotenv.config({ path: path.join(__dirname, "./.env") });
9+
10+
//internal imports
11+
const connectDB = require("./src/confiq/db");
12+
const { checkLogin } = require("./src/middleware/authVerify");
13+
14+
//imports routes
15+
16+
//security lib imports
17+
const cors = require("cors");
18+
const hpp = require("hpp");
19+
const helmet = require("helmet");
20+
const rateLimit = require("express-rate-limit");
21+
const expressMongoSanitize = require("express-mongo-sanitize");
22+
const xssClean = require("xss-clean");
23+
24+
//
25+
const userRoutes = require("./src/routes/user/userRoutes");
26+
const taskRoutes = require("./src/routes/task/taskRoutes");
27+
28+
//security middleware emplement
29+
app.use(cors());
30+
app.use(hpp());
31+
app.use(helmet());
32+
app.use(expressMongoSanitize());
33+
app.use(xssClean());
34+
35+
//default middleware emplement
36+
app.use(express.json());
37+
app.use(express.urlencoded({ extended: true }));
38+
app.use(morgan("dev"));
39+
40+
// Apply the rate limiting middleware to all requests
41+
42+
const limiter = rateLimit({
43+
windowMs: 15 * 60 * 1000,
44+
max: 10000,
45+
standardHeaders: true,
46+
legacyHeaders: false,
47+
});
48+
49+
app.use(limiter);
50+
51+
const MONGODB_CONNECTION_URL = process.env.MONGODB_CONNECTION_URL;
52+
const DB_OPTIONS = {
53+
//user: process.env.MONGODB_DATABASE_USERNAME,
54+
//pass: process.env.MONGODB_DATABASE_PASSWORD,
55+
dbName: "task",
56+
autoIndex: true,
57+
};
58+
59+
//connection database
60+
connectDB(MONGODB_CONNECTION_URL, DB_OPTIONS);
61+
app.use(express.static("client/build"));
62+
63+
// Routing Implement
64+
65+
app.use("/api/v1/user", userRoutes);
66+
app.use("/api/v1/task", taskRoutes);
67+
68+
// Add React Front End Routing
69+
app.get("*", (req, res) => {
70+
res.sendFile(path.resolve(__dirname, "client", "build", "index.html"));
71+
});
72+
73+
// 404 not found handler
74+
// app.use(notFoundErrorHandler);
75+
76+
// Default Error Handler
77+
app.use((err, req, res, next) => {
78+
if (err.message) {
79+
res.status(500).send({ status: "fail", data: err.message });
80+
} else {
81+
res
82+
.status(500)
83+
.send({ status: "fail", data: "There was an server side error!" });
84+
}
85+
});
86+
87+
module.exports = app;

client/.gitignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# production
12+
/build
13+
14+
# misc
15+
.DS_Store
16+
.env.local
17+
.env.development.local
18+
.env.test.local
19+
.env.production.local
20+
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*

client/package.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"name": "appname",
3+
"version": "0.1.0",
4+
"private": true,
5+
"dependencies": {
6+
"axios": "^0.27.2",
7+
"bootstrap": "^5.1.3",
8+
"cogo-toast": "^4.2.3",
9+
"html-react-parser": "^1.4.14",
10+
"react": "^18.1.0",
11+
"react-bootstrap": "^2.4.0",
12+
"react-countup": "^6.2.0",
13+
"react-dom": "^18.1.0",
14+
"react-icons": "^4.4.0",
15+
"react-loading-skeleton": "^3.1.0",
16+
"react-router-dom": "^6.3.0",
17+
"react-scripts": "5.0.1",
18+
"react-slick": "^0.29.0",
19+
"react-sweetalert2": "^0.5.2",
20+
"recharts": "^2.1.10",
21+
"slick-carousel": "^1.8.1",
22+
"video-react": "^0.15.0"
23+
},
24+
"scripts": {
25+
"start": "react-scripts start",
26+
"build": "react-scripts build",
27+
"test": "react-scripts test",
28+
"eject": "react-scripts eject"
29+
},
30+
"eslintConfig": {
31+
"extends": [
32+
"react-app",
33+
"react-app/jest"
34+
]
35+
},
36+
"browserslist": {
37+
"production": [
38+
">0.2%",
39+
"not dead",
40+
"not op_mini all"
41+
],
42+
"development": [
43+
"last 1 chrome version",
44+
"last 1 firefox version",
45+
"last 1 safari version"
46+
]
47+
}
48+
}

client/public/favicon.ico

3.94 KB
Binary file not shown.

client/public/index.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="utf-8" />
6+
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
7+
<meta name="viewport" content="width=device-width, initial-scale=1" />
8+
<meta name="theme-color" content="#000000" />
9+
<meta name="description" content="Mern Project Structure" />
10+
</head>
11+
12+
<body>
13+
<noscript>You need to enable JavaScript to run this app.</noscript>
14+
<div id="root"></div>
15+
</body>
16+
17+
</html>

client/src/APIRequest/ApiRequest.js

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
//external lib import
2+
import axios from "axios";
3+
4+
axios.defaults.baseURL = "https://mern-project-server-api.herokuapp.com/api/v1";
5+
axios.defaults.headers.common["Authorization"] =
6+
"Bearer " + sessionStorage.getItem("token");
7+
8+
axios.defaults.headers.post["Content-Type"] =
9+
"application/x-www-form-urlencoded";
10+
11+
class ApiRequest {
12+
static getRequest(url) {
13+
axios
14+
.get(url)
15+
.then((response) => {
16+
if (response.status === 200) {
17+
return response.data;
18+
} else {
19+
return null;
20+
}
21+
})
22+
.catch((err) => {
23+
console.log(err);
24+
return null;
25+
});
26+
}
27+
28+
static postRequest(url, postJson) {
29+
axios
30+
.post(url, postJson)
31+
.then((response) => {
32+
if (response.status === 201) {
33+
return response.data;
34+
} else {
35+
return null;
36+
}
37+
})
38+
.catch((err) => {
39+
console.log(err);
40+
return null;
41+
});
42+
}
43+
44+
static updateRequest(url, postJson) {
45+
axios
46+
.update(url, postJson)
47+
.then((response) => {
48+
if (response.status === 200) {
49+
return response.data;
50+
} else {
51+
return null;
52+
}
53+
})
54+
.catch((err) => {
55+
console.log(err);
56+
return null;
57+
});
58+
}
59+
60+
static deleteRequest(url) {
61+
axios
62+
.delete(url)
63+
.then((response) => {
64+
if (response.status === 200) {
65+
return response.data;
66+
} else {
67+
return null;
68+
}
69+
})
70+
.catch((err) => {
71+
console.log(err);
72+
return null;
73+
});
74+
}
75+
}
76+
77+
export default ApiRequest;

client/src/App.jsx

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//external imports
2+
import React, { Component } from "react";
3+
import { Route, Routes } from "react-router-dom";
4+
5+
//enternel imports
6+
import CancledTaskPage from "./pages/CancledTaskPage";
7+
import ComplatedTaskPage from "./pages/ComplatedTaskPage";
8+
import CreateTaskPage from "./pages/CreateTaskPage";
9+
import DashboardPage from "./pages/DashboardPage";
10+
import ForgetPasswordPage from "./pages/ForgetPasswordPage";
11+
import HomePage from "./pages/HomePage";
12+
import LoginPage from "./pages/LoginPage";
13+
import NewTaskPage from "./pages/NewTaskPage";
14+
import NotFoundPage from "./pages/NotFound";
15+
import PendingTaskPage from "./pages/PendingTaskPage";
16+
import ProfilePage from "./pages/ProfilePage";
17+
import RegistrationPage from "./pages/RegistrationPage";
18+
import TaskPage from "./pages/TaskPage";
19+
20+
class App extends Component {
21+
render() {
22+
return (
23+
<Routes>
24+
<Route path="/" element={<HomePage />} />
25+
<Route path="/registration" element={<RegistrationPage />} />
26+
<Route path="/login" element={<LoginPage />} />
27+
<Route path="/forget-password" element={<ForgetPasswordPage />} />
28+
<Route path="/profile" element={<ProfilePage />} />
29+
<Route path="/dashboard" element={<DashboardPage />} />
30+
<Route path="/create-blog" element={<CreateTaskPage />} />
31+
<Route path="/all-blog" element={<TaskPage />} />
32+
<Route path="/pending-blog" element={<PendingTaskPage />} />
33+
<Route path="/cancled-blog" element={<CancledTaskPage />} />
34+
<Route path="/new-blog" element={<NewTaskPage />} />
35+
<Route path="/complate-page" element={<ComplatedTaskPage />} />
36+
<Route element={<NotFoundPage />} />
37+
</Routes>
38+
);
39+
}
40+
}
41+
42+
export default App;

client/src/assets/css/animate.min.css

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)