From 7b21c41a15262897b3a310ebd59513dc128af3ed Mon Sep 17 00:00:00 2001 From: DoctorCodeine Date: Wed, 14 Dec 2022 19:59:30 -0600 Subject: [PATCH 1/2] House keeping MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Harvey Li <112590580+harvli@users.noreply.github.com> Co-authored-by: John Wroge <72668920+johnwroge@users.noreply.github.com> Co-authored-by: Amy Nguyen (Aimée) <106037255+DoctorCodeine@users.noreply.github.com> Co-authored-by: Ed Cho <106274379+edcho720@users.noreply.github.com> --- .env | 3 ++ .gitignore | 2 +- README.md | 31 ++++++++++++--- jest.config.js | 15 +------- package-lock.json | 79 ++++++++++++++++++++++++++++++++++----- package.json | 2 + src/server/database/db.ts | 8 +++- test.html | 27 ------------- 8 files changed, 110 insertions(+), 57 deletions(-) create mode 100644 .env delete mode 100644 test.html diff --git a/.env b/.env new file mode 100644 index 0000000..1989a72 --- /dev/null +++ b/.env @@ -0,0 +1,3 @@ +mongoURI = 'mongodb+srv://zeus:zeus@cluster0.1i7iws7.mongodb.net/?retryWrites=true&w=majority'; +dbName = 'Zeus'; +collectionName = 'Users'; \ No newline at end of file diff --git a/.gitignore b/.gitignore index 8f00ef2..133fce8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ node_modules -.env +process.env dist \ No newline at end of file diff --git a/README.md b/README.md index 0941ded..126abe0 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,7 @@ 1. You will need to obtain the stateful set of your clusters.
- ``` + ``` kubectl get statefulset ``` @@ -237,13 +237,34 @@ For more information regarding how to contribute, please refer to the guidelines from this repo. 1. Fork and clone the `dev` branch onto your local branch. -2. Create a new a feature branch + ``` bash + https://github.com/oslabs-beta/Zeus.git ``` +2. Create a new a feature branch + ``` bash [your-name]/AWESOME-FEATURES ``` -3. Please ensure you are following eslint conventions. -4. Please ensure to create tests for your feature and that it passes your test suite. -5. Please be detailed in your pull request. + +3. Install all the dependencies + ``` bash + npm install + ``` +4. Create ```.env``` file at the root directory + ``` bash + root + ├─ .env + ├─ electron + └─ src + ``` +5. Connect to NoSQL database in .env + + ``` js + mongoURI = "Your NoSQL URI string" + ``` +6. ***Please ensure you are following eslint conventions***. +7. ***Please ensure to create tests for your feature and that it passes your test suite***. +8. **Please be detailed in your pull request**. + ![img](./Demo%20Shots/PR-guide.png)
diff --git a/jest.config.js b/jest.config.js index 28c8662..ad92023 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,17 +1,6 @@ /** @type {import('ts-jest').JestConfigWithTsJest} */ module.exports = { - preset: 'ts-jest', - testEnvironment: ['node', 'jsdom'] - // moduleFileExtensions: [ - // 'js', - // 'jsx', - // 'json', - // 'node', - // 'ts' - // ], - // transform: { - // '^.+\\.js$': 'babel-jest', - // '^.+\\.(ts|tsx)$': 'ts-jest' - // } + preset: 'ts-jest', + testEnvironment: ['node', 'jsdom'] }; diff --git a/package-lock.json b/package-lock.json index 8ac5e6a..b5786bc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,6 +23,7 @@ "cookie-parser": "^1.4.6", "cors": "^2.8.5", "css-loader": "^6.7.2", + "dotenv": "^16.0.3", "eslint-config-airbnb": "^19.0.4", "express": "^4.18.2", "formik": "^2.2.9", @@ -36,6 +37,7 @@ "mongosh": "^1.6.1", "node-fetch": "^3.3.0", "nodemon": "^2.0.20", + "path": "^0.12.7", "prom-client": "^14.1.0", "react": "^18.2.0", "react-dom": "^18.2.0", @@ -13795,12 +13797,11 @@ } }, "node_modules/dotenv": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", - "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==", - "dev": true, + "version": "16.0.3", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz", + "integrity": "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==", "engines": { - "node": ">=10" + "node": ">=12" } }, "node_modules/dotenv-expand": { @@ -28775,6 +28776,15 @@ "node": ">=0.10.0" } }, + "node_modules/path": { + "version": "0.12.7", + "resolved": "https://registry.npmjs.org/path/-/path-0.12.7.tgz", + "integrity": "sha512-aXXC6s+1w7otVF9UletFkFcDsJeO7lSZBPUQhtb5O0xJe8LtYhj/GxldoL09bBj9+ZmE2hNoHqQSFMN5fikh4Q==", + "dependencies": { + "process": "^0.11.1", + "util": "^0.10.3" + } + }, "node_modules/path-browserify": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.1.tgz", @@ -28831,6 +28841,19 @@ "node": ">=8" } }, + "node_modules/path/node_modules/inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw==" + }, + "node_modules/path/node_modules/util": { + "version": "0.10.4", + "resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz", + "integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==", + "dependencies": { + "inherits": "2.0.3" + } + }, "node_modules/pbkdf2": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.1.2.tgz", @@ -31762,6 +31785,15 @@ "node": ">=8" } }, + "node_modules/react-scripts/node_modules/dotenv": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", + "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==", + "dev": true, + "engines": { + "node": ">=10" + } + }, "node_modules/react-scripts/node_modules/emittery": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/emittery/-/emittery-0.8.1.tgz", @@ -49082,10 +49114,9 @@ } }, "dotenv": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", - "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==", - "dev": true + "version": "16.0.3", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz", + "integrity": "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==" }, "dotenv-expand": { "version": "5.1.0", @@ -60317,6 +60348,30 @@ "integrity": "sha512-XHXfu/yOQRy9vYOtUDVMN60OEJjW013GoObG1o+xwQTpB9eYJX/BjXMsdW13ZDPruFhYYn0AG22w0xgQMwl3Nw==", "dev": true }, + "path": { + "version": "0.12.7", + "resolved": "https://registry.npmjs.org/path/-/path-0.12.7.tgz", + "integrity": "sha512-aXXC6s+1w7otVF9UletFkFcDsJeO7lSZBPUQhtb5O0xJe8LtYhj/GxldoL09bBj9+ZmE2hNoHqQSFMN5fikh4Q==", + "requires": { + "process": "^0.11.1", + "util": "^0.10.3" + }, + "dependencies": { + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw==" + }, + "util": { + "version": "0.10.4", + "resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz", + "integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==", + "requires": { + "inherits": "2.0.3" + } + } + } + }, "path-browserify": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.1.tgz", @@ -62376,6 +62431,12 @@ } } }, + "dotenv": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", + "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==", + "dev": true + }, "emittery": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/emittery/-/emittery-0.8.1.tgz", diff --git a/package.json b/package.json index 1501577..06ea9ee 100644 --- a/package.json +++ b/package.json @@ -101,6 +101,7 @@ "cookie-parser": "^1.4.6", "cors": "^2.8.5", "css-loader": "^6.7.2", + "dotenv": "^16.0.3", "eslint-config-airbnb": "^19.0.4", "express": "^4.18.2", "formik": "^2.2.9", @@ -114,6 +115,7 @@ "mongosh": "^1.6.1", "node-fetch": "^3.3.0", "nodemon": "^2.0.20", + "path": "^0.12.7", "prom-client": "^14.1.0", "react": "^18.2.0", "react-dom": "^18.2.0", diff --git a/src/server/database/db.ts b/src/server/database/db.ts index 67269ce..9043e42 100644 --- a/src/server/database/db.ts +++ b/src/server/database/db.ts @@ -1,16 +1,20 @@ import { ErrorRequestHandler } from 'express'; +import path from 'path'; //acquiring mongoose framework const mongoose = require('mongoose'); +require("dotenv").config({ + path: path.resolve(__dirname, "../../../process.env"), +}); + //this line below is used to suppress deprecation warnings mongoose.set('strictQuery', true); //Data can be accessed anywhere -Look at env file to find username and password -const mongoURI = 'mongodb+srv://zeus:123@cluster0.ntr77xf.mongodb.net/?retryWrites=true&w=majority'; //to hid server from public -const URI = process.env.MONGO_URI || mongoURI; +const URI = process.env.MONGO_URI; //establishing connection to mongo mongoose diff --git a/test.html b/test.html deleted file mode 100644 index 77247e2..0000000 --- a/test.html +++ /dev/null @@ -1,27 +0,0 @@ -Namespace Name CPU Requests CPU Limits Memory Requests Memory Limits Age - \ No newline at end of file From 35649c32234404fddf4d512bcbebccc08f666b46 Mon Sep 17 00:00:00 2001 From: DoctorCodeine Date: Wed, 14 Dec 2022 20:22:00 -0600 Subject: [PATCH 2/2] Housing keeping --- .env | 3 --- CONTRIBUTING.md | 2 +- README.md | 51 ++++++++++++++++++++++++++++----------- src/server/database/db.ts | 4 +-- tsconfig.json | 7 ------ 5 files changed, 39 insertions(+), 28 deletions(-) delete mode 100644 .env diff --git a/.env b/.env deleted file mode 100644 index 1989a72..0000000 --- a/.env +++ /dev/null @@ -1,3 +0,0 @@ -mongoURI = 'mongodb+srv://zeus:zeus@cluster0.1i7iws7.mongodb.net/?retryWrites=true&w=majority'; -dbName = 'Zeus'; -collectionName = 'Users'; \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c67e348..b0b0315 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -16,7 +16,7 @@ We use github to host code, to track issues and feature requests, as well as acc Pull requests are the best way to propose changes to the codebase. We actively welcome your pull requests: -1. Fork the repo and create your branch from `main`. +1. Fork the repo and create your branch from `dev`. 2. If you've added code that should be tested, add tests. 3. Ensure the test suite passes. 4. Make sure your code lints. diff --git a/README.md b/README.md index 126abe0..b42b929 100644 --- a/README.md +++ b/README.md @@ -86,8 +86,6 @@


-
-
# Accessing Grafana @@ -156,8 +154,6 @@

-
-
# Accessing Prometheus

@@ -193,7 +189,37 @@

-
+ + +# Running Zeus + +1. Fork and clone the `dev` branch onto your local branch. + ``` bash + https://github.com/oslabs-beta/Zeus.git + ``` + +2. Install all the dependencies + ``` bash + npm install + ``` +3. Create ```process.env``` file at the root directory + ``` bash + root + ├─ process.env + ├─ electron + └─ src + ``` +4. Connect to NoSQL database in .env + + ``` js + mongoURI = "Your NoSQL URI string" + ``` +5. Ensure your cluster is running and then you can start the application with: + ``` bash + npm run electron + ``` + +

# Made with @@ -226,9 +252,9 @@ ![Prometheus](https://img.shields.io/badge/Prometheus-E6522C?style=for-the-badge&logo=Prometheus&logoColor=white)
+
-
-
+ # Contributions @@ -249,10 +275,10 @@ guidelines from this repo. ``` bash npm install ``` -4. Create ```.env``` file at the root directory +4. Create ```process.env``` file at the root directory ``` bash root - ├─ .env + ├─ process.env ├─ electron └─ src ``` @@ -269,13 +295,10 @@ guidelines from this repo.

-
-
# Founders -- Ed Cho [LinkedIn](https://www.linkedin.com/in/edcho720/)| [GitHub](https://github.com/edcho720) +- Ed Cho [LinkedIn](https://www.linkedin.com/in/edcho720/) | [GitHub](https://github.com/edcho720) - John Wroge [LinkedIn](https://www.linkedin.com/in/john-wroge/) | [GitHub](https://github.com/johnwroge) - Harvey Li [LinkedIn](https://www.linkedin.com/in/harvey-li/) | [GitHub](https://github.com/harvli) -- Amy (Aimée) Nguyen [LinkedIn](https://www.linkedin.com/in/aqn/) | - [GitHub](https://github.com/DoctorCodeine) +- Amy (Aimée) Nguyen [LinkedIn](https://www.linkedin.com/in/aqn/) | [GitHub](https://github.com/DoctorCodeine) diff --git a/src/server/database/db.ts b/src/server/database/db.ts index 9043e42..e05bfa1 100644 --- a/src/server/database/db.ts +++ b/src/server/database/db.ts @@ -21,7 +21,7 @@ mongoose .connect(URI, { useNewUrlParser: true, useUnifiedTopology: true, - dbName: 'zeus', + // dbName: 'zeus', }) .then(() => console.log('🦆🦆🦆🦆🦆🦆🦆🦆 Mongoose is connected')) .catch((err: ErrorRequestHandler) => { @@ -38,5 +38,3 @@ const userSchema = new mongoose.Schema({ const Users = mongoose.model('Users', userSchema); // Export db module.exports = Users; - -export {}; diff --git a/tsconfig.json b/tsconfig.json index 2a369e2..f4d22d4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -23,12 +23,5 @@ ], }, "include": ["src/**/*", "__test__/"], - - // "paths": { - // "*": [ - // "node_modules/*" - // ] - // }, - // "exclude": ["node_modules"], } //"ESNext" in module