Delete server directory
This commit is contained in:
@@ -1 +0,0 @@
|
|||||||
CONNECTIONS_URL = "URL"
|
|
||||||
3
server/.gitignore
vendored
3
server/.gitignore
vendored
@@ -1,3 +0,0 @@
|
|||||||
/node_modules
|
|
||||||
.DS_Store
|
|
||||||
.env
|
|
||||||
@@ -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);
|
|
||||||
@@ -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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user