Compare commits
61 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 21f1eac554 | |||
| 789f81129f | |||
| d43e9a3ee2 | |||
| e318d2f621 | |||
| 934fcaa351 | |||
| c0706cd0da | |||
| cd5c648b05 | |||
| 8f22333929 | |||
| d66a07232d | |||
| 2ebb9d4105 | |||
| 3d4df1684c | |||
| 4d99e7bda7 | |||
| 2eda5b0084 | |||
| 7e8c257e17 | |||
| 2468b43b11 | |||
| a38024f179 | |||
| b3aff2b5b4 | |||
| 4c027a41bf | |||
| a91287b34a | |||
| 74050cfc27 | |||
| 3c2b047a33 | |||
| b0cc3f0391 | |||
| dabc719cfd | |||
| a67a855687 | |||
| 704ed6c9d8 | |||
| 88aa68bc47 | |||
| a2526ef845 | |||
| 18ce64ca94 | |||
| aaee9450b8 | |||
| 48a3eed3e6 | |||
| c154f777b4 | |||
| 20377359c6 | |||
| e259f9b1ba | |||
| 377fe8f605 | |||
| fb52787b26 | |||
| 356d0a3638 | |||
| 756680888b | |||
| 63a9790265 | |||
| edd60307e9 | |||
| ddf1fc7979 | |||
| 78dcaed0aa | |||
| f93e1749f7 | |||
| 44a9dbfe13 | |||
| 225890dfd5 | |||
| baebd2d594 | |||
| a2ef968ddf | |||
| 88f44a412b | |||
| 09b08cd791 | |||
| 2964c1e448 | |||
| a2344947f8 | |||
| 52b755fe16 | |||
| b1c31731ee | |||
| b8cc43c556 | |||
| 24b9ff3b5f | |||
| a38b8922a0 | |||
| fcedc00612 | |||
| da4316dccc | |||
| faacb8b8c7 | |||
| c48fcba994 | |||
| 56e3151db0 | |||
| 8aeaa46332 |
@@ -0,0 +1,10 @@
|
||||
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
|
||||
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "npm"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
(I am now *mirroring* to github from my private gitea, because mircrosoft is evil.)
|
||||
|
||||
# MERN-template
|
||||
|
||||
A website template using the MERN stack. It is geared towards Persistent Browser Based Games (think neopets), but is flexible enough for a number of different uses.
|
||||
@@ -44,6 +46,7 @@ To set up this template in development mode:
|
||||
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
|
||||
7. Repeat this process for each microservice (linked above)
|
||||
|
||||
# Features List
|
||||
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
//polyfills
|
||||
import 'regenerator-runtime/runtime';
|
||||
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom/client';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { useEffect, useContext, useRef } from 'react';
|
||||
import { Link, Navigate } from 'react-router-dom';
|
||||
import { Link, Navigate } from 'react-router';
|
||||
|
||||
import ApplyToBody from '../utilities/apply-to-body';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { useContext, useRef } from 'react';
|
||||
import { Link, Navigate } from 'react-router-dom';
|
||||
import { Link, Navigate } from 'react-router';
|
||||
|
||||
import ApplyToBody from '../utilities/apply-to-body';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { useContext, useRef } from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { Link } from 'react-router';
|
||||
|
||||
import { TokenContext } from '../../utilities/token-provider';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { useContext, useRef } from 'react';
|
||||
import { Link, useNavigate } from 'react-router-dom';
|
||||
import { Link, useNavigate } from 'react-router';
|
||||
|
||||
import ApplyToBody from '../utilities/apply-to-body';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { useContext, useRef } from 'react';
|
||||
import { Link, useNavigate, useSearchParams } from 'react-router-dom';
|
||||
import { Link, useNavigate, useSearchParams } from 'react-router';
|
||||
|
||||
import ApplyToBody from '../utilities/apply-to-body';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { useContext, useRef } from 'react';
|
||||
import { Link, useNavigate } from 'react-router-dom';
|
||||
import { Link, useNavigate } from 'react-router';
|
||||
|
||||
import ApplyToBody from '../utilities/apply-to-body';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { useContext } from 'react';
|
||||
import { Link, Navigate } from 'react-router-dom';
|
||||
import { Link, Navigate } from 'react-router';
|
||||
|
||||
import ApplyToBody from '../utilities/apply-to-body';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { useContext } from 'react';
|
||||
import { Link, Navigate } from 'react-router-dom';
|
||||
import { Link, Navigate } from 'react-router';
|
||||
|
||||
import ApplyToBody from '../utilities/apply-to-body';
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//react
|
||||
import React, { useContext, Suspense, lazy } from 'react';
|
||||
import { BrowserRouter, Routes, Route } from 'react-router-dom';
|
||||
import { BrowserRouter, Routes, Route } from 'react-router';
|
||||
import { TokenContext } from './utilities/token-provider';
|
||||
|
||||
//styling
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { useContext } from 'react';
|
||||
import { Link, Navigate } from 'react-router-dom';
|
||||
import { Link, Navigate } from 'react-router';
|
||||
|
||||
import ApplyToBody from './utilities/apply-to-body';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { useContext } from 'react';
|
||||
import { Link, Navigate } from 'react-router-dom';
|
||||
import { Link, Navigate } from 'react-router';
|
||||
|
||||
import ApplyToBody from './utilities/apply-to-body';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { Link } from 'react-router';
|
||||
|
||||
import ApplyToBody from './utilities/apply-to-body';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { Link } from 'react-router';
|
||||
|
||||
const Break = () => {
|
||||
return (
|
||||
@@ -13,7 +13,7 @@ const Break = () => {
|
||||
const Footer = () => {
|
||||
return (
|
||||
<footer>
|
||||
<p className='text centered'>© <a href='https://krgamestudios.com'>KR Game Studios</a> 2020-2024<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-2025<Break /><Link to='/privacypolicy'>Privacy Policy</Link><Break /><Link to='/credits'>Credits</Link></p>
|
||||
</footer>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { Link } from 'react-router';
|
||||
|
||||
const Static = props => {
|
||||
return (
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { Link } from 'react-router';
|
||||
|
||||
const Static = props => {
|
||||
return (
|
||||
|
||||
+16
-15
@@ -46,18 +46,21 @@ 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, this only alters startup.sql)', '');
|
||||
}
|
||||
// //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, this only alters startup.sql)', '');
|
||||
// }
|
||||
|
||||
const localAddress = macUser ? 'localhost' : '%';
|
||||
// const localAddress = macUser === 'yes' ? 'localhost' : '%';
|
||||
const localAddress = '%';
|
||||
|
||||
//project configuration
|
||||
const projectName = await question('Project Name', 'template');
|
||||
const projectWebAddress = await question('Project Web Address', 'example.com');
|
||||
|
||||
const corsWebOrigin = await question('CORS Web Origin', `https://${projectWebAddress}`);
|
||||
|
||||
let projectDBLocation = '';
|
||||
while (typeof projectDBLocation != 'string' || /^[le]/i.test(projectDBLocation[0]) == false) {
|
||||
projectDBLocation = await question('Project [l]ocal or [e]xternal database?');
|
||||
@@ -180,7 +183,7 @@ See https://github.com/krgamestudios/MERN-template/wiki for help.
|
||||
const defaultHost = tmpHost;
|
||||
|
||||
if (defaultUser) {
|
||||
console.log(`Default user email will be: ${defaultUser}@${authWebAddress}`);
|
||||
console.log(`Default user email will be: ${defaultUser}@${defaultHost}`);
|
||||
}
|
||||
|
||||
//traefic configuration
|
||||
@@ -206,6 +209,7 @@ services:
|
||||
- traefik.http.routers.${projectName}router.service=${projectName}service@docker
|
||||
- traefik.http.services.${projectName}service.loadbalancer.server.port=${projectPort}
|
||||
environment:
|
||||
- WEB_ORIGIN=${corsWebOrigin}
|
||||
- WEB_PORT=${projectPort}
|
||||
- DB_HOSTNAME=${projectDBHost}
|
||||
- DB_PORTNAME=${projectDBPort}
|
||||
@@ -218,7 +222,6 @@ services:
|
||||
- CHAT_URI=https://${chatWebAddress}
|
||||
- SECRET_ACCESS=${accessToken}
|
||||
volumes:
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
networks:
|
||||
- app-network
|
||||
@@ -238,6 +241,7 @@ services:
|
||||
- traefik.http.routers.${newsName}router.service=${newsName}service@docker
|
||||
- traefik.http.services.${newsName}service.loadbalancer.server.port=${newsPort}
|
||||
environment:
|
||||
- WEB_ORIGIN=${corsWebOrigin}
|
||||
- WEB_PORT=${newsPort}
|
||||
- DB_HOSTNAME=${newsDBHost}
|
||||
- DB_PORTNAME=${newsDBPort}
|
||||
@@ -248,7 +252,6 @@ services:
|
||||
- PAGE_SIZE=10
|
||||
- SECRET_ACCESS=${accessToken}
|
||||
volumes:
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
networks:
|
||||
- app-network
|
||||
@@ -268,6 +271,7 @@ services:
|
||||
- traefik.http.routers.${authName}router.service=${authName}service@docker
|
||||
- traefik.http.services.${authName}service.loadbalancer.server.port=${authPort}
|
||||
environment:
|
||||
- WEB_ORIGIN=${corsWebOrigin}
|
||||
- WEB_PROTOCOL=https
|
||||
- WEB_ADDRESS=${authWebAddress}
|
||||
- HOOK_POST_VALIDATION_ARRAY=${authPostValidationHookArray}
|
||||
@@ -289,7 +293,6 @@ services:
|
||||
- SECRET_ACCESS=${accessToken}
|
||||
- SECRET_REFRESH=${refreshToken}
|
||||
volumes:
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
networks:
|
||||
- app-network
|
||||
@@ -309,6 +312,7 @@ services:
|
||||
- traefik.http.routers.${chatName}router.service=${chatName}service@docker
|
||||
- traefik.http.services.${chatName}service.loadbalancer.server.port=${chatPort}
|
||||
environment:
|
||||
- WEB_ORIGIN=${corsWebOrigin}
|
||||
- WEB_PORT=${chatPort}
|
||||
- DB_HOSTNAME=${chatDBHost}
|
||||
- DB_PORTNAME=${chatDBPort}
|
||||
@@ -318,7 +322,6 @@ services:
|
||||
- DB_TIMEZONE=${dbTimeZone}
|
||||
- SECRET_ACCESS=${accessToken}
|
||||
volumes:
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
networks:
|
||||
- app-network
|
||||
@@ -335,7 +338,6 @@ ${ [projectDBHost, newsDBHost, authDBHost, chatDBHost].some(x => x == "database"
|
||||
volumes:
|
||||
- ./mysql:/var/lib/mysql
|
||||
- ./startup.sql:/docker-entrypoint-initdb.d/startup.sql:ro
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
networks:
|
||||
- app-network
|
||||
@@ -362,7 +364,6 @@ ${ [projectDBHost, newsDBHost, authDBHost, chatDBHost].some(x => x == "database"
|
||||
volumes:
|
||||
- ./letsencrypt:/letsencrypt
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
networks:
|
||||
- app-network
|
||||
@@ -376,9 +377,9 @@ networks:
|
||||
FROM node:22-bookworm-slim
|
||||
WORKDIR "/app"
|
||||
COPY . /app
|
||||
RUN mkdir /app/public
|
||||
RUN mkdir -p /app/public
|
||||
RUN chown node:node /app/public
|
||||
RUN npm install --production
|
||||
RUN npm install --omit=dev
|
||||
EXPOSE ${projectPort}
|
||||
USER node
|
||||
ENTRYPOINT ["bash", "-c"]
|
||||
|
||||
Generated
+3839
-3246
File diff suppressed because it is too large
Load Diff
+24
-28
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "mern-template",
|
||||
"version": "1.5.1",
|
||||
"version": "1.5.5",
|
||||
"description": "A website template using the MERN stack.",
|
||||
"main": "server/server.js",
|
||||
"scripts": {
|
||||
@@ -10,10 +10,7 @@
|
||||
"build:client": "webpack --env=production --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",
|
||||
"dev:client": "webpack serve --config webpack.config.js",
|
||||
"analyze": "webpack --env=production --env=analyze --config webpack.config.js"
|
||||
},
|
||||
"repository": {
|
||||
@@ -27,34 +24,33 @@
|
||||
},
|
||||
"homepage": "https://github.com/KRGameStudios/MERN-template#readme",
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.24.5",
|
||||
"@babel/preset-env": "^7.24.5",
|
||||
"@babel/preset-react": "^7.24.1",
|
||||
"babel-loader": "^9.1.3",
|
||||
"@babel/core": "^7.29.0",
|
||||
"@babel/preset-env": "^7.29.2",
|
||||
"@babel/preset-react": "^7.28.5",
|
||||
"babel-loader": "^10.1.1",
|
||||
"clean-webpack-plugin": "^4.0.0",
|
||||
"compression-webpack-plugin": "^11.1.0",
|
||||
"concurrently": "^8.2.2",
|
||||
"css-loader": "^7.1.1",
|
||||
"compression-webpack-plugin": "^12.0.0",
|
||||
"concurrently": "^9.2.1",
|
||||
"css-loader": "^7.1.4",
|
||||
"dateformat": "^5.0.3",
|
||||
"dotenv": "^16.4.5",
|
||||
"express": "^4.19.2",
|
||||
"html-webpack-plugin": "^5.6.0",
|
||||
"dotenv": "^17.4.1",
|
||||
"express": "^5.2.1",
|
||||
"html-webpack-plugin": "^5.6.6",
|
||||
"jwt-decode": "^4.0.0",
|
||||
"mariadb": "^3.3.0",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"react-router": "^6.3.0",
|
||||
"react-router-dom": "^6.23.0",
|
||||
"react-select": "^5.8.0",
|
||||
"sequelize": "^6.37.3",
|
||||
"socket.io-client": "^4.7.5",
|
||||
"mariadb": "^3.5.2",
|
||||
"react": "^19.2.4",
|
||||
"react-dom": "^19.2.5",
|
||||
"react-router": "^7.14.0",
|
||||
"react-select": "^5.10.2",
|
||||
"sequelize": "^6.37.8",
|
||||
"socket.io-client": "^4.8.3",
|
||||
"style-loader": "^4.0.0",
|
||||
"webpack": "^5.91.0",
|
||||
"webpack-bundle-analyzer": "^4.10.2",
|
||||
"webpack-cli": "^5.1.4"
|
||||
"webpack": "^5.106.1",
|
||||
"webpack-bundle-analyzer": "^5.3.0",
|
||||
"webpack-cli": "^6.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"nodemon": "^3.1.0",
|
||||
"webpack-dev-server": "^5.0.4"
|
||||
"nodemon": "^3.1.14",
|
||||
"webpack-dev-server": "^5.2.3"
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -13,14 +13,14 @@ const server = require('http').Server(app);
|
||||
app.use(express.json());
|
||||
|
||||
//handle compressed files (middleware)
|
||||
app.get('*.js', (req, res, next) => {
|
||||
app.get('/{*any}.js', (req, res, next) => {
|
||||
req.url = req.url + '.gz';
|
||||
res.set('Content-Encoding', 'gzip');
|
||||
res.set('Content-Type', 'text/javascript');
|
||||
next();
|
||||
});
|
||||
|
||||
app.get('*.css', (req, res, next) => {
|
||||
app.get('/{*any}.css', (req, res, next) => {
|
||||
req.url = req.url + '.gz';
|
||||
res.set('Content-Encoding', 'gzip');
|
||||
res.set('Content-Type', 'text/css');
|
||||
@@ -34,7 +34,7 @@ const database = require('./database');
|
||||
app.use('/', express.static(path.resolve(__dirname, '..', 'public')));
|
||||
|
||||
//fallback to the index file
|
||||
app.get('*', (req, res) => {
|
||||
app.get('/{*any}', (req, res) => {
|
||||
res.sendFile(path.resolve(__dirname, '..', 'public' , 'index.html'));
|
||||
});
|
||||
|
||||
|
||||
+4
-5
@@ -9,7 +9,7 @@ const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
|
||||
const path = require('path');
|
||||
|
||||
//the exported config function
|
||||
module.exports = ({ production, development, local, analyze }) => {
|
||||
module.exports = ({ production, analyze }) => {
|
||||
return {
|
||||
mode: production ? "production" : "development",
|
||||
entry: path.resolve(__dirname, 'client', 'client.jsx'),
|
||||
@@ -33,7 +33,6 @@ module.exports = ({ production, development, local, analyze }) => {
|
||||
loader: 'babel-loader',
|
||||
options: {
|
||||
presets: ['@babel/preset-env', '@babel/preset-react'],
|
||||
plugins: ['@babel/plugin-syntax-dynamic-import']
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -48,9 +47,9 @@ module.exports = ({ production, development, local, analyze }) => {
|
||||
new DefinePlugin({
|
||||
'process.env': {
|
||||
'PRODUCTION': production,
|
||||
'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"',
|
||||
'NEWS_URI': production ? `"${process.env.NEWS_URI}"` : '"http://localhost:3100"',
|
||||
'AUTH_URI': production ? `"${process.env.AUTH_URI}"` : '"http://localhost:3200"',
|
||||
'CHAT_URI': production ? `"${process.env.CHAT_URI}"` : '"http://localhost:3300"',
|
||||
}
|
||||
}),
|
||||
new CleanWebpackPlugin({
|
||||
|
||||
Reference in New Issue
Block a user