11 Commits
main ... images

Author SHA1 Message Date
Ben Elferink
296effed4f chore: update preview 2024-12-14 16:17:17 +02:00
Ben Elferink
e1e38bc708 Delete Screen Shot 2021-09-28 at 19.02.24.png 2021-09-29 11:09:53 +03:00
Ben Elferink
8c7dfde584 Delete Screen Shot 2021-09-28 at 19.02.33.png 2021-09-29 11:09:38 +03:00
Ben Elferink
05244227b9 Delete Screen Shot 2021-09-29 at 10.59.42.png 2021-09-29 11:09:34 +03:00
Ben Elferink
3a29842cba Add files via upload 2021-09-29 11:08:44 +03:00
Ben Elferink
69b5c09ed4 Add files via upload 2021-09-29 11:03:05 +03:00
Ben Elferink
0f3f6045b9 Delete server directory 2021-09-29 11:02:17 +03:00
Ben Elferink
1c17915ea2 Delete client directory 2021-09-29 11:01:42 +03:00
Ben Elferink
8efebf7a31 Add files via upload 2021-09-28 19:04:30 +03:00
Ben Elferink
074bca9835 added mern banner image 2020-12-22 00:28:18 +02:00
Ben Elferink
c7fd68ba70 added images for mongodb wiki 2020-12-22 00:15:03 +02:00
20 changed files with 16 additions and 173 deletions

14
.gitignore vendored
View File

@@ -1,2 +1,14 @@
/node_modules # dependencies
node_modules
.pnp
.pnp.js
# production
build
dist
# misc
.env
.DS_Store .DS_Store
*.log
*.pid

View File

@@ -1,49 +1,8 @@
# MERN Stack Template # MERN Stack Template
<img src='https://raw.githubusercontent.com/BenElferink/mern-template/refs/heads/images/images/mern.jpeg' />
- **M** = [MongoDB](https://www.mongodb.com) - **M** = [MongoDB](https://www.mongodb.com)
- **E** = [Express.js](https://expressjs.com) - **E** = [Express.js](https://expressjs.com)
- **R** = [React.js](https://reactjs.org) - **R** = [React.js](https://reactjs.org)
- **N** = [Node.js](https://nodejs.org) - **N** = [Node.js](https://nodejs.org)
<br />
<br />
## How to use this template
<br />
### STEP 1:
Click ["Use this template"](https://github.com/belferink1996/MERN-template/generate) to generate a new repository.<br />
Then open your terminal and clone your repository:
> cd ~/Desktop <br />
> git clone https://github.com/[your-user-name]/[your-repo-name].git
<br />
### STEP 2:
Go to your client folder (frontend), and set your workspace:
> cd ~/Desktop/[your-repo-name]/client <br />
> npm install <br />
> npm start
<br />
### STEP 3:
Prepare your MongoDB database,<br />
then go to your server folder (backend), and set your workspace:
> cd ~/Desktop/[your-repo-name]/server <br />
> npm install <br />
Set your database within `index.js`, then start server:
> npm start
<br />
### STEP 4: CODE !!!

3
client/.gitignore vendored
View File

@@ -1,3 +0,0 @@
/node_modules
.DS_Store
.eslintcache

View File

@@ -1,28 +0,0 @@
{
"name": "client",
"version": "0.1.0",
"main": "index.js",
"scripts": {
"start": "react-scripts start"
},
"author": "Ben Elferink",
"license": "ISC",
"dependencies": {
"axios": "^0.21.0",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-scripts": "^4.0.1"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}

View File

@@ -1,12 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>MERN_STACK</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root" />
</body>
</html>

View File

@@ -1,8 +0,0 @@
import React from 'react';
import './style/style.css';
function App() {
return <div>Hello World - React.js</div>;
}
export default App;

View File

@@ -1,6 +0,0 @@
import axios from 'axios';
const url = 'http://localhost:8080/';
// export const getSomething = () => axios.get(url + 'path');
// export const postSometing = (form) => axios.post(url + 'path', form);

View File

@@ -1,10 +0,0 @@
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
);

View File

@@ -1,9 +0,0 @@
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Arial, Helvetica, sans-serif;
}

BIN
images/mern.jpeg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 431 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 448 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 807 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 334 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

BIN
images/preview.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 271 KiB

View File

@@ -1 +0,0 @@
CONNECTIONS_URL = "URL"

3
server/.gitignore vendored
View File

@@ -1,3 +0,0 @@
/node_modules
.DS_Store
.env

View File

@@ -1,30 +0,0 @@
import mongoose from 'mongoose';
import express from 'express';
import dotenv from 'dotenv';
import cors from 'cors';
// initialize app
const app = express();
dotenv.config();
// connect to db ---> if you want to connect to cloud server: edit "CONNECTION_URL" in -> .env file
const DB_NAME = 'testDB'; // if you want to use local server: edit this "DB_NAME" (and remove the "CONNECTION_URL" from -> .env file)
const CONNECTION_URL = process.env.CONNECTION_URL || `mongodb://localhost:27017/${DB_NAME}`;
const PORT = process.env.PORT || 8080; // 8080 === development port
const DEPRECATED_FIX = { useNewUrlParser: true, useUnifiedTopology: true }; // change this with (possible) warnings on first connection
mongoose
.connect(CONNECTION_URL, DEPRECATED_FIX)
.then(() => console.log('✅ MongoDB connected'))
.then(() => app.listen(PORT, () => console.log(`✅ Listening on port: ${PORT}`)))
.catch((error) => console.log(`${error}`));
mongoose.connection.on('error', (err) => console.log(`❌ MongoDB: ${err}`));
// middlewares
app.use(express.json()); // body parser
app.use(cors()); // enables requests
// routes
app.get('/', (req, res) => res.send('Hello World - Express.js'));
// app.use('/', IMPORTED_ROUTES);

View File

@@ -1,18 +0,0 @@
{
"name": "server",
"version": "0.1.0",
"main": "index.js",
"type": "module",
"scripts": {
"start": "nodemon index.js"
},
"author": "Ben Elferink",
"license": "ISC",
"dependencies": {
"cors": "^2.8.5",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"mongoose": "^5.11.8",
"nodemon": "^2.0.6"
}
}