Compare commits

..

29 Commits

Author SHA1 Message Date
Kayne Ruse ed01fe6db5 Addressed #34 2022-05-30 06:16:10 +01:00
Kayne Ruse cfb8d20ad2 Merge remote-tracking branch 'refs/remotes/origin/main' 2022-05-30 06:10:20 +01:00
Kayne Ruse d44cae397d Updated dependencies, addressed #33 2022-05-30 06:10:01 +01:00
Kayne Ruse b97fff05b3 Added FUNDING.yml 2022-02-13 07:49:49 +11:00
Kayne Ruse 22703bfbcb Swapped day and month around 2022-01-09 15:02:06 +00:00
Kayne Ruse 14a3c9eabe Added timestamps to the chatbox 2022-01-09 06:39:13 +00:00
Kayne Ruse 8e90a4a540 Trying a fix 2022-01-08 04:59:21 +00:00
Kayne Ruse 1d3c94a1aa Shortened the code with a ternary 2022-01-06 14:26:30 +00:00
Kayne Ruse ca5e79ccf3 Merge pull request #32 from kcampbelljr/macos-docs
Macos docs
2022-01-07 01:15:36 +11:00
Kayne Ruse 03acce1907 Removed an unused dependency 2022-01-06 14:00:51 +00:00
Keith Campbell c0b7280533 removed macos, updated code on original configure script, testing.. 2022-01-05 23:23:09 -05:00
Keith Campbell 2925cce7ca created a copy of the configure script and made the changes needed for now, should we add a macos check to the original configure script instead? 2022-01-04 23:51:02 -05:00
Kayne Ruse b90670b922 Tweaked credits 2022-01-03 19:21:57 +00:00
Kayne Ruse 290f25f898 Added prox to the credits 2022-01-03 08:45:27 +00:00
Kayne Ruse 3cdef433f9 Tweaked moderator privileges 2022-01-02 18:11:11 +00:00
Kayne Ruse 53c8ddab54 Removed rehype-raw 2021-12-30 14:28:10 +00:00
Kayne Ruse 4e94c5338d Removed client-side markdown rendering 2021-12-30 13:21:34 +00:00
Kayne Ruse 55ff5765c6 Swapped out a library 2021-12-27 03:34:00 +00:00
Kayne Ruse d486059430 Updated webpack.config.js 2021-12-26 16:12:23 +00:00
Kayne Ruse 9d8c948dbb Updated dependencies 2021-12-24 07:37:43 +00:00
Kayne Ruse b21fa8db9e Tweaked webpack.config.js 2021-12-20 13:52:43 +00:00
Kayne Ruse c130b74e2d Added an example proxy route to webpack.config.js 2021-12-20 07:33:01 +00:00
Kayne Ruse d37b93d5f7 Updated webpack-dev-server to 4.6.0 2021-12-20 07:07:36 +00:00
Kayne Ruse 829cb2e3da Disabled source map in prod 2021-12-20 06:19:23 +00:00
Kayne Ruse 29f0dbb1ca Fixed HTTPS redirection 2021-12-15 18:39:37 +00:00
Kayne Ruse 13ad7d2435 Updated README.md 2021-12-11 16:57:48 +00:00
Kayne Ruse e30853e0cd Updated configure-script.js 2021-12-11 11:38:17 +00:00
Kayne Ruse 1e16a96f86 Updated README.md 2021-12-11 05:01:10 +00:00
Kayne Ruse cff73107b2 Updated package-lock.json 2021-11-17 06:13:41 +00:00
36 changed files with 4332 additions and 9613 deletions
+5
View File
@@ -0,0 +1,5 @@
# These are supported funding model platforms
patreon: krgamestudios
ko_fi: krgamestudios
custom: ["https://www.paypal.com/donate/?hosted_button_id=73Q82T2ZHV8AA"]
+1
View File
@@ -56,6 +56,7 @@ To set up this template in development mode:
- Account deletion
- Password management
- JSON web token authentication
- Optional post validation hook
- Fully Featured News Blog (as a microservice)
- Publish, edit or delete articles as needed
- Secured via admin panel
-10
View File
@@ -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)
-4
View File
@@ -1,4 +0,0 @@
<header>
<h1 class="text centered">Privacy Policy</h1>
</header>
+1 -5
View File
@@ -24,10 +24,7 @@ const Account = props => {
//grab the user's info
useEffect(() => {
authTokens.tokenFetch(`${process.env.AUTH_URI}/auth/account`, {
method: 'GET',
headers: {
'Access-Control-Allow-Origin': '*'
}
method: 'GET'
})
.then(blob => blob.json())
.then(json => contactRef.current.checked = json.contact)
@@ -88,7 +85,6 @@ const update = async (password, retype, contact, tokenFetch) => {
const result = await tokenFetch(`${process.env.AUTH_URI}/auth/account`, {
method: 'PATCH',
headers: {
'Access-Control-Allow-Origin': '*',
'Content-Type': 'application/json'
},
body: JSON.stringify({
+1 -2
View File
@@ -72,8 +72,7 @@ const handleSubmit = async (email, password) => {
const result = await fetch(`${process.env.AUTH_URI}/auth/login`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*'
'Content-Type': 'application/json'
},
body: JSON.stringify({
email,
@@ -38,7 +38,6 @@ const handleSubmit = async (password, authTokens) => {
const result = await authTokens.tokenFetch(`${process.env.AUTH_URI}/auth/account`, {
method: 'DELETE',
headers: {
'Access-Control-Allow-Origin': '*',
'Content-Type': 'application/json'
},
body: JSON.stringify({
@@ -54,7 +53,6 @@ const handleSubmit = async (password, authTokens) => {
const result2 = await authTokens.tokenFetch(`${process.env.AUTH_URI}/auth/logout`, {
method: 'DELETE',
headers: {
'Access-Control-Allow-Origin': '*',
'Content-Type': 'application/json'
},
body: JSON.stringify({
+1 -2
View File
@@ -14,8 +14,7 @@ const Logout = () => {
const result = await authTokens.tokenFetch(`${process.env.AUTH_URI}/auth/logout`, { //NOTE: this gets overwritten as a bugfix
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*'
'Content-Type': 'application/json'
},
body: JSON.stringify({
token: authTokens.refreshToken
+1 -2
View File
@@ -66,8 +66,7 @@ const handleSubmit = async (email) => {
const result = await fetch(`${process.env.AUTH_URI}/auth/recover`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*'
'Content-Type': 'application/json'
},
body: JSON.stringify({
email
-1
View File
@@ -68,7 +68,6 @@ const update = async (password, retype, query) => {
const result = await fetch(`${process.env.AUTH_URI}/auth/reset?email=${query.email}&token=${query.token}`, {
method: 'PATCH',
headers: {
'Access-Control-Allow-Origin': '*',
'Content-Type': 'application/json'
},
body: JSON.stringify({
+1 -2
View File
@@ -83,8 +83,7 @@ const handleSubmit = async (email, username, password, retype, contact) => {
const result = await fetch(`${process.env.AUTH_URI}/auth/signup`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*'
'Content-Type': 'application/json'
},
body: JSON.stringify({
email,
-6
View File
@@ -5,9 +5,6 @@ import ApplyToBody from '../utilities/apply-to-body';
import { TokenContext } from '../utilities/token-provider';
import NewsPublisher from './panels/news-publisher';
import NewsEditor from './panels/news-editor';
import GrantAdmin from './panels/grant-admin';
import GrantMod from './panels/grant-mod';
@@ -26,9 +23,6 @@ const Admin = props => {
<div className='page panel'>
<div className='central panel'>
<h1 className='text centered'>Administration Tools</h1>
<NewsPublisher />
<br />
<NewsEditor />
<br />
<GrantAdmin />
<br />
+8
View File
@@ -5,6 +5,9 @@ import ApplyToBody from '../utilities/apply-to-body';
import { TokenContext } from '../utilities/token-provider';
import NewsPublisher from './panels/news-publisher';
import NewsEditor from './panels/news-editor';
import ChatReports from './panels/chat-reports';
import BanUser from './panels/ban-user';
@@ -23,7 +26,12 @@ const Mod = props => {
<div className='page panel'>
<div className='central panel'>
<h1 className='text centered'>Moderation Tools</h1>
<NewsPublisher />
<br />
<NewsEditor />
<br />
<BanUser />
<br />
<ChatReports />
<Link to='/' className='text centered'>Return Home</Link>
</div>
@@ -42,8 +42,7 @@ const handleButtonPress = async (username, tokenFetch) => {
const result = await tokenFetch(`${process.env.AUTH_URI}/admin/banuser`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*'
'Content-Type': 'application/json'
},
body: JSON.stringify({
username
@@ -8,12 +8,7 @@ const ChatReports = props => {
const authTokens = useContext(TokenContext);
useEffect(async () => {
const result = await authTokens.tokenFetch(`${process.env.CHAT_URI}/admin/reports`, {
method: 'GET',
headers: {
'Access-Control-Allow-Origin': '*'
}
});
const result = await authTokens.tokenFetch(`${process.env.CHAT_URI}/admin/reports`);
if (!result.ok) {
const err = `${result.status}: ${await result.text()}`;
@@ -59,8 +54,7 @@ const deleteReportsFor = (chatlogIndex, tokenFetch, setReports) => {
tokenFetch(`${process.env.CHAT_URI}/admin/reports`, {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*'
'Content-Type': 'application/json'
},
body: JSON.stringify({ chatlogIndex })
});
@@ -51,8 +51,7 @@ const handleButtonPress = async (username, tokenFetch, method) => {
const result = await tokenFetch(`${process.env.AUTH_URI}/admin/admin`, {
method: method,
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*'
'Content-Type': 'application/json'
},
body: JSON.stringify({
username
@@ -51,8 +51,7 @@ const handleButtonPress = async (username, tokenFetch, method) => {
const result = await tokenFetch(`${process.env.AUTH_URI}/admin/mod`, {
method: method,
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*'
'Content-Type': 'application/json'
},
body: JSON.stringify({
username
@@ -1,5 +1,5 @@
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';
@@ -21,8 +21,7 @@ const NewsEditor = props => {
const result = await fetch(`${process.env.NEWS_URI}/news/metadata?limit=999`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*'
'Content-Type': 'application/json'
},
});
@@ -39,16 +38,10 @@ const NewsEditor = props => {
<div className='panel'>
<h2 className='text centered'>News Editor</h2>
<Select
options={articles.map(article => { return { label: article.title, value: article.index }; })}
onChange={async values => {
options={articles.map(article => { return { label: article.title, index: article.index }; })}
onChange={async ({index}) => {
//fetch this article
const index = values[0].value;
const result = await fetch(`${process.env.NEWS_URI}/news/archive/${index}`, {
headers: {
'Access-Control-Allow-Origin': '*'
}
});
const result = await fetch(`${process.env.NEWS_URI}/news/archive/${index}`);
if (!result.ok) {
const err = `${result.status}: ${await result.text()}`;
@@ -109,8 +102,7 @@ const handleSubmit = async (title, author, body, index, tokenFetch) => {
const result = await tokenFetch(`${process.env.NEWS_URI}/news/${index}`, {
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*'
'Content-Type': 'application/json'
},
body: JSON.stringify({
title,
@@ -28,7 +28,7 @@ const NewsPublisher = props => {
<input type='text' name='title' placeholder='Title' ref={titleRef} />
<input type='text' name='author' placeholder='Author' ref={authorRef} />
<textarea name='body' rows='10' cols='150' placeholder='Body of the article goes here...' ref={bodyRef} />
<button type='submit'>Publish</button>
</form>
</div>
@@ -46,8 +46,7 @@ const handleSubmit = async (title, author, body, tokenFetch) => {
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*'
'Content-Type': 'application/json'
},
body: JSON.stringify({
title,
+2 -3
View File
@@ -5,7 +5,6 @@ import { TokenContext } from './utilities/token-provider';
//library components
import LazyRoute from './utilities/lazy-route';
import MarkdownPage from './utilities/markdown-page';
//styling
import '../styles/styles.css';
@@ -34,8 +33,8 @@ const App = props => {
<LazyRoute path='/admin' component={() => import('./administration/admin')} />
<LazyRoute path='/mod' component={() => import('./administration/mod')} />
<LazyRoute path='/privacypolicy' component={async () => () => <MarkdownPage content={require('../markdown/privacy-policy.md').default} />} />
<LazyRoute path='/credits' component={async () => () => <MarkdownPage content={require('../markdown/credits.md').default} />} />
<LazyRoute path='/privacypolicy' component={() => import('./static/privacy-policy')} />
<LazyRoute path='/credits' component={() => import('./static/credits')} />
<LazyRoute path='*' component={() => import('./not-found')} />
</Switch>
-1
View File
@@ -5,7 +5,6 @@ import ApplyToBody from './utilities/apply-to-body';
import { TokenContext } from './utilities/token-provider';
import MarkdownPanel from './utilities/markdown-panel';
import Logout from './accounts/panels/logout';
const Dashboard = props => {
-1
View File
@@ -5,7 +5,6 @@ import ApplyToBody from './utilities/apply-to-body';
import { TokenContext } from './utilities/token-provider';
import MarkdownPanel from './utilities/markdown-panel';
import NewsFeed from './panels/news-feed';
const HomePage = props => {
+1 -1
View File
@@ -13,7 +13,7 @@ const Break = () => {
const Footer = () => {
return (
<footer>
<p className='text centered'>© <a href='https://krgamestudios.com'>KR Game Studios</a> 2020-2021<Break /><Link to='/privacypolicy'>Privacy Policy</Link><Break /><Link to='/credits'>Credits</Link></p>
<p className='text centered'>© <a href='https://krgamestudios.com'>KR Game Studios</a> 2020-2022<Break /><Link to='/privacypolicy'>Privacy Policy</Link><Break /><Link to='/credits'>Credits</Link></p>
</footer>
);
};
+3 -5
View File
@@ -1,8 +1,6 @@
import React, { useState, useEffect, useRef } from 'react';
import dateFormat from 'dateformat';
import MarkdownPanel from '../utilities/markdown-panel';
const NewsFeed = props => {
const [articles, setArticles] = useState([]);
const aborter = useRef(new AbortController()); //BUGFIX: double-renders = double fetches + react update after unmount
@@ -12,8 +10,7 @@ const NewsFeed = props => {
fetch(`${process.env.NEWS_URI}/news`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*'
'Content-Type': 'application/json'
},
signal: aborter.current.signal //oh dear
})
@@ -29,6 +26,7 @@ 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 />
@@ -40,7 +38,7 @@ const NewsFeed = props => {
<span>Published {dateFormat(article.createdAt, 'fullDate')}</span>
}</em></p>
<br />
<MarkdownPanel style={{whiteSpace: 'pre-wrap'}} content={article.body} />
<div dangerouslySetInnerHTML={{ __html: article.rendered }} />
</div>
);
})}
+33 -3
View File
@@ -78,7 +78,7 @@ const handleSend = (inputRef, pushChatlog, username, accessToken) => {
});
if (!inputRef.current.value.startsWith('/')) {
pushChatlog({ username: username, text: inputRef.current.value });
pushChatlog({ createdAt: (new Date(Date.now())).toISOString(), username: username, text: inputRef.current.value });
}
inputRef.current.value = '';
@@ -86,7 +86,36 @@ const handleSend = (inputRef, pushChatlog, username, accessToken) => {
//render each line
const processLine = (line, index, accessToken) => {
let content = <div className='content'>{line.username ? <span className='username'>{line.username}: </span> : ''}{line.text ? <span className='text'>{line.text}</span> : ''}</div>;
//utility functions
const isValidDate = d => {
return d instanceof Date && !isNaN(d);
};
const isToday = d => {
const now = new Date(Date.now());
return d.getDate() == now.getDate() && d.getMonth() == now.getMonth() && d.getFullYear() == now.getFullYear();
};
const isThisYear = d => {
const now = new Date(Date.now());
return d.getFullYear() == now.getFullYear();
};
//parse the date
const date = new Date(line.createdAt);
//split it up so we can format each field individually
const year = `${date.getFullYear()}`;
const month = `${date.getMonth() + 1}`;
const day = `${date.getDate()}`;
const hours = `${date.getHours()}`;
const minutes = `${date.getMinutes()}`.padStart(2, '0');
//combine into the final timestamp
const timestamp = !isValidDate(date) ? '' : isToday(date) ? `${hours}:${minutes}` : isThisYear(date) ? `${month}/${day}` : `${year}`;
//generate the content string
let content = <div className='content row'>{timestamp.length > 0 ? <span className='timestamp col'>{timestamp}</span> : null }<span className='inner col'>{line.username ? <span className='username'>{line.username}: </span> : ''}{line.text ? <span className='text'>{line.text}</span> : ''}</span></div>;
//decorators
if (line.emphasis) {
@@ -97,7 +126,8 @@ const processLine = (line, index, accessToken) => {
content = <strong>{content}</strong>;
}
return <li key={index} className='line'>{content}<a className='report' onClick={() => processReport(line, accessToken)}>!!!</a></li>;
return <li key={index} className='line table noCollapse'>{content}<a className='report' onClick={() => processReport(line, accessToken)}>!!!</a></li>;
};
const processReport = (line, accessToken) => {
+16
View File
@@ -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;
+12
View File
@@ -0,0 +1,12 @@
import React from 'react';
const Static = props => {
return (
<header>
<h1 className="text centered">Privacy Policy</h1>
</header>
);
};
export default Static;
-22
View File
@@ -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;
-35
View File
@@ -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;
+2 -5
View File
@@ -37,7 +37,6 @@ const TokenProvider = props => {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*',
'Authorization': `Bearer ${bearer}`
},
body: JSON.stringify({
@@ -50,8 +49,7 @@ const TokenProvider = props => {
const response = await fetch(`${process.env.AUTH_URI}/auth/token`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*'
'Content-Type': 'application/json'
},
body: JSON.stringify({
token: refreshToken
@@ -91,8 +89,7 @@ const TokenProvider = props => {
const response = await fetch(`${process.env.AUTH_URI}/auth/token`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*'
'Content-Type': 'application/json'
},
body: JSON.stringify({
token: refreshToken
+10
View File
@@ -77,6 +77,16 @@
display: flex;
}
.chat .timestamp {
max-width: 44px;
}
.chat .inner {
flex: 1 !important;
display: inline-block !important;
flex-direction: row !important;
}
.chat .username {
font-weight: bold;
}
+23 -9
View File
@@ -46,6 +46,14 @@ See https://github.com/krgamestudios/MERN-template/wiki for help.
`
);
//determine local computer address for mac user vs everyone else
let macUser = '';
while (macUser.toLowerCase() !== 'yes' && macUser.toLowerCase() !== 'no') {
macUser = await question('Will the MERN Template be running locally on a MacOS system? (yes or no)', '');
}
const localAddress = macUser ? 'localhost' : '%';
//project configuration
const projectName = await question('Project Name', 'template');
const projectWebAddress = await question('Project Web Address', 'example.com');
@@ -62,6 +70,7 @@ See https://github.com/krgamestudios/MERN-template/wiki for help.
//auth configuration
const authName = await question('Auth Name', 'auth');
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 authDBUser = await question('Auth DB Username', authName);
const authDBPass = await question('Auth DB Password', 'charizard');
@@ -180,6 +189,7 @@ services:
environment:
- WEB_PROTOCOL=https
- WEB_ADDRESS=${authWebAddress}
- HOOK_POST_VALIDATION=${authPostValidationHook}
- WEB_RESET_ADDRESS=${authResetAddress}
- WEB_PORT=${authPort}
- DB_HOSTNAME=database
@@ -245,11 +255,14 @@ services:
- --api.insecure=false
- --providers.docker=true
- --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
- --certificatesresolvers.myresolver.acme.tlschallenge=true
- --certificatesresolvers.myresolver.acme.email=${supportEmail}
- --certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json
- traefik.docker.network=app-network
ports:
- 80:80
- 443:443
@@ -279,24 +292,25 @@ CMD ["sleep 10 && npm start"]
const sqlfile = `
CREATE DATABASE IF NOT EXISTS ${projectName};
CREATE USER IF NOT EXISTS '${projectDBUser}'@'%' IDENTIFIED BY '${projectDBPass}';
GRANT ALL PRIVILEGES ON ${projectName}.* TO '${projectDBUser}'@'%';
CREATE USER IF NOT EXISTS '${projectDBUser}'@'${localAddress}' IDENTIFIED BY '${projectDBPass}';
GRANT ALL PRIVILEGES ON ${projectName}.* TO '${projectDBUser}'@'${localAddress}';
CREATE DATABASE IF NOT EXISTS ${newsName};
CREATE USER IF NOT EXISTS '${newsDBUser}'@'%' IDENTIFIED BY '${newsDBPass}';
GRANT ALL PRIVILEGES ON ${newsName}.* TO '${newsDBUser}'@'%';
CREATE USER IF NOT EXISTS '${newsDBUser}'@'${localAddress}' IDENTIFIED BY '${newsDBPass}';
GRANT ALL PRIVILEGES ON ${newsName}.* TO '${newsDBUser}'@'${localAddress}';
CREATE DATABASE IF NOT EXISTS ${authName};
CREATE USER IF NOT EXISTS '${authDBUser}'@'%' IDENTIFIED BY '${authDBPass}';
GRANT ALL PRIVILEGES ON ${authName}.* TO '${authDBUser}'@'%';
CREATE USER IF NOT EXISTS '${authDBUser}'@'${localAddress}' IDENTIFIED BY '${authDBPass}';
GRANT ALL PRIVILEGES ON ${authName}.* TO '${authDBUser}'@'${localAddress}';
CREATE DATABASE IF NOT EXISTS ${chatName};
CREATE USER IF NOT EXISTS '${chatDBUser}'@'%' IDENTIFIED BY '${chatDBPass}';
GRANT ALL PRIVILEGES ON ${chatName}.* TO '${chatDBUser}'@'%';
CREATE USER IF NOT EXISTS '${chatDBUser}'@'${localAddress}' IDENTIFIED BY '${chatDBPass}';
GRANT ALL PRIVILEGES ON ${chatName}.* TO '${chatDBUser}'@'${localAddress}';
FLUSH PRIVILEGES;
`;
fs.writeFileSync('docker-compose.yml', ymlfile);
fs.writeFileSync('Dockerfile', dockerfile);
fs.writeFileSync('startup.sql', sqlfile);
+4160 -9405
View File
File diff suppressed because it is too large Load Diff
+9 -9
View File
@@ -1,6 +1,6 @@
{
"name": "mern-template",
"version": "1.0.6",
"version": "1.2.0",
"description": "A website template using the MERN stack.",
"main": "server/server.js",
"scripts": {
@@ -8,9 +8,12 @@
"build": "npm run build:server && npm run build:client",
"build:server": "exit 0",
"build:client": "webpack --env=production --config webpack.config.js",
"dev": "concurrently npm:watch:server npm:watch:client",
"watch:server": "nodemon ./* --ext js,jsx,json --ignore 'node_modules/*'",
"watch:client": "webpack serve --env=development --config webpack.config.js",
"dev": "concurrently npm:dev:server npm:dev:client",
"dev:server": "nodemon --ext js,jsx,json --ignore 'node_modules/*'",
"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"
},
"repository": {
@@ -40,14 +43,11 @@
"jwt-decode": "^3.1.2",
"mariadb": "^2.5.4",
"query-string": "^7.0.1",
"raw-loader": "^4.0.2",
"react": "^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-dom": "^5.2.0",
"rehype-raw": "^5.1.0",
"react-select": "^5.2.1",
"sequelize": "^6.6.5",
"socket.io-client": "^4.1.3",
"style-loader": "^3.2.1",
@@ -57,6 +57,6 @@
},
"devDependencies": {
"nodemon": "^2.0.12",
"webpack-dev-server": "^3.11.2"
"webpack-dev-server": "^4.6.0"
}
}
+29 -47
View File
@@ -9,7 +9,7 @@ const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const path = require('path');
//the exported config function
module.exports = ({ production, analyze }) => {
module.exports = ({ production, development, local, analyze }) => {
return {
mode: production ? "production" : "development",
entry: path.resolve(__dirname, 'client', 'client.jsx'),
@@ -19,7 +19,7 @@ module.exports = ({ production, analyze }) => {
filename: '[name].[chunkhash].js',
sourceMapFilename: '[name].[chunkhash].js.map'
},
devtool: production ? 'source-map' : 'eval-source-map',
devtool: production ? false : 'eval-source-map',
resolve: {
extensions: ['.js', '.jsx']
},
@@ -42,23 +42,15 @@ module.exports = ({ production, analyze }) => {
test: /\.(css)$/,
use: ['style-loader', 'css-loader']
},
{
test: /\.(md)$/,
use: [
{
loader: 'raw-loader'
},
],
},
]
},
plugins: [
new DefinePlugin({
'process.env': {
'PRODUCTION': production,
'NEWS_URI': production ? `"${process.env.NEWS_URI}"` : '"https://dev-news.krgamestudios.com"',
'AUTH_URI': production ? `"${process.env.AUTH_URI}"` : '"https://dev-auth.krgamestudios.com"',
'CHAT_URI': production ? `"${process.env.CHAT_URI}"` : '"https://dev-chat.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}"` : development ? '"https://dev-auth.krgamestudios.com"' : '"http://localhost:3200"',
'CHAT_URI': production ? `"${process.env.CHAT_URI}"` : development ? '"https://dev-chat.krgamestudios.com"' : '"http://localhost:3300"',
}
}),
new CleanWebpackPlugin({
@@ -83,41 +75,31 @@ module.exports = ({ production, analyze }) => {
})
],
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,
injectHot: true
},
watchOptions: {
ignored: /(node_modules)/
host: 'localhost',
port: 3001,
client: {
overlay: {
errors: true,
warnings: true,
},
},
watchFiles: {
options: {
ignored: ['node_modules/**']
}
},
proxy: {
'/api': {
target: 'http://localhost:3000'
}
},
static: '/public',
historyApiFallback: true
}
}
};