Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| eb370663d2 | |||
| 462116d980 | |||
| af06ddc06d | |||
| f937ee47db | |||
| 6d0dd419ca | |||
| 2919467dff | |||
| 269caac88c | |||
| 69c297fa74 | |||
| 0f538be3e5 | |||
| f85b6e8793 | |||
| 2af9532930 | |||
| 191da50740 | |||
| f24c7990f6 | |||
| 7a48780f50 | |||
| 33952a9896 | |||
| 8076b0cc40 | |||
| e216474196 | |||
| 2532bf1867 | |||
| 93a3c30e81 | |||
| ae8c82e83a | |||
| bc6a795750 | |||
| 9947ef13c1 | |||
| d3f0b1ac7d |
@@ -1,6 +1,6 @@
|
||||
WEB_PORT=3000
|
||||
|
||||
DB_HOSTNAME=database
|
||||
DB_HOSTNAME=localhost
|
||||
DB_DATABASE=template
|
||||
DB_USERNAME=template
|
||||
DB_PASSWORD=pikachu
|
||||
@@ -12,4 +12,4 @@ DB_TIMEZONE=Australia/Sydney
|
||||
DB_LOGGING=
|
||||
|
||||
# Make sure this value matches the system that you connect to
|
||||
SECRET_ACCESS=access
|
||||
SECRET_ACCESS=access
|
||||
|
||||
@@ -1,89 +1,91 @@
|
||||
# MERN-template
|
||||
|
||||
A website template using the MERN stack. The primary technology involved is:
|
||||
|
||||
* React
|
||||
* Nodejs
|
||||
* MariaDB (with Sequelize)
|
||||
* Docker (with docker-compose)
|
||||
|
||||
This template is designed to support the development of persistent browser based games (PBBGs), but it, and it's component microservices, can be used elsewhere.
|
||||
|
||||
This template is released under the zlib license (see LICENSE).
|
||||
|
||||
See the [github wiki](https://github.com/krgamestudios/MERN-template/wiki) for full documentation.
|
||||
|
||||
# Microservices
|
||||
|
||||
There are external components to this template referred to as "microservices". These can be omitted entirely by simply removing the React components that access them. These are also available via [docker hub](https://hub.docker.com/u/krgamestudios).
|
||||
|
||||
* News Server: https://github.com/krgamestudios/news-server
|
||||
* Auth Server: https://github.com/krgamestudios/auth-server
|
||||
* Chat Server: https://github.com/krgamestudios/chat-server
|
||||
|
||||
# Setup Deployment
|
||||
|
||||
A clean install is this easy:
|
||||
|
||||
```
|
||||
git clone https://github.com/krgamestudios/MERN-template.git
|
||||
node configure-script.js
|
||||
docker-compose up --build
|
||||
```
|
||||
|
||||
# Setup Development
|
||||
|
||||
To set up this template in development mode:
|
||||
|
||||
1. Ensure mariadb is running in your development environment
|
||||
2. Run `mariadb sql/create_database.sql` as the root user
|
||||
3. Run `npm install`
|
||||
4. Run `cp .envdev .env` and enter your details into the `.env` file
|
||||
5. Execute `npm run dev`
|
||||
6. Navigate to `http://localhost:3001` in your web browser
|
||||
|
||||
# Features List
|
||||
|
||||
- Mainly one language across the codebase (JavaScript)
|
||||
- Full documentation
|
||||
- Setup tutorial
|
||||
- Fully Featured Account System (as a microservice)
|
||||
- Email validation
|
||||
- Logging in and out
|
||||
- Account deletion
|
||||
- Password management
|
||||
- JSON web token authentication
|
||||
- Fully Featured News Blog (as a microservice)
|
||||
- Publish, edit or delete articles as needed
|
||||
- Secured via admin panel
|
||||
- Fully Featured Chat System (as a microservice)
|
||||
- Available when logged in
|
||||
- Chat logs saved to the database
|
||||
- Room-based chat (type `/room name` to access a specific room)
|
||||
- Moderation tools
|
||||
- Permanently banning users
|
||||
- Chat-muting users for a time period
|
||||
- Users reporting offensive chat-content
|
||||
- Easy To Use Configuration Script
|
||||
- Sets up everything via docker
|
||||
- A default admin account (if desired)
|
||||
|
||||
# Coming Soon
|
||||
|
||||
- Full documentation
|
||||
- Modding tutorials
|
||||
|
||||
# Coming Eventually
|
||||
|
||||
- Fully Featured News Blog (as a microservice)
|
||||
- Restore deleted articles
|
||||
- Undo edits
|
||||
- Fully Featured Chat System (as a microservice)
|
||||
- Custom emoji
|
||||
- Private messaging
|
||||
- Broadcasting to all channels
|
||||
- Badges next to usernames
|
||||
- Better compression for client files
|
||||
- Backend for leaderboards (modding tutorial?)
|
||||
- Backend for energy systems (modding tutorial?)
|
||||
- Backend for items, shops, trading and currency
|
||||
# MERN-template
|
||||
|
||||
A website template using the MERN stack. The primary technology involved is:
|
||||
|
||||
* React
|
||||
* Nodejs
|
||||
* MariaDB (with Sequelize)
|
||||
* Docker (with docker-compose)
|
||||
|
||||
This template is designed to support the development of persistent browser based games (PBBGs), but it, and it's component microservices, can be used elsewhere.
|
||||
|
||||
This template is released under the zlib license (see LICENSE).
|
||||
|
||||
See the [github wiki](https://github.com/krgamestudios/MERN-template/wiki) for full documentation.
|
||||
|
||||
# Microservices
|
||||
|
||||
There are external components to this template referred to as "microservices". These can be omitted entirely by simply removing the React components that access them. These are also available via [docker hub](https://hub.docker.com/u/krgamestudios).
|
||||
|
||||
* News Server: https://github.com/krgamestudios/news-server
|
||||
* Auth Server: https://github.com/krgamestudios/auth-server
|
||||
* Chat Server: https://github.com/krgamestudios/chat-server
|
||||
|
||||
# Setup Deployment
|
||||
|
||||
A clean install is this easy:
|
||||
|
||||
```
|
||||
git clone https://github.com/krgamestudios/MERN-template.git
|
||||
cd MERN-template
|
||||
npm install
|
||||
node configure-script.js
|
||||
docker-compose up --build
|
||||
```
|
||||
|
||||
# Setup Development
|
||||
|
||||
To set up this template in development mode:
|
||||
|
||||
1. Ensure mariadb is running in your development environment
|
||||
2. Run `mariadb sql/create_database.sql` as the root user
|
||||
3. Run `npm install`
|
||||
4. Run `cp .envdev .env` and enter your details into the `.env` file
|
||||
5. Execute `npm run dev`
|
||||
6. Navigate to `http://localhost:3001` in your web browser
|
||||
|
||||
# Features List
|
||||
|
||||
- Mainly one language across the codebase (JavaScript)
|
||||
- Full documentation
|
||||
- Setup tutorial
|
||||
- Fully Featured Account System (as a microservice)
|
||||
- Email validation
|
||||
- Logging in and out
|
||||
- Account deletion
|
||||
- Password management
|
||||
- JSON web token authentication
|
||||
- Fully Featured News Blog (as a microservice)
|
||||
- Publish, edit or delete articles as needed
|
||||
- Secured via admin panel
|
||||
- Fully Featured Chat System (as a microservice)
|
||||
- Available when logged in
|
||||
- Chat logs saved to the database
|
||||
- Room-based chat (type `/room name` to access a specific room)
|
||||
- Moderation tools
|
||||
- Permanently banning users
|
||||
- Chat-muting users for a time period
|
||||
- Users reporting offensive chat-content
|
||||
- Easy To Use Configuration Script
|
||||
- Sets up everything via docker
|
||||
- A default admin account (if desired)
|
||||
|
||||
# Coming Soon
|
||||
|
||||
- Full documentation
|
||||
- Modding tutorials
|
||||
|
||||
# Coming Eventually
|
||||
|
||||
- Fully Featured News Blog (as a microservice)
|
||||
- Restore deleted articles
|
||||
- Undo edits
|
||||
- Fully Featured Chat System (as a microservice)
|
||||
- Custom emoji
|
||||
- Private messaging
|
||||
- Broadcasting to all channels
|
||||
- Badges next to usernames
|
||||
- Better compression for client files
|
||||
- Backend for leaderboards (modding tutorial?)
|
||||
- Backend for energy systems (modding tutorial?)
|
||||
- Backend for items, shops, trading and currency
|
||||
|
||||
@@ -29,6 +29,9 @@ const App = props => {
|
||||
<LazyRoute path='/login' component={() => import('./pages/login')} />
|
||||
<LazyRoute path='/account' component={() => import('./pages/account')} />
|
||||
|
||||
<LazyRoute path='/recover' component={() => import('./pages/recover')} />
|
||||
<LazyRoute path='/reset' component={() => import('./pages/reset')} />
|
||||
|
||||
<LazyRoute path='/admin' component={() => import('./pages/admin')} />
|
||||
<LazyRoute path='/mod' component={() => import('./pages/mod')} />
|
||||
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
import React, { useContext, useRef } from 'react';
|
||||
import { Redirect } from 'react-router-dom';
|
||||
|
||||
import { TokenContext } from '../utilities/token-provider';
|
||||
|
||||
//utilities
|
||||
const validateEmail = require('../../../common/utilities/validate-email');
|
||||
|
||||
const Recover = props => {
|
||||
//context
|
||||
const authTokens = useContext(TokenContext);
|
||||
|
||||
//misplaced?
|
||||
if (authTokens.accessToken) {
|
||||
return <Redirect to='/' />;
|
||||
}
|
||||
|
||||
//refs
|
||||
const emailRef = useRef();
|
||||
const recoverRef = useRef();
|
||||
|
||||
return (
|
||||
<div className='page'>
|
||||
<h1 className='centered'>Recover Password</h1>
|
||||
<form className='constricted' onSubmit={
|
||||
async evt => { //on submit
|
||||
recoverRef.current.disabled = true;
|
||||
evt.preventDefault();
|
||||
const [result, redirect] = await handleSubmit(emailRef.current.value);
|
||||
if (result) {
|
||||
alert(result);
|
||||
recoverRef.current.disabled = false;
|
||||
}
|
||||
|
||||
//redirect
|
||||
if (redirect) {
|
||||
props.history.push('/');
|
||||
}
|
||||
}
|
||||
}>
|
||||
<div>
|
||||
<label htmlFor='email'>Enter Your Email:</label>
|
||||
<input type='email' name='email' ref={emailRef} />
|
||||
</div>
|
||||
|
||||
<button type='submit' ref={recoverRef}>Recover Password</button>
|
||||
</form>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const handleSubmit = async (email) => {
|
||||
email = email.trim();
|
||||
|
||||
const err = handleValidation(email);
|
||||
|
||||
if (err) {
|
||||
return [err];
|
||||
}
|
||||
|
||||
//send to the auth server
|
||||
const result = await fetch(`${process.env.AUTH_URI}/auth/recover`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Access-Control-Allow-Origin': '*'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
email
|
||||
})
|
||||
});
|
||||
|
||||
if (!result.ok) {
|
||||
const err = `${result.status}: ${await result.text()}`;
|
||||
console.error(err);
|
||||
return [err, false];
|
||||
}
|
||||
|
||||
return [await result.text(), true];
|
||||
};
|
||||
|
||||
//returns an error message, or null on success
|
||||
const handleValidation = (email) => {
|
||||
if (!validateEmail(email)) {
|
||||
return 'invalid email';
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
export default Recover;
|
||||
@@ -0,0 +1,89 @@
|
||||
import React, { useContext, useRef } from 'react';
|
||||
import { Redirect } from 'react-router-dom';
|
||||
import queryString from 'query-string';
|
||||
|
||||
import { TokenContext } from '../utilities/token-provider';
|
||||
|
||||
const Reset = props => {
|
||||
//context
|
||||
const authTokens = useContext(TokenContext);
|
||||
|
||||
//query
|
||||
const query = queryString.parse(props.location.search);
|
||||
|
||||
//misplaced?
|
||||
if (authTokens.accessToken || !query.email || !query.token) {
|
||||
return <Redirect to='/' />;
|
||||
}
|
||||
|
||||
//refs
|
||||
const passwordRef = useRef();
|
||||
const retypeRef = useRef();
|
||||
const resetRef = useRef();
|
||||
|
||||
//render the thing
|
||||
return (
|
||||
<div className='page'>
|
||||
<h1 className='centered'>Reset Password</h1>
|
||||
<form className='constricted' onSubmit={async evt => {
|
||||
evt.preventDefault();
|
||||
const [err] = await update(passwordRef.current.value, retypeRef.current.value, query);
|
||||
|
||||
if (err) {
|
||||
alert(err);
|
||||
return;
|
||||
}
|
||||
|
||||
alert('Details updated');
|
||||
|
||||
//redirect
|
||||
if (redirect) {
|
||||
props.history.push('/');
|
||||
}
|
||||
}}>
|
||||
<div>
|
||||
<div>
|
||||
<label htmlFor='password'>Enter New Password:</label>
|
||||
<input type='password' name='password' ref={passwordRef} />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label htmlFor='retype'>Retype New Password:</label>
|
||||
<input type='password' name='retype' ref={retypeRef} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type='submit'>Update Information</button>
|
||||
</form>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const update = async (password, retype, query) => {
|
||||
if (password != retype) {
|
||||
return ['Passwords do not match'];
|
||||
}
|
||||
|
||||
if (password && password.length < 8) {
|
||||
return ['Password is too short'];
|
||||
}
|
||||
|
||||
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({
|
||||
password: password ? password : null,
|
||||
})
|
||||
});
|
||||
|
||||
if (!result.ok) {
|
||||
return [`${await result.status}: ${await result.text()}`];
|
||||
} else {
|
||||
return [null];
|
||||
}
|
||||
}
|
||||
|
||||
export default Reset;
|
||||
@@ -22,16 +22,19 @@ const SignUp = props => {
|
||||
const passwordRef = useRef();
|
||||
const retypeRef = useRef();
|
||||
const contactRef = useRef();
|
||||
const signupRef = useRef();
|
||||
|
||||
return (
|
||||
<div className='page'>
|
||||
<h1 className='centered'>Signup</h1>
|
||||
<form className='constricted' onSubmit={
|
||||
async evt => { //on submit
|
||||
signupRef.current.disabled = true;
|
||||
evt.preventDefault();
|
||||
const [result, redirect] = await handleSubmit(emailRef.current.value, usernameRef.current.value, passwordRef.current.value, retypeRef.current.value, contactRef.current.checked);
|
||||
if (result) {
|
||||
alert(result);
|
||||
signupRef.current.disabled = false;
|
||||
}
|
||||
|
||||
//redirect
|
||||
@@ -65,7 +68,7 @@ const SignUp = props => {
|
||||
<input type='checkbox' name='contact' ref={contactRef} />
|
||||
</div>
|
||||
|
||||
<button type='submit'>Signup</button>
|
||||
<button type='submit' ref={signupRef}>Signup</button>
|
||||
</form>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -43,7 +43,7 @@ const ChatReports = props => {
|
||||
<td>{report.chatlog.room}</td>
|
||||
<td>{report.chatlog.text}</td>
|
||||
<td>{report.reporter.join(', ')}</td>
|
||||
<td><button onClick={() => deleteReportsFor(report.chatlogId, authTokens.tokenFetch, setReports)}>Delete</button></td>
|
||||
<td><button onClick={() => deleteReportsFor(report.chatlogIndex, authTokens.tokenFetch, setReports)}>Delete</button></td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
@@ -51,17 +51,17 @@ const ChatReports = props => {
|
||||
);
|
||||
};
|
||||
|
||||
const deleteReportsFor = (chatlogId, tokenFetch, setReports) => {
|
||||
const deleteReportsFor = (chatlogIndex, tokenFetch, setReports) => {
|
||||
tokenFetch(`${process.env.CHAT_URI}/admin/reports`, {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Access-Control-Allow-Origin': '*'
|
||||
},
|
||||
body: JSON.stringify({ chatlogId })
|
||||
body: JSON.stringify({ chatlogIndex })
|
||||
});
|
||||
|
||||
setReports(reports => reports.filter(report => report.chatlogId != chatlogId));
|
||||
setReports(reports => reports.filter(report => report.chatlogIndex != chatlogIndex));
|
||||
};
|
||||
|
||||
export default ChatReports;
|
||||
@@ -9,6 +9,8 @@ const Visitor = () => {
|
||||
<Link to='/signup'>Sign Up</Link>
|
||||
<span> - </span>
|
||||
<Link to='/login'>Log In</Link>
|
||||
<span> - </span>
|
||||
<Link to='/recover'>Recover</Link>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import ReactMarkdown from 'react-markdown/with-html';
|
||||
import ReactMarkdown from 'react-markdown';
|
||||
import rehypeRaw from 'rehype-raw';
|
||||
|
||||
const Markdown = props => {
|
||||
//content?
|
||||
@@ -27,7 +28,7 @@ const Markdown = props => {
|
||||
}
|
||||
|
||||
return (
|
||||
<ReactMarkdown escapeHtml={false} props={{...props}}>{contentHook}</ReactMarkdown>
|
||||
<ReactMarkdown rehypePlugins={[rehypeRaw]} escapeHtml={false} props={{...props}}>{contentHook}</ReactMarkdown>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -26,7 +26,21 @@ const NewsFeed = props => {
|
||||
return (
|
||||
<div>
|
||||
<h1 className='centered'>News Feed</h1>
|
||||
{articles.map((article, index) => {
|
||||
{(articles || []).map((article, index) => {
|
||||
//BUGFIX: check for empty data
|
||||
if (!article.title) {
|
||||
return article.title = '';
|
||||
}
|
||||
|
||||
if (!article.author) {
|
||||
return article.author = '';
|
||||
}
|
||||
|
||||
if (!article.body) {
|
||||
return article.body = '';
|
||||
}
|
||||
|
||||
//render
|
||||
return (
|
||||
<div key={index}>
|
||||
<hr />
|
||||
|
||||
@@ -96,7 +96,7 @@ const processLine = (line, index, accessToken) => {
|
||||
content = <strong>{content}</strong>;
|
||||
}
|
||||
|
||||
return <li key={index} className='line'>{content}<div className='report'><a onClick={() => processReport(line, accessToken)} style={{ display: line.id && !line.notification ? 'flex' : 'none' }}>!!!</a></div></li>;
|
||||
return <li key={index} className='line'>{content}<div className='report'><a onClick={() => processReport(line, accessToken)} style={{ display: line.index && !line.notification ? 'flex' : 'none' }}>!!!</a></div></li>;
|
||||
};
|
||||
|
||||
const processReport = (line, accessToken) => {
|
||||
@@ -105,7 +105,7 @@ const processReport = (line, accessToken) => {
|
||||
if (yes) {
|
||||
socket.emit('report', {
|
||||
accessToken,
|
||||
id: line.id
|
||||
index: line.index
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
+9
-5
@@ -57,13 +57,14 @@ See https://github.com/krgamestudios/MERN-template/wiki for help.
|
||||
const newsName = await question('News Name', 'news');
|
||||
const newsWebAddress = await question('News Web Address', `${newsName}.${projectWebAddress}`);
|
||||
const newsDBUser = await question('News DB Username', newsName);
|
||||
const newsDBPass = await question('News DB Password', 'charizard');
|
||||
const newsDBPass = await question('News DB Password', 'venusaur');
|
||||
|
||||
//auth configuration
|
||||
const authName = await question('Auth Name', 'auth');
|
||||
const authWebAddress = await question('Auth Web Address', `${authName}.${projectWebAddress}`);
|
||||
const authResetAddress = await question('Auth Reset Addr', `${projectWebAddress}/reset`);
|
||||
const authDBUser = await question('Auth DB Username', authName);
|
||||
const authDBPass = await question('Auth DB Password', 'venusaur');
|
||||
const authDBPass = await question('Auth DB Password', 'charizard');
|
||||
|
||||
const emailSMTP = await question('Email SMTP', 'smtp.example.com');
|
||||
const emailUser = await question('Email Address', 'foobar@example.com');
|
||||
@@ -123,7 +124,7 @@ services:
|
||||
- traefik.http.routers.${projectName}router.service=${projectName}service@docker
|
||||
- traefik.http.services.${projectName}service.loadbalancer.server.port=${projectPort}
|
||||
environment:
|
||||
- WEB_PORT=3000
|
||||
- WEB_PORT=${projectPort}
|
||||
- DB_HOSTNAME=database
|
||||
- DB_DATABASE=${projectName}
|
||||
- DB_USERNAME=${projectDBUser}
|
||||
@@ -179,6 +180,7 @@ services:
|
||||
environment:
|
||||
- WEB_PROTOCOL=https
|
||||
- WEB_ADDRESS=${authWebAddress}
|
||||
- WEB_RESET_ADDRESS=${authResetAddress}
|
||||
- WEB_PORT=${authPort}
|
||||
- DB_HOSTNAME=database
|
||||
- DB_DATABASE=${authName}
|
||||
@@ -265,10 +267,12 @@ networks:
|
||||
const dockerfile = `
|
||||
FROM node:15
|
||||
WORKDIR "/app"
|
||||
COPY package*.json ./
|
||||
RUN npm install
|
||||
COPY . /app
|
||||
RUN mkdir /app/public
|
||||
RUN chown node:node /app/public
|
||||
RUN npm install --production
|
||||
EXPOSE ${projectPort}
|
||||
USER node
|
||||
ENTRYPOINT ["bash", "-c"]
|
||||
CMD ["sleep 10 && npm start"]
|
||||
`;
|
||||
|
||||
Generated
+3605
-3094
File diff suppressed because it is too large
Load Diff
+61
-60
@@ -1,60 +1,61 @@
|
||||
{
|
||||
"name": "mern-template",
|
||||
"version": "1.0.0",
|
||||
"description": "A website template using the MERN stack.",
|
||||
"main": "server/server.js",
|
||||
"scripts": {
|
||||
"start": "npm run build && node server/server.js",
|
||||
"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",
|
||||
"analyzer": "webpack --env=production --analyzer --config webpack.config.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/KRGameStudios/MERN-template.git"
|
||||
},
|
||||
"author": "Kayne Ruse",
|
||||
"license": "ISC",
|
||||
"bugs": {
|
||||
"url": "https://github.com/KRGameStudios/MERN-template/issues"
|
||||
},
|
||||
"homepage": "https://github.com/KRGameStudios/MERN-template#readme",
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.12.10",
|
||||
"@babel/preset-env": "^7.12.11",
|
||||
"@babel/preset-react": "^7.12.10",
|
||||
"@loadable/component": "^5.14.1",
|
||||
"babel-loader": "^8.2.2",
|
||||
"clean-webpack-plugin": "^3.0.0",
|
||||
"concurrently": "^5.3.0",
|
||||
"css-loader": "^5.1.3",
|
||||
"dateformat": "^4.5.1",
|
||||
"dotenv": "^8.2.0",
|
||||
"express": "^4.17.1",
|
||||
"html-webpack-plugin": "^5.0.0-alpha.14",
|
||||
"jwt-decode": "^3.1.2",
|
||||
"mariadb": "^2.5.2",
|
||||
"raw-loader": "^4.0.2",
|
||||
"react": "^17.0.1",
|
||||
"react-dom": "^17.0.1",
|
||||
"react-dropdown-select": "^4.7.4",
|
||||
"react-markdown": "^5.0.3",
|
||||
"react-router": "^5.2.0",
|
||||
"react-router-dom": "^5.2.0",
|
||||
"sequelize": "^6.4.0",
|
||||
"socket.io-client": "^4.0.0",
|
||||
"style-loader": "^2.0.0",
|
||||
"universal-cookie": "^4.0.4",
|
||||
"webpack": "^5.15.0",
|
||||
"webpack-cli": "^4.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"nodemon": "^2.0.7",
|
||||
"webpack-bundle-analyzer": "^4.3.0",
|
||||
"webpack-dev-server": "^3.11.2"
|
||||
}
|
||||
}
|
||||
{
|
||||
"name": "mern-template",
|
||||
"version": "1.0.2",
|
||||
"description": "A website template using the MERN stack.",
|
||||
"main": "server/server.js",
|
||||
"scripts": {
|
||||
"start": "npm run build && node server/server.js",
|
||||
"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",
|
||||
"analyzer": "webpack --env=production --analyzer --config webpack.config.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/KRGameStudios/MERN-template.git"
|
||||
},
|
||||
"author": "Kayne Ruse",
|
||||
"license": "ISC",
|
||||
"bugs": {
|
||||
"url": "https://github.com/KRGameStudios/MERN-template/issues"
|
||||
},
|
||||
"homepage": "https://github.com/KRGameStudios/MERN-template#readme",
|
||||
"dependencies": {
|
||||
"@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",
|
||||
"concurrently": "^6.2.0",
|
||||
"css-loader": "^6.2.0",
|
||||
"dateformat": "^4.5.1",
|
||||
"dotenv": "^10.0.0",
|
||||
"express": "^4.17.1",
|
||||
"html-webpack-plugin": "^5.3.2",
|
||||
"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",
|
||||
"sequelize": "^6.6.5",
|
||||
"socket.io-client": "^4.1.3",
|
||||
"style-loader": "^3.2.1",
|
||||
"webpack": "^5.46.0",
|
||||
"webpack-bundle-analyzer": "^4.4.2",
|
||||
"webpack-cli": "^4.7.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"nodemon": "^2.0.12",
|
||||
"webpack-dev-server": "^3.11.2"
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -8,10 +8,9 @@ const path = require('path');
|
||||
const express = require('express');
|
||||
const app = express();
|
||||
const server = require('http').Server(app);
|
||||
const bodyParser = require('body-parser');
|
||||
|
||||
//config
|
||||
app.use(bodyParser.json());
|
||||
app.use(express.json());
|
||||
|
||||
//database connection
|
||||
const database = require('./database');
|
||||
|
||||
+4
-4
@@ -18,7 +18,7 @@ module.exports = ({ production, analyzer }) => {
|
||||
filename: '[name].[chunkhash].js',
|
||||
sourceMapFilename: '[name].[chunkhash].js.map'
|
||||
},
|
||||
devtool: 'eval-source-map',
|
||||
devtool: production ? 'source-map' : 'eval-source-map',
|
||||
resolve: {
|
||||
extensions: ['.js', '.jsx']
|
||||
},
|
||||
@@ -55,9 +55,9 @@ module.exports = ({ production, analyzer }) => {
|
||||
new DefinePlugin({
|
||||
'process.env': {
|
||||
'PRODUCTION': production,
|
||||
'NEWS_URI': production ? `"${process.env.NEWS_URI}"` : '"https://dev-news.eggtrainer.com"',
|
||||
'AUTH_URI': production ? `"${process.env.AUTH_URI}"` : '"https://dev-auth.eggtrainer.com"',
|
||||
'CHAT_URI': production ? `"${process.env.CHAT_URI}"` : '"https://dev-chat.eggtrainer.com"',
|
||||
'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"',
|
||||
}
|
||||
}),
|
||||
new CleanWebpackPlugin({
|
||||
|
||||
Reference in New Issue
Block a user