Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4e94c5338d | |||
| 55ff5765c6 | |||
| d486059430 | |||
| 9d8c948dbb | |||
| b21fa8db9e | |||
| c130b74e2d | |||
| d37b93d5f7 | |||
| 829cb2e3da | |||
| 29f0dbb1ca | |||
| 13ad7d2435 | |||
| e30853e0cd | |||
| 1e16a96f86 | |||
| cff73107b2 | |||
| 76417747b3 | |||
| b8323723ed |
@@ -56,6 +56,7 @@ To set up this template in development mode:
|
|||||||
- Account deletion
|
- Account deletion
|
||||||
- Password management
|
- Password management
|
||||||
- JSON web token authentication
|
- JSON web token authentication
|
||||||
|
- Optional post validation hook
|
||||||
- Fully Featured News Blog (as a microservice)
|
- Fully Featured News Blog (as a microservice)
|
||||||
- Publish, edit or delete articles as needed
|
- Publish, edit or delete articles as needed
|
||||||
- Secured via admin panel
|
- Secured via admin panel
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
<header>
|
|
||||||
<h1 class="text centered">Credits</h1>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
## MERN-template
|
|
||||||
|
|
||||||
The MERN-template developed by Kayne Ruse, KR Game Studios
|
|
||||||
|
|
||||||
[https://github.com/krgamestudios/MERN-template](https://github.com/krgamestudios/MERN-template)
|
|
||||||
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
<header>
|
|
||||||
<h1 class="text centered">Privacy Policy</h1>
|
|
||||||
</header>
|
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import React, { useState, useEffect, useContext, useRef } from 'react';
|
import React, { useState, useEffect, useContext, useRef } from 'react';
|
||||||
import Select from 'react-dropdown-select';
|
import Select from 'react-select';
|
||||||
|
|
||||||
import { TokenContext } from '../../utilities/token-provider';
|
import { TokenContext } from '../../utilities/token-provider';
|
||||||
|
|
||||||
@@ -39,11 +39,9 @@ const NewsEditor = props => {
|
|||||||
<div className='panel'>
|
<div className='panel'>
|
||||||
<h2 className='text centered'>News Editor</h2>
|
<h2 className='text centered'>News Editor</h2>
|
||||||
<Select
|
<Select
|
||||||
options={articles.map(article => { return { label: article.title, value: article.index }; })}
|
options={articles.map(article => { return { label: article.title, index: article.index }; })}
|
||||||
onChange={async values => {
|
onChange={async ({index}) => {
|
||||||
//fetch this article
|
//fetch this article
|
||||||
const index = values[0].value;
|
|
||||||
|
|
||||||
const result = await fetch(`${process.env.NEWS_URI}/news/archive/${index}`, {
|
const result = await fetch(`${process.env.NEWS_URI}/news/archive/${index}`, {
|
||||||
headers: {
|
headers: {
|
||||||
'Access-Control-Allow-Origin': '*'
|
'Access-Control-Allow-Origin': '*'
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import { TokenContext } from './utilities/token-provider';
|
|||||||
|
|
||||||
//library components
|
//library components
|
||||||
import LazyRoute from './utilities/lazy-route';
|
import LazyRoute from './utilities/lazy-route';
|
||||||
import MarkdownPage from './utilities/markdown-page';
|
|
||||||
|
|
||||||
//styling
|
//styling
|
||||||
import '../styles/styles.css';
|
import '../styles/styles.css';
|
||||||
@@ -34,8 +33,8 @@ const App = props => {
|
|||||||
<LazyRoute path='/admin' component={() => import('./administration/admin')} />
|
<LazyRoute path='/admin' component={() => import('./administration/admin')} />
|
||||||
<LazyRoute path='/mod' component={() => import('./administration/mod')} />
|
<LazyRoute path='/mod' component={() => import('./administration/mod')} />
|
||||||
|
|
||||||
<LazyRoute path='/privacypolicy' component={async () => () => <MarkdownPage content={require('../markdown/privacy-policy.md').default} />} />
|
<LazyRoute path='/privacypolicy' component={() => import('./static/privacy-policy')} />
|
||||||
<LazyRoute path='/credits' component={async () => () => <MarkdownPage content={require('../markdown/credits.md').default} />} />
|
<LazyRoute path='/credits' component={() => import('./static/credits')} />
|
||||||
|
|
||||||
<LazyRoute path='*' component={() => import('./not-found')} />
|
<LazyRoute path='*' component={() => import('./not-found')} />
|
||||||
</Switch>
|
</Switch>
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import ApplyToBody from './utilities/apply-to-body';
|
|||||||
|
|
||||||
import { TokenContext } from './utilities/token-provider';
|
import { TokenContext } from './utilities/token-provider';
|
||||||
|
|
||||||
import MarkdownPanel from './utilities/markdown-panel';
|
|
||||||
import Logout from './accounts/panels/logout';
|
import Logout from './accounts/panels/logout';
|
||||||
|
|
||||||
const Dashboard = props => {
|
const Dashboard = props => {
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import ApplyToBody from './utilities/apply-to-body';
|
|||||||
|
|
||||||
import { TokenContext } from './utilities/token-provider';
|
import { TokenContext } from './utilities/token-provider';
|
||||||
|
|
||||||
import MarkdownPanel from './utilities/markdown-panel';
|
|
||||||
import NewsFeed from './panels/news-feed';
|
import NewsFeed from './panels/news-feed';
|
||||||
|
|
||||||
const HomePage = props => {
|
const HomePage = props => {
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import React, { useState, useEffect, useRef } from 'react';
|
import React, { useState, useEffect, useRef } from 'react';
|
||||||
import dateFormat from 'dateformat';
|
import dateFormat from 'dateformat';
|
||||||
|
|
||||||
import MarkdownPanel from '../utilities/markdown-panel';
|
|
||||||
|
|
||||||
const NewsFeed = props => {
|
const NewsFeed = props => {
|
||||||
const [articles, setArticles] = useState([]);
|
const [articles, setArticles] = useState([]);
|
||||||
const aborter = useRef(new AbortController()); //BUGFIX: double-renders = double fetches + react update after unmount
|
const aborter = useRef(new AbortController()); //BUGFIX: double-renders = double fetches + react update after unmount
|
||||||
@@ -29,6 +27,7 @@ const NewsFeed = props => {
|
|||||||
<div className='panel'>
|
<div className='panel'>
|
||||||
<h1 className='text centered'>News Feed</h1>
|
<h1 className='text centered'>News Feed</h1>
|
||||||
{articles.map((article, index) => {
|
{articles.map((article, index) => {
|
||||||
|
console.log(article)
|
||||||
return (
|
return (
|
||||||
<div key={index} className='panel'>
|
<div key={index} className='panel'>
|
||||||
<hr />
|
<hr />
|
||||||
@@ -40,7 +39,7 @@ const NewsFeed = props => {
|
|||||||
<span>Published {dateFormat(article.createdAt, 'fullDate')}</span>
|
<span>Published {dateFormat(article.createdAt, 'fullDate')}</span>
|
||||||
}</em></p>
|
}</em></p>
|
||||||
<br />
|
<br />
|
||||||
<MarkdownPanel style={{whiteSpace: 'pre-wrap'}} content={article.body} />
|
<div dangerouslySetInnerHTML={{ __html: article.rendered }} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
const Static = props => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<header>
|
||||||
|
<h1 className='text centered'>Credits</h1>
|
||||||
|
</header>
|
||||||
|
<h2>MERN-template</h2>
|
||||||
|
<p>The <a href='https://github.com/krgamestudios/MERN-template'>MERN-template</a> developed by Kayne Ruse, KR Game Studios</p>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Static;
|
||||||
|
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
const Static = props => {
|
||||||
|
return (
|
||||||
|
<header>
|
||||||
|
<h1 className="text centered">Privacy Policy</h1>
|
||||||
|
</header>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Static;
|
||||||
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import { Link } from 'react-router-dom';
|
|
||||||
|
|
||||||
import ApplyToBody from '../utilities/apply-to-body';
|
|
||||||
|
|
||||||
import MarkdownPanel from './markdown-panel';
|
|
||||||
|
|
||||||
const MarkdownPage = props => {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<ApplyToBody className='dashboard' />
|
|
||||||
<div className='page'>
|
|
||||||
<div className='central panel'>
|
|
||||||
<MarkdownPanel uri={props.uri} content={props.content} />
|
|
||||||
<Link to='/' className='text centered'>Return Home</Link>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
};
|
|
||||||
|
|
||||||
export default MarkdownPage;
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
import React, { useState, useEffect } from 'react';
|
|
||||||
import ReactMarkdown from 'react-markdown';
|
|
||||||
import rehypeRaw from 'rehype-raw';
|
|
||||||
|
|
||||||
const Markdown = props => {
|
|
||||||
//content?
|
|
||||||
let [contentHook, setContentHook] = useState(null);
|
|
||||||
|
|
||||||
//check arguments
|
|
||||||
if (!props.content) {
|
|
||||||
if (!props.uri) {
|
|
||||||
throw 'Markdown requires either content or uri prop';
|
|
||||||
}
|
|
||||||
|
|
||||||
//once
|
|
||||||
useEffect(() => {
|
|
||||||
fetch(props.uri)
|
|
||||||
.then(blob => blob.text())
|
|
||||||
.then(blob => setContentHook(blob))
|
|
||||||
.catch(e => console.error(e))
|
|
||||||
;
|
|
||||||
}, []);
|
|
||||||
}
|
|
||||||
|
|
||||||
//assume raw info
|
|
||||||
else if (!contentHook) {
|
|
||||||
setContentHook(props.content);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<ReactMarkdown rehypePlugins={[rehypeRaw]} props={{...props}}>{contentHook}</ReactMarkdown>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Markdown;
|
|
||||||
+7
-2
@@ -62,6 +62,7 @@ See https://github.com/krgamestudios/MERN-template/wiki for help.
|
|||||||
//auth configuration
|
//auth configuration
|
||||||
const authName = await question('Auth Name', 'auth');
|
const authName = await question('Auth Name', 'auth');
|
||||||
const authWebAddress = await question('Auth Web Address', `${authName}.${projectWebAddress}`);
|
const authWebAddress = await question('Auth Web Address', `${authName}.${projectWebAddress}`);
|
||||||
|
const authPostValidationHook = await question('Auth Post Validation Hook', '');
|
||||||
const authResetAddress = await question('Auth Reset Addr', `${projectWebAddress}/reset`);
|
const authResetAddress = await question('Auth Reset Addr', `${projectWebAddress}/reset`);
|
||||||
const authDBUser = await question('Auth DB Username', authName);
|
const authDBUser = await question('Auth DB Username', authName);
|
||||||
const authDBPass = await question('Auth DB Password', 'charizard');
|
const authDBPass = await question('Auth DB Password', 'charizard');
|
||||||
@@ -180,6 +181,7 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
- WEB_PROTOCOL=https
|
- WEB_PROTOCOL=https
|
||||||
- WEB_ADDRESS=${authWebAddress}
|
- WEB_ADDRESS=${authWebAddress}
|
||||||
|
- HOOK_POST_VALIDATION=${authPostValidationHook}
|
||||||
- WEB_RESET_ADDRESS=${authResetAddress}
|
- WEB_RESET_ADDRESS=${authResetAddress}
|
||||||
- WEB_PORT=${authPort}
|
- WEB_PORT=${authPort}
|
||||||
- DB_HOSTNAME=database
|
- DB_HOSTNAME=database
|
||||||
@@ -245,11 +247,14 @@ services:
|
|||||||
- --api.insecure=false
|
- --api.insecure=false
|
||||||
- --providers.docker=true
|
- --providers.docker=true
|
||||||
- --providers.docker.exposedbydefault=false
|
- --providers.docker.exposedbydefault=false
|
||||||
|
- --entrypoints.web.address=:80
|
||||||
|
- --entrypoints.web.http.redirections.entryPoint.to=websecure
|
||||||
|
- --entrypoints.web.http.redirections.entryPoint.scheme=https
|
||||||
|
- --entrypoints.web.http.redirections.entrypoint.permanent=true
|
||||||
- --entrypoints.websecure.address=:443
|
- --entrypoints.websecure.address=:443
|
||||||
- --certificatesresolvers.myresolver.acme.tlschallenge=true
|
- --certificatesresolvers.myresolver.acme.tlschallenge=true
|
||||||
- --certificatesresolvers.myresolver.acme.email=${supportEmail}
|
- --certificatesresolvers.myresolver.acme.email=${supportEmail}
|
||||||
- --certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json
|
- --certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json
|
||||||
- traefik.docker.network=app-network
|
|
||||||
ports:
|
ports:
|
||||||
- 80:80
|
- 80:80
|
||||||
- 443:443
|
- 443:443
|
||||||
@@ -265,7 +270,7 @@ networks:
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
const dockerfile = `
|
const dockerfile = `
|
||||||
FROM node:15
|
FROM node:16
|
||||||
WORKDIR "/app"
|
WORKDIR "/app"
|
||||||
COPY . /app
|
COPY . /app
|
||||||
RUN mkdir /app/public
|
RUN mkdir /app/public
|
||||||
|
|||||||
Generated
+3722
-8120
File diff suppressed because it is too large
Load Diff
+9
-7
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "mern-template",
|
"name": "mern-template",
|
||||||
"version": "1.0.5",
|
"version": "1.2.0",
|
||||||
"description": "A website template using the MERN stack.",
|
"description": "A website template using the MERN stack.",
|
||||||
"main": "server/server.js",
|
"main": "server/server.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -8,9 +8,12 @@
|
|||||||
"build": "npm run build:server && npm run build:client",
|
"build": "npm run build:server && npm run build:client",
|
||||||
"build:server": "exit 0",
|
"build:server": "exit 0",
|
||||||
"build:client": "webpack --env=production --config webpack.config.js",
|
"build:client": "webpack --env=production --config webpack.config.js",
|
||||||
"dev": "concurrently npm:watch:server npm:watch:client",
|
"dev": "concurrently npm:dev:server npm:dev:client",
|
||||||
"watch:server": "nodemon ./* --ext js,jsx,json --ignore 'node_modules/*'",
|
"dev:server": "nodemon ./* --ext js,jsx,json --ignore 'node_modules/*'",
|
||||||
"watch:client": "webpack serve --env=development --config webpack.config.js",
|
"dev:client": "webpack serve --env=development --config webpack.config.js",
|
||||||
|
"local": "concurrently npm:local:server npm:local:client",
|
||||||
|
"local:server": "nodemon ./* --ext js,jsx,json --ignore 'node_modules/*'",
|
||||||
|
"local:client": "webpack serve --env=local --config webpack.config.js",
|
||||||
"analyze": "webpack --env=production --env=analyze --config webpack.config.js"
|
"analyze": "webpack --env=production --env=analyze --config webpack.config.js"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -43,10 +46,9 @@
|
|||||||
"raw-loader": "^4.0.2",
|
"raw-loader": "^4.0.2",
|
||||||
"react": "^17.0.2",
|
"react": "^17.0.2",
|
||||||
"react-dom": "^17.0.2",
|
"react-dom": "^17.0.2",
|
||||||
"react-dropdown-select": "^4.7.4",
|
|
||||||
"react-markdown": "^6.0.2",
|
|
||||||
"react-router": "^5.2.0",
|
"react-router": "^5.2.0",
|
||||||
"react-router-dom": "^5.2.0",
|
"react-router-dom": "^5.2.0",
|
||||||
|
"react-select": "^5.2.1",
|
||||||
"rehype-raw": "^5.1.0",
|
"rehype-raw": "^5.1.0",
|
||||||
"sequelize": "^6.6.5",
|
"sequelize": "^6.6.5",
|
||||||
"socket.io-client": "^4.1.3",
|
"socket.io-client": "^4.1.3",
|
||||||
@@ -57,6 +59,6 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"nodemon": "^2.0.12",
|
"nodemon": "^2.0.12",
|
||||||
"webpack-dev-server": "^3.11.2"
|
"webpack-dev-server": "^4.6.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+29
-39
@@ -9,7 +9,7 @@ const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
//the exported config function
|
//the exported config function
|
||||||
module.exports = ({ production, analyze }) => {
|
module.exports = ({ production, development, local, analyze }) => {
|
||||||
return {
|
return {
|
||||||
mode: production ? "production" : "development",
|
mode: production ? "production" : "development",
|
||||||
entry: path.resolve(__dirname, 'client', 'client.jsx'),
|
entry: path.resolve(__dirname, 'client', 'client.jsx'),
|
||||||
@@ -19,7 +19,7 @@ module.exports = ({ production, analyze }) => {
|
|||||||
filename: '[name].[chunkhash].js',
|
filename: '[name].[chunkhash].js',
|
||||||
sourceMapFilename: '[name].[chunkhash].js.map'
|
sourceMapFilename: '[name].[chunkhash].js.map'
|
||||||
},
|
},
|
||||||
devtool: production ? 'source-map' : 'eval-source-map',
|
devtool: production ? false : 'eval-source-map',
|
||||||
resolve: {
|
resolve: {
|
||||||
extensions: ['.js', '.jsx']
|
extensions: ['.js', '.jsx']
|
||||||
},
|
},
|
||||||
@@ -56,9 +56,9 @@ module.exports = ({ production, analyze }) => {
|
|||||||
new DefinePlugin({
|
new DefinePlugin({
|
||||||
'process.env': {
|
'process.env': {
|
||||||
'PRODUCTION': production,
|
'PRODUCTION': production,
|
||||||
'NEWS_URI': production ? `"${process.env.NEWS_URI}"` : '"https://dev-news.krgamestudios.com"',
|
'NEWS_URI': production ? `"${process.env.NEWS_URI}"` : development ? '"https://dev-news.krgamestudios.com"' : '"http://localhost:3100"',
|
||||||
'AUTH_URI': production ? `"${process.env.AUTH_URI}"` : '"https://dev-auth.krgamestudios.com"',
|
'AUTH_URI': production ? `"${process.env.AUTH_URI}"` : development ? '"https://dev-auth.krgamestudios.com"' : '"http://localhost:3200"',
|
||||||
'CHAT_URI': production ? `"${process.env.CHAT_URI}"` : '"https://dev-chat.krgamestudios.com"',
|
'CHAT_URI': production ? `"${process.env.CHAT_URI}"` : development ? '"https://dev-chat.krgamestudios.com"' : '"http://localhost:3300"',
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
new CleanWebpackPlugin({
|
new CleanWebpackPlugin({
|
||||||
@@ -83,41 +83,31 @@ module.exports = ({ production, analyze }) => {
|
|||||||
})
|
})
|
||||||
],
|
],
|
||||||
devServer: {
|
devServer: {
|
||||||
contentBase: path.resolve(__dirname, 'public'),
|
|
||||||
compress: true,
|
|
||||||
port: 3001,
|
|
||||||
proxy: {
|
|
||||||
'/api/': 'http://localhost:3000/'
|
|
||||||
},
|
|
||||||
overlay: {
|
|
||||||
errors: true
|
|
||||||
},
|
|
||||||
stats: {
|
|
||||||
colors: true,
|
|
||||||
hash: false,
|
|
||||||
version: false,
|
|
||||||
timings: false,
|
|
||||||
assets: false,
|
|
||||||
chunks: false,
|
|
||||||
modules: false,
|
|
||||||
reasons: false,
|
|
||||||
children: false,
|
|
||||||
source: false,
|
|
||||||
errors: true,
|
|
||||||
errorDetails: false,
|
|
||||||
warnings: true,
|
|
||||||
publicPath: false
|
|
||||||
},
|
|
||||||
host: '0.0.0.0',
|
|
||||||
disableHostCheck: true,
|
|
||||||
clientLogLevel: 'silent',
|
|
||||||
historyApiFallback: true,
|
|
||||||
hot: true,
|
hot: true,
|
||||||
injectHot: true
|
host: 'localhost',
|
||||||
},
|
port: 3001,
|
||||||
watchOptions: {
|
client: {
|
||||||
ignored: /(node_modules)/
|
overlay: {
|
||||||
|
errors: true,
|
||||||
|
warnings: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
watchFiles: {
|
||||||
|
options: {
|
||||||
|
ignored: ['node_modules/**']
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
proxy: {
|
||||||
|
'/api': {
|
||||||
|
target: 'http://localhost:3000'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
static: '/public',
|
||||||
|
|
||||||
|
historyApiFallback: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user