Compare commits

..

4 Commits

Author SHA1 Message Date
Kayne Ruse 2794b4c724 Updated dependencies 2022-11-13 01:56:14 +00:00
Kayne Ruse b1f49a4166 Removed a dependency 2022-08-01 11:09:35 +01:00
Kayne Ruse 4cbf67dcbb Updated dependencies 2022-08-01 10:34:35 +01:00
Kayne Ruse fd29385cf8 Update README.md 2022-07-28 03:47:23 +10:00
18 changed files with 820 additions and 6515 deletions
+1
View File
@@ -56,6 +56,7 @@ To set up this template in development mode:
- Account deletion
- Password management
- JSON web token authentication
- HttpOnly cookies for security
- Optional post validation hook
- Fully Featured News Blog (as a microservice)
- Publish, edit or delete articles as needed
+9 -7
View File
@@ -2,14 +2,16 @@
import 'regenerator-runtime/runtime';
import React from 'react';
import ReactDOM from 'react-dom';
import ReactDOM from 'react-dom/client';
import App from './pages/app';
import TokenProvider from './pages/utilities/token-provider';
ReactDOM.render(
<TokenProvider>
<App />
</TokenProvider>,
document.querySelector('#root')
);
ReactDOM
.createRoot(document.getElementById('root'))
.render(
<TokenProvider>
<App />
</TokenProvider>
)
;
+2 -2
View File
@@ -1,5 +1,5 @@
import React, { useEffect, useContext, useRef } from 'react';
import { Link, Redirect } from 'react-router-dom';
import { Link, Navigate } from 'react-router-dom';
import ApplyToBody from '../utilities/apply-to-body';
@@ -13,7 +13,7 @@ const Account = props => {
//misplaced?
if (!authTokens.accessToken) {
return <Redirect to='/' />;
return <Navigate to='/' />;
}
//refs
+3 -3
View File
@@ -1,5 +1,5 @@
import React, { useContext, useRef } from 'react';
import { Link, Redirect } from 'react-router-dom';
import { Link, Navigate } from 'react-router-dom';
import ApplyToBody from '../utilities/apply-to-body';
@@ -13,7 +13,7 @@ const Login = props => {
//misplaced?
if (authTokens.accessToken) {
return <Redirect to='/' />;
return <Navigate to='/' />;
}
//refs
@@ -40,7 +40,7 @@ const Login = props => {
if (accessToken) {
authTokens.setAccessToken(accessToken);
props.history.push('/');
return <Navigate to='/' />;
}
}
}>
+2 -2
View File
@@ -1,5 +1,5 @@
import React, { useContext, useRef } from 'react';
import { Link, Redirect } from 'react-router-dom';
import { Link, Navigate } from 'react-router-dom';
import ApplyToBody from '../utilities/apply-to-body';
@@ -14,7 +14,7 @@ const Recover = props => {
//misplaced?
if (authTokens.accessToken) {
return <Redirect to='/' />;
return <Navigate to='/' />;
}
//refs
+2 -2
View File
@@ -1,5 +1,5 @@
import React, { useContext, useRef } from 'react';
import { Link, Redirect } from 'react-router-dom';
import { Link, Navigate } from 'react-router-dom';
import queryString from 'query-string';
import ApplyToBody from '../utilities/apply-to-body';
@@ -15,7 +15,7 @@ const Reset = props => {
//misplaced?
if (authTokens.accessToken || !query.email || !query.token) {
return <Redirect to='/' />;
return <Navigate to='/' />;
}
//refs
+2 -2
View File
@@ -1,5 +1,5 @@
import React, { useContext, useRef } from 'react';
import { Link, Redirect } from 'react-router-dom';
import { Link, Navigate } from 'react-router-dom';
import ApplyToBody from '../utilities/apply-to-body';
@@ -15,7 +15,7 @@ const Signup = props => {
//misplaced?
if (authTokens.accessToken) {
return <Redirect to='/' />;
return <Navigate to='/' />;
}
//refs
+2 -2
View File
@@ -1,5 +1,5 @@
import React, { useContext } from 'react';
import { Link, Redirect } from 'react-router-dom';
import { Link, Navigate } from 'react-router-dom';
import ApplyToBody from '../utilities/apply-to-body';
@@ -14,7 +14,7 @@ const Admin = props => {
//misplaced? (admin only)
if (!authTokens.accessToken || !authTokens.getPayload().admin) {
return <Redirect to='/' />;
return <Navigate to='/' />;
}
return (
+2 -2
View File
@@ -1,5 +1,5 @@
import React, { useContext } from 'react';
import { Link, Redirect } from 'react-router-dom';
import { Link, Navigate } from 'react-router-dom';
import ApplyToBody from '../utilities/apply-to-body';
@@ -17,7 +17,7 @@ const Mod = props => {
//misplaced? (admin only)
if (!authTokens.accessToken || !(authTokens.getPayload().admin || authTokens.getPayload().mod)) {
return <Redirect to='/' />;
return <Navigate to='/' />;
}
return (
+34 -21
View File
@@ -1,11 +1,8 @@
//react
import React, { useContext } from 'react';
import { BrowserRouter, Switch } from 'react-router-dom';
import React, { useContext, Suspense, lazy } from 'react';
import { BrowserRouter, Routes, Route } from 'react-router-dom';
import { TokenContext } from './utilities/token-provider';
//library components
import LazyRoute from './utilities/lazy-route';
//styling
import '../styles/styles.css';
@@ -13,33 +10,49 @@ import '../styles/styles.css';
import Footer from './panels/footer';
import PopupChat from './panels/popup-chat';
//lazy wrappers
const Homepage = lazy(() => import('./homepage'));
const Signup = lazy(() => import('./accounts/signup'));
const Login = lazy(() => import('./accounts/login'));
const Account = lazy(() => import('./accounts/account'));
const Dashboard = lazy(() => import('./dashboard'));
const Recover = lazy(() => import('./accounts/recover'));
const Reset = lazy(() => import('./accounts/reset'));
const Admin = lazy(() => import('./administration/admin'));
const Mod = lazy(() => import('./administration/mod'));
const PrivacyPolicy = lazy(() => import('./static/privacy-policy'));
const Credits = lazy(() => import('./static/credits'));
const NotFound = lazy(() => import('./not-found'));
const App = props => {
const authTokens = useContext(TokenContext);
//default render
return (
<BrowserRouter>
<Switch>
<LazyRoute exact path='/' component={() => import('./homepage')} />
<Suspense>
<Routes>
<Route exact path='/' element={<Homepage />} />
<LazyRoute path='/signup' component={() => import('./accounts/signup')} />
<LazyRoute path='/login' component={() => import('./accounts/login')} />
<LazyRoute path='/account' component={() => import('./accounts/account')} />
<LazyRoute path='/dashboard' component={() => import('./dashboard')} />
<Route path='/signup' element={<Signup />} />
<Route path='/login' element={<Login />} />
<Route path='/account' element={<Account />} />
<Route path='/dashboard' element={<Dashboard />} />
<LazyRoute path='/recover' component={() => import('./accounts/recover')} />
<LazyRoute path='/reset' component={() => import('./accounts/reset')} />
<Route path='/recover' element={<Recover />} />
<Route path='/reset' element={<Reset />} />
<LazyRoute path='/admin' component={() => import('./administration/admin')} />
<LazyRoute path='/mod' component={() => import('./administration/mod')} />
<Route path='/admin' element={<Admin />} />
<Route path='/mod' element={<Mod />} />
<LazyRoute path='/privacypolicy' component={() => import('./static/privacy-policy')} />
<LazyRoute path='/credits' component={() => import('./static/credits')} />
<Route path='/privacypolicy' element={<PrivacyPolicy />} />
<Route path='/credits' element={<Credits />} />
<LazyRoute path='*' component={() => import('./not-found')} />
</Switch>
{ authTokens.accessToken ? <PopupChat /> : <></> }
<Footer />
<Route path='*' element={<NotFound />} />
</Routes>
</Suspense>
{ authTokens.accessToken ? <PopupChat /> : <></> }
<Footer />
</BrowserRouter>
);
};
+2 -2
View File
@@ -1,5 +1,5 @@
import React, { useContext } from 'react';
import { Link, Redirect } from 'react-router-dom';
import { Link, Navigate } from 'react-router-dom';
import ApplyToBody from './utilities/apply-to-body';
@@ -13,7 +13,7 @@ const Dashboard = props => {
//misplaced?
if (!authTokens.accessToken) {
return <Redirect to='/' />;
return <Navigate to='/' />;
}
return (
+2 -2
View File
@@ -1,5 +1,5 @@
import React, { useContext } from 'react';
import { Link, Redirect } from 'react-router-dom';
import { Link, Navigate } from 'react-router-dom';
import ApplyToBody from './utilities/apply-to-body';
@@ -13,7 +13,7 @@ const HomePage = props => {
//misplaced?
if (authTokens.accessToken) {
return <Redirect to='/dashboard' />;
return <Navigate to='/dashboard' />;
}
return (
-1
View File
@@ -22,7 +22,6 @@ const NewsFeed = props => {
<div className='panel'>
<h1 className='text centered'>News Feed</h1>
{articles.map((article, index) => {
console.log(article)
return (
<div key={index} className='panel'>
<hr />
-13
View File
@@ -1,13 +0,0 @@
import React from 'react';
import { Route } from 'react-router-dom';
import loadable from '@loadable/component';
const LazyRoute = props => {
const { component, ...lazyProps } = props;
const lazyComponent = loadable(component);
return <Route {...lazyProps} component={lazyComponent} />
};
export default LazyRoute;
+1 -1
View File
@@ -22,6 +22,6 @@
<meta property="og:description" content="" />
</head>
<body>
<div id = "root"></div>
<div id="root"></div>
</body>
</html>
+1 -1
View File
@@ -278,7 +278,7 @@ networks:
`;
const dockerfile = `
FROM node:16
FROM node:18
WORKDIR "/app"
COPY . /app
RUN mkdir /app/public
+744 -6440
View File
File diff suppressed because it is too large Load Diff
+11 -12
View File
@@ -1,6 +1,6 @@
{
"name": "mern-template",
"version": "1.3.0",
"version": "1.3.2",
"description": "A website template using the MERN stack.",
"main": "server/server.js",
"scripts": {
@@ -30,23 +30,22 @@
"@babel/core": "^7.14.8",
"@babel/preset-env": "^7.14.8",
"@babel/preset-react": "^7.14.5",
"@loadable/component": "^5.15.0",
"babel-loader": "^8.2.2",
"clean-webpack-plugin": "^3.0.0",
"compression-webpack-plugin": "^8.0.1",
"concurrently": "^6.2.0",
"clean-webpack-plugin": "^4.0.0",
"compression-webpack-plugin": "^10.0.0",
"concurrently": "^7.3.0",
"css-loader": "^6.2.0",
"dateformat": "^4.5.1",
"dotenv": "^10.0.0",
"dateformat": "^5.0.3",
"dotenv": "^16.0.1",
"express": "^4.17.1",
"html-webpack-plugin": "^5.3.2",
"jwt-decode": "^3.1.2",
"mariadb": "^2.5.4",
"mariadb": "^3.0.1",
"query-string": "^7.0.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-router": "^5.2.0",
"react-router-dom": "^5.2.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router": "^6.3.0",
"react-router-dom": "^6.3.0",
"react-select": "^5.2.1",
"sequelize": "^6.6.5",
"socket.io-client": "^4.1.3",