├── .github └── workflows │ └── main.yaml ├── .gitignore ├── LICENSE ├── README.md └── mern ├── client ├── .eslintrc.cjs ├── .gitignore ├── cypress.json ├── cypress │ ├── fixtures │ │ └── example.json │ ├── integration │ │ └── endToEnd.spec.js │ ├── plugins │ │ └── index.js │ └── support │ │ ├── commands.js │ │ └── index.js ├── index.html ├── package-lock.json ├── package.json ├── postcss.config.js ├── public │ └── vite.svg ├── src │ ├── App.jsx │ ├── assets │ │ └── mongodb.svg │ ├── components │ │ ├── Navbar.jsx │ │ ├── Record.jsx │ │ └── RecordList.jsx │ ├── index.css │ └── main.jsx ├── tailwind.config.js └── vite.config.js └── server ├── db └── connection.js ├── package-lock.json ├── package.json ├── routes └── record.js └── server.js /.github/workflows/main.yaml: -------------------------------------------------------------------------------- 1 | # This is a basic workflow to help you get started with Actions 2 | 3 | name: CI 4 | 5 | # Controls when the workflow will run 6 | on: 7 | # Triggers the workflow on push or pull request events but only for the main branch 8 | push: 9 | branches: [ $default-branch ] 10 | pull_request: 11 | branches: [ $default-branch ] 12 | 13 | # Allows you to run this workflow manually from the Actions tab 14 | workflow_dispatch: 15 | 16 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel 17 | jobs: 18 | # This workflow contains a single job called "build" 19 | 20 | build: 21 | # The type of runner that the job will run on 22 | runs-on: ubuntu-latest 23 | environment: Testing 24 | strategy: 25 | matrix: 26 | node-version: [14.x , 16.x] 27 | max-parallel: 1 28 | 29 | # Steps represent a sequence of tasks that will be executed as part of the job 30 | steps: 31 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it 32 | - uses: actions/checkout@v2 33 | with: 34 | ref: 'main-test' 35 | 36 | - name: Install server npm packages 37 | uses: bahmutov/npm-install@v1 38 | with: 39 | working-directory: mern/server 40 | 41 | - name: Install client npm packages 42 | uses: bahmutov/npm-install@v1 43 | with: 44 | working-directory: mern/client 45 | 46 | - name: Start server in the background 47 | env: 48 | ATLAS_URI: ${{ secrets.ATLAS_URI }} 49 | run: (cd mern/server && echo "ATLAS_URI=$ATLAS_URI" > config.env && npm start &) 50 | 51 | - name: Start React app in the background 52 | run: (cd mern/client && npm start &) 53 | 54 | - name: Install Cypress and run tests 55 | uses: cypress-io/github-action@v2 56 | with: 57 | working-directory: mern/client 58 | 59 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | config.env 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | Copyright 2024 MongoDB Inc. 179 | 180 | Licensed under the Apache License, Version 2.0 (the "License"); 181 | you may not use this file except in compliance with the License. 182 | You may obtain a copy of the License at 183 | 184 | http://www.apache.org/licenses/LICENSE-2.0 185 | 186 | Unless required by applicable law or agreed to in writing, software 187 | distributed under the License is distributed on an "AS IS" BASIS, 188 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 189 | See the License for the specific language governing permissions and 190 | limitations under the License. 191 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # mern-stack-example 2 | Mern Stack code for the [Mern Tutorial](https://www.mongodb.com/languages/mern-stack-tutorial) 3 | 4 | [![CI](https://github.com/mongodb-developer/mern-stack-example/actions/workflows/main.yaml/badge.svg)](https://github.com/mongodb-developer/mern-stack-example/actions/workflows/main.yaml) 5 | 6 | ## How To Run 7 | Create the file `mern/server/config.env` with your Atlas URI and the server port: 8 | ``` 9 | ATLAS_URI=mongodb+srv://:@sandbox.jadwj.mongodb.net/ 10 | PORT=5050 11 | ``` 12 | 13 | Start server: 14 | ``` 15 | cd mern/server 16 | npm install 17 | npm start 18 | ``` 19 | 20 | Start Web server 21 | ``` 22 | cd mern/client 23 | npm install 24 | npm run dev 25 | ``` 26 | 27 | ## Disclaimer 28 | 29 | Use at your own risk; not a supported MongoDB product 30 | -------------------------------------------------------------------------------- /mern/client/.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { browser: true, es2020: true }, 4 | extends: [ 5 | 'eslint:recommended', 6 | 'plugin:react/recommended', 7 | 'plugin:react/jsx-runtime', 8 | 'plugin:react-hooks/recommended', 9 | ], 10 | ignorePatterns: ['dist', '.eslintrc.cjs'], 11 | parserOptions: { ecmaVersion: 'latest', sourceType: 'module' }, 12 | settings: { react: { version: '18.2' } }, 13 | plugins: ['react-refresh'], 14 | rules: { 15 | 'react-refresh/only-export-components': [ 16 | 'warn', 17 | { allowConstantExport: true }, 18 | ], 19 | }, 20 | } 21 | -------------------------------------------------------------------------------- /mern/client/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /mern/client/cypress.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /mern/client/cypress/fixtures/example.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Using fixtures to represent data", 3 | "email": "hello@cypress.io", 4 | "body": "Fixtures are a great way to mock data for responses to routes" 5 | } 6 | -------------------------------------------------------------------------------- /mern/client/cypress/integration/endToEnd.spec.js: -------------------------------------------------------------------------------- 1 | 2 | describe('Web site availability', () => { 3 | 4 | after(() => { 5 | cy.contains("Delete").click({ force: true }); 6 | }); 7 | it('Sanity listings web site', () => { 8 | cy.visit('http://localhost:5173'); 9 | cy.contains('Create Record').should('exist'); 10 | }); 11 | it('Test Adding Employee listings', () => { 12 | cy.visit('http://localhost:5173/create'); 13 | cy.get('#name').type("Employee1"); 14 | cy.get('#position').type("Position1"); 15 | cy.get("#positionIntern").click({ force: true }); 16 | cy.contains("Create person").click({ force: true }); 17 | cy.visit('http://localhost:5173'); 18 | cy.contains('Employee1').should('exist'); 19 | }); 20 | /* it('Test Editing Employee listings', () => { 21 | //cy.visit('http://localhost:3000'); 22 | cy.contains('Edit').click({ force: true }) 23 | cy.on('url:changed', url => { 24 | cy.visit(url); 25 | cy.get('#position').clear(); 26 | cy.get('#position').type("Position2"); 27 | cy.contains("Update Record").click({ force: true }); 28 | cy.visit('http://localhost:3000'); 29 | cy.contains('Position2').should('exist'); 30 | }); 31 | 32 | 33 | 34 | });*/ 35 | }); -------------------------------------------------------------------------------- /mern/client/cypress/plugins/index.js: -------------------------------------------------------------------------------- 1 | /// 2 | // *********************************************************** 3 | // This example plugins/index.js can be used to load plugins 4 | // 5 | // You can change the location of this file or turn off loading 6 | // the plugins file with the 'pluginsFile' configuration option. 7 | // 8 | // You can read more here: 9 | // https://on.cypress.io/plugins-guide 10 | // *********************************************************** 11 | 12 | // This function is called when a project is opened or re-opened (e.g. due to 13 | // the project's config changing) 14 | 15 | /** 16 | * @type {Cypress.PluginConfig} 17 | */ 18 | // eslint-disable-next-line no-unused-vars 19 | module.exports = (on, config) => { 20 | // `on` is used to hook into various events Cypress emits 21 | // `config` is the resolved Cypress config 22 | } 23 | -------------------------------------------------------------------------------- /mern/client/cypress/support/commands.js: -------------------------------------------------------------------------------- 1 | // *********************************************** 2 | // This example commands.js shows you how to 3 | // create various custom commands and overwrite 4 | // existing commands. 5 | // 6 | // For more comprehensive examples of custom 7 | // commands please read more here: 8 | // https://on.cypress.io/custom-commands 9 | // *********************************************** 10 | // 11 | // 12 | // -- This is a parent command -- 13 | // Cypress.Commands.add('login', (email, password) => { ... }) 14 | // 15 | // 16 | // -- This is a child command -- 17 | // Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... }) 18 | // 19 | // 20 | // -- This is a dual command -- 21 | // Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... }) 22 | // 23 | // 24 | // -- This will overwrite an existing command -- 25 | // Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... }) 26 | -------------------------------------------------------------------------------- /mern/client/cypress/support/index.js: -------------------------------------------------------------------------------- 1 | // *********************************************************** 2 | // This example support/index.js is processed and 3 | // loaded automatically before your test files. 4 | // 5 | // This is a great place to put global configuration and 6 | // behavior that modifies Cypress. 7 | // 8 | // You can change the location of this file or turn off 9 | // automatically serving support files with the 10 | // 'supportFile' configuration option. 11 | // 12 | // You can read more here: 13 | // https://on.cypress.io/configuration 14 | // *********************************************************** 15 | 16 | // Import commands.js using ES2015 syntax: 17 | import './commands' 18 | 19 | // Alternatively you can use CommonJS syntax: 20 | // require('./commands') 21 | -------------------------------------------------------------------------------- /mern/client/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | MERN (MongoDB + Express + React + Node) 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /mern/client/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "client", 3 | "private": true, 4 | "version": "0.1.0", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "vite", 8 | "build": "vite build", 9 | "lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0", 10 | "preview": "vite preview" 11 | }, 12 | "dependencies": { 13 | "react": "^18.2.0", 14 | "react-dom": "^18.2.0" 15 | }, 16 | "devDependencies": { 17 | "@types/react": "^18.2.43", 18 | "@types/react-dom": "^18.2.17", 19 | "@vitejs/plugin-react": "^4.2.1", 20 | "autoprefixer": "^10.4.17", 21 | "cypress": "^13.6.4", 22 | "eslint": "^8.55.0", 23 | "eslint-plugin-react": "^7.33.2", 24 | "eslint-plugin-react-hooks": "^4.6.0", 25 | "eslint-plugin-react-refresh": "^0.4.5", 26 | "postcss": "^8.4.34", 27 | "react-router-dom": "^6.22.0", 28 | "tailwindcss": "^3.4.1", 29 | "vite": "^5.0.8" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /mern/client/postcss.config.js: -------------------------------------------------------------------------------- 1 | export default { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | }, 6 | } 7 | -------------------------------------------------------------------------------- /mern/client/public/vite.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mern/client/src/App.jsx: -------------------------------------------------------------------------------- 1 | import { Outlet } from "react-router-dom"; 2 | import Navbar from "./components/Navbar"; 3 | 4 | const App = () => { 5 | return ( 6 |
7 | 8 | 9 |
10 | ); 11 | }; 12 | export default App; 13 | -------------------------------------------------------------------------------- /mern/client/src/assets/mongodb.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /mern/client/src/components/Navbar.jsx: -------------------------------------------------------------------------------- 1 | import { NavLink } from "react-router-dom"; 2 | 3 | export default function Navbar() { 4 | return ( 5 |
6 | 15 |
16 | ); 17 | } 18 | -------------------------------------------------------------------------------- /mern/client/src/components/Record.jsx: -------------------------------------------------------------------------------- 1 | import { useState, useEffect } from "react"; 2 | import { useParams, useNavigate } from "react-router-dom"; 3 | 4 | export default function Record() { 5 | const [form, setForm] = useState({ 6 | name: "", 7 | position: "", 8 | level: "", 9 | }); 10 | const [isNew, setIsNew] = useState(true); 11 | const params = useParams(); 12 | const navigate = useNavigate(); 13 | 14 | useEffect(() => { 15 | async function fetchData() { 16 | const id = params.id?.toString() || undefined; 17 | if(!id) return; 18 | setIsNew(false); 19 | const response = await fetch( 20 | `http://localhost:5050/record/${params.id.toString()}` 21 | ); 22 | if (!response.ok) { 23 | const message = `An error has occurred: ${response.statusText}`; 24 | console.error(message); 25 | return; 26 | } 27 | const record = await response.json(); 28 | if (!record) { 29 | console.warn(`Record with id ${id} not found`); 30 | navigate("/"); 31 | return; 32 | } 33 | setForm(record); 34 | } 35 | fetchData(); 36 | return; 37 | }, [params.id, navigate]); 38 | 39 | // These methods will update the state properties. 40 | function updateForm(value) { 41 | return setForm((prev) => { 42 | return { ...prev, ...value }; 43 | }); 44 | } 45 | 46 | // This function will handle the submission. 47 | async function onSubmit(e) { 48 | e.preventDefault(); 49 | const person = { ...form }; 50 | try { 51 | let response; 52 | if (isNew) { 53 | // if we are adding a new record we will POST to /record. 54 | response = await fetch("http://localhost:5050/record", { 55 | method: "POST", 56 | headers: { 57 | "Content-Type": "application/json", 58 | }, 59 | body: JSON.stringify(person), 60 | }); 61 | } else { 62 | // if we are updating a record we will PATCH to /record/:id. 63 | response = await fetch(`http://localhost:5050/record/${params.id}`, { 64 | method: "PATCH", 65 | headers: { 66 | "Content-Type": "application/json", 67 | }, 68 | body: JSON.stringify(person), 69 | }); 70 | } 71 | 72 | if (!response.ok) { 73 | throw new Error(`HTTP error! status: ${response.status}`); 74 | } 75 | } catch (error) { 76 | console.error('A problem occurred adding or updating a record: ', error); 77 | } finally { 78 | setForm({ name: "", position: "", level: "" }); 79 | navigate("/"); 80 | } 81 | } 82 | 83 | // This following section will display the form that takes the input from the user. 84 | return ( 85 | <> 86 |

Create/Update Employee Record

87 |
91 |
92 |
93 |

94 | Employee Info 95 |

96 |

97 | This information will be displayed publicly so be careful what you 98 | share. 99 |

100 |
101 | 102 |
103 |
104 | 110 |
111 |
112 | updateForm({ name: e.target.value })} 120 | /> 121 |
122 |
123 |
124 |
125 | 131 |
132 |
133 | updateForm({ position: e.target.value })} 141 | /> 142 |
143 |
144 |
145 |
146 |
147 | Position Options 148 |
149 |
150 | updateForm({ level: e.target.value })} 158 | /> 159 | 165 | updateForm({ level: e.target.value })} 173 | /> 174 | 180 | updateForm({ level: e.target.value })} 188 | /> 189 | 195 |
196 |
197 |
198 |
199 |
200 |
201 | 206 |
207 | 208 | ); 209 | } 210 | -------------------------------------------------------------------------------- /mern/client/src/components/RecordList.jsx: -------------------------------------------------------------------------------- 1 | import { useEffect, useState } from "react"; 2 | import { Link } from "react-router-dom"; 3 | 4 | const Record = (props) => ( 5 | 6 | 7 | {props.record.name} 8 | 9 | 10 | {props.record.position} 11 | 12 | 13 | {props.record.level} 14 | 15 | 16 |
17 | 21 | Edit 22 | 23 | 33 |
34 | 35 | 36 | ); 37 | 38 | export default function RecordList() { 39 | const [records, setRecords] = useState([]); 40 | 41 | // This method fetches the records from the database. 42 | useEffect(() => { 43 | async function getRecords() { 44 | const response = await fetch(`http://localhost:5050/record/`); 45 | if (!response.ok) { 46 | const message = `An error occurred: ${response.statusText}`; 47 | console.error(message); 48 | return; 49 | } 50 | const records = await response.json(); 51 | setRecords(records); 52 | } 53 | getRecords(); 54 | return; 55 | }, [records.length]); 56 | 57 | // This method will delete a record 58 | async function deleteRecord(id) { 59 | await fetch(`http://localhost:5050/record/${id}`, { 60 | method: "DELETE", 61 | }); 62 | const newRecords = records.filter((el) => el._id !== id); 63 | setRecords(newRecords); 64 | } 65 | 66 | // This method will map out the records on the table 67 | function recordList() { 68 | return records.map((record) => { 69 | return ( 70 | deleteRecord(record._id)} 73 | key={record._id} 74 | /> 75 | ); 76 | }); 77 | } 78 | 79 | // This following section will display the table with the records of individuals. 80 | return ( 81 | <> 82 |

Employee Records

83 |
84 |
85 | 86 | 87 | 88 | 91 | 94 | 97 | 100 | 101 | 102 | 103 | {recordList()} 104 | 105 |
89 | Name 90 | 92 | Position 93 | 95 | Level 96 | 98 | Action 99 |
106 |
107 |
108 | 109 | ); 110 | } 111 | -------------------------------------------------------------------------------- /mern/client/src/index.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; 4 | -------------------------------------------------------------------------------- /mern/client/src/main.jsx: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | import * as ReactDOM from "react-dom/client"; 3 | import { 4 | createBrowserRouter, 5 | RouterProvider, 6 | } from "react-router-dom"; 7 | import App from "./App"; 8 | import Record from "./components/Record"; 9 | import RecordList from "./components/RecordList"; 10 | import "./index.css"; 11 | 12 | const router = createBrowserRouter([ 13 | { 14 | path: "/", 15 | element: , 16 | children: [ 17 | { 18 | path: "/", 19 | element: , 20 | }, 21 | ], 22 | }, 23 | { 24 | path: "/create", 25 | element: , 26 | children: [ 27 | { 28 | path: "/create", 29 | element: , 30 | }, 31 | ], 32 | }, 33 | { 34 | path: "/edit/:id", 35 | element: , 36 | children: [ 37 | { 38 | path: "/edit/:id", 39 | element: , 40 | }, 41 | ], 42 | }, 43 | ]); 44 | 45 | ReactDOM.createRoot(document.getElementById("root")).render( 46 | 47 | 48 | 49 | ); 50 | -------------------------------------------------------------------------------- /mern/client/tailwind.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('tailwindcss').Config} */ 2 | export default { 3 | content: [ 4 | "./index.html", 5 | "./src/**/*.{js,ts,jsx,tsx}", 6 | ], 7 | theme: { 8 | extend: {}, 9 | }, 10 | plugins: [], 11 | } 12 | 13 | -------------------------------------------------------------------------------- /mern/client/vite.config.js: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'vite' 2 | import react from '@vitejs/plugin-react' 3 | 4 | // https://vitejs.dev/config/ 5 | export default defineConfig({ 6 | plugins: [react()], 7 | }) 8 | -------------------------------------------------------------------------------- /mern/server/db/connection.js: -------------------------------------------------------------------------------- 1 | import { MongoClient, ServerApiVersion } from "mongodb"; 2 | 3 | const URI = process.env.ATLAS_URI || ""; 4 | const client = new MongoClient(URI, { 5 | serverApi: { 6 | version: ServerApiVersion.v1, 7 | strict: true, 8 | deprecationErrors: true, 9 | }, 10 | }); 11 | 12 | try { 13 | // Connect the client to the server 14 | await client.connect(); 15 | // Send a ping to confirm a successful connection 16 | await client.db("admin").command({ ping: 1 }); 17 | console.log("Pinged your deployment. You successfully connected to MongoDB!"); 18 | } catch (err) { 19 | console.error(err); 20 | } 21 | 22 | let db = client.db("employees"); 23 | 24 | export default db; 25 | -------------------------------------------------------------------------------- /mern/server/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "server", 3 | "version": "1.0.0", 4 | "lockfileVersion": 3, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "server", 9 | "version": "1.0.0", 10 | "license": "ISC", 11 | "dependencies": { 12 | "cors": "^2.8.5", 13 | "express": "^4.18.2", 14 | "mongodb": "^6.3.0" 15 | } 16 | }, 17 | "node_modules/@mongodb-js/saslprep": { 18 | "version": "1.1.4", 19 | "resolved": "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.1.4.tgz", 20 | "integrity": "sha512-8zJ8N1x51xo9hwPh6AWnKdLGEC5N3lDa6kms1YHmFBoRhTpJR6HG8wWk0td1MVCu9cD4YBrvjZEtd5Obw0Fbnw==", 21 | "dependencies": { 22 | "sparse-bitfield": "^3.0.3" 23 | } 24 | }, 25 | "node_modules/@types/webidl-conversions": { 26 | "version": "7.0.3", 27 | "resolved": "https://registry.npmjs.org/@types/webidl-conversions/-/webidl-conversions-7.0.3.tgz", 28 | "integrity": "sha512-CiJJvcRtIgzadHCYXw7dqEnMNRjhGZlYK05Mj9OyktqV8uVT8fD2BFOB7S1uwBE3Kj2Z+4UyPmFw/Ixgw/LAlA==" 29 | }, 30 | "node_modules/@types/whatwg-url": { 31 | "version": "11.0.4", 32 | "resolved": "https://registry.npmjs.org/@types/whatwg-url/-/whatwg-url-11.0.4.tgz", 33 | "integrity": "sha512-lXCmTWSHJvf0TRSO58nm978b8HJ/EdsSsEKLd3ODHFjo+3VGAyyTp4v50nWvwtzBxSMQrVOK7tcuN0zGPLICMw==", 34 | "dependencies": { 35 | "@types/webidl-conversions": "*" 36 | } 37 | }, 38 | "node_modules/accepts": { 39 | "version": "1.3.8", 40 | "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", 41 | "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", 42 | "dependencies": { 43 | "mime-types": "~2.1.34", 44 | "negotiator": "0.6.3" 45 | }, 46 | "engines": { 47 | "node": ">= 0.6" 48 | } 49 | }, 50 | "node_modules/array-flatten": { 51 | "version": "1.1.1", 52 | "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", 53 | "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==" 54 | }, 55 | "node_modules/body-parser": { 56 | "version": "1.20.1", 57 | "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz", 58 | "integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==", 59 | "dependencies": { 60 | "bytes": "3.1.2", 61 | "content-type": "~1.0.4", 62 | "debug": "2.6.9", 63 | "depd": "2.0.0", 64 | "destroy": "1.2.0", 65 | "http-errors": "2.0.0", 66 | "iconv-lite": "0.4.24", 67 | "on-finished": "2.4.1", 68 | "qs": "6.11.0", 69 | "raw-body": "2.5.1", 70 | "type-is": "~1.6.18", 71 | "unpipe": "1.0.0" 72 | }, 73 | "engines": { 74 | "node": ">= 0.8", 75 | "npm": "1.2.8000 || >= 1.4.16" 76 | } 77 | }, 78 | "node_modules/bson": { 79 | "version": "6.3.0", 80 | "resolved": "https://registry.npmjs.org/bson/-/bson-6.3.0.tgz", 81 | "integrity": "sha512-balJfqwwTBddxfnidJZagCBPP/f48zj9Sdp3OJswREOgsJzHiQSaOIAtApSgDQFYgHqAvFkp53AFSqjMDZoTFw==", 82 | "engines": { 83 | "node": ">=16.20.1" 84 | } 85 | }, 86 | "node_modules/bytes": { 87 | "version": "3.1.2", 88 | "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", 89 | "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", 90 | "engines": { 91 | "node": ">= 0.8" 92 | } 93 | }, 94 | "node_modules/call-bind": { 95 | "version": "1.0.6", 96 | "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.6.tgz", 97 | "integrity": "sha512-Mj50FLHtlsoVfRfnHaZvyrooHcrlceNZdL/QBvJJVd9Ta55qCQK0gs4ss2oZDeV9zFCs6ewzYgVE5yfVmfFpVg==", 98 | "dependencies": { 99 | "es-errors": "^1.3.0", 100 | "function-bind": "^1.1.2", 101 | "get-intrinsic": "^1.2.3", 102 | "set-function-length": "^1.2.0" 103 | }, 104 | "engines": { 105 | "node": ">= 0.4" 106 | }, 107 | "funding": { 108 | "url": "https://github.com/sponsors/ljharb" 109 | } 110 | }, 111 | "node_modules/content-disposition": { 112 | "version": "0.5.4", 113 | "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", 114 | "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", 115 | "dependencies": { 116 | "safe-buffer": "5.2.1" 117 | }, 118 | "engines": { 119 | "node": ">= 0.6" 120 | } 121 | }, 122 | "node_modules/content-type": { 123 | "version": "1.0.5", 124 | "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", 125 | "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", 126 | "engines": { 127 | "node": ">= 0.6" 128 | } 129 | }, 130 | "node_modules/cookie": { 131 | "version": "0.5.0", 132 | "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", 133 | "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==", 134 | "engines": { 135 | "node": ">= 0.6" 136 | } 137 | }, 138 | "node_modules/cookie-signature": { 139 | "version": "1.0.6", 140 | "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", 141 | "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==" 142 | }, 143 | "node_modules/cors": { 144 | "version": "2.8.5", 145 | "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", 146 | "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", 147 | "dependencies": { 148 | "object-assign": "^4", 149 | "vary": "^1" 150 | }, 151 | "engines": { 152 | "node": ">= 0.10" 153 | } 154 | }, 155 | "node_modules/debug": { 156 | "version": "2.6.9", 157 | "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", 158 | "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", 159 | "dependencies": { 160 | "ms": "2.0.0" 161 | } 162 | }, 163 | "node_modules/define-data-property": { 164 | "version": "1.1.2", 165 | "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.2.tgz", 166 | "integrity": "sha512-SRtsSqsDbgpJBbW3pABMCOt6rQyeM8s8RiyeSN8jYG8sYmt/kGJejbydttUsnDs1tadr19tvhT4ShwMyoqAm4g==", 167 | "dependencies": { 168 | "es-errors": "^1.3.0", 169 | "get-intrinsic": "^1.2.2", 170 | "gopd": "^1.0.1", 171 | "has-property-descriptors": "^1.0.1" 172 | }, 173 | "engines": { 174 | "node": ">= 0.4" 175 | } 176 | }, 177 | "node_modules/depd": { 178 | "version": "2.0.0", 179 | "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", 180 | "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", 181 | "engines": { 182 | "node": ">= 0.8" 183 | } 184 | }, 185 | "node_modules/destroy": { 186 | "version": "1.2.0", 187 | "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", 188 | "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", 189 | "engines": { 190 | "node": ">= 0.8", 191 | "npm": "1.2.8000 || >= 1.4.16" 192 | } 193 | }, 194 | "node_modules/ee-first": { 195 | "version": "1.1.1", 196 | "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", 197 | "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" 198 | }, 199 | "node_modules/encodeurl": { 200 | "version": "1.0.2", 201 | "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", 202 | "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", 203 | "engines": { 204 | "node": ">= 0.8" 205 | } 206 | }, 207 | "node_modules/es-errors": { 208 | "version": "1.3.0", 209 | "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", 210 | "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", 211 | "engines": { 212 | "node": ">= 0.4" 213 | } 214 | }, 215 | "node_modules/escape-html": { 216 | "version": "1.0.3", 217 | "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", 218 | "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==" 219 | }, 220 | "node_modules/etag": { 221 | "version": "1.8.1", 222 | "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", 223 | "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", 224 | "engines": { 225 | "node": ">= 0.6" 226 | } 227 | }, 228 | "node_modules/express": { 229 | "version": "4.18.2", 230 | "resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz", 231 | "integrity": "sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==", 232 | "dependencies": { 233 | "accepts": "~1.3.8", 234 | "array-flatten": "1.1.1", 235 | "body-parser": "1.20.1", 236 | "content-disposition": "0.5.4", 237 | "content-type": "~1.0.4", 238 | "cookie": "0.5.0", 239 | "cookie-signature": "1.0.6", 240 | "debug": "2.6.9", 241 | "depd": "2.0.0", 242 | "encodeurl": "~1.0.2", 243 | "escape-html": "~1.0.3", 244 | "etag": "~1.8.1", 245 | "finalhandler": "1.2.0", 246 | "fresh": "0.5.2", 247 | "http-errors": "2.0.0", 248 | "merge-descriptors": "1.0.1", 249 | "methods": "~1.1.2", 250 | "on-finished": "2.4.1", 251 | "parseurl": "~1.3.3", 252 | "path-to-regexp": "0.1.7", 253 | "proxy-addr": "~2.0.7", 254 | "qs": "6.11.0", 255 | "range-parser": "~1.2.1", 256 | "safe-buffer": "5.2.1", 257 | "send": "0.18.0", 258 | "serve-static": "1.15.0", 259 | "setprototypeof": "1.2.0", 260 | "statuses": "2.0.1", 261 | "type-is": "~1.6.18", 262 | "utils-merge": "1.0.1", 263 | "vary": "~1.1.2" 264 | }, 265 | "engines": { 266 | "node": ">= 0.10.0" 267 | } 268 | }, 269 | "node_modules/finalhandler": { 270 | "version": "1.2.0", 271 | "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz", 272 | "integrity": "sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==", 273 | "dependencies": { 274 | "debug": "2.6.9", 275 | "encodeurl": "~1.0.2", 276 | "escape-html": "~1.0.3", 277 | "on-finished": "2.4.1", 278 | "parseurl": "~1.3.3", 279 | "statuses": "2.0.1", 280 | "unpipe": "~1.0.0" 281 | }, 282 | "engines": { 283 | "node": ">= 0.8" 284 | } 285 | }, 286 | "node_modules/forwarded": { 287 | "version": "0.2.0", 288 | "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", 289 | "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", 290 | "engines": { 291 | "node": ">= 0.6" 292 | } 293 | }, 294 | "node_modules/fresh": { 295 | "version": "0.5.2", 296 | "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", 297 | "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", 298 | "engines": { 299 | "node": ">= 0.6" 300 | } 301 | }, 302 | "node_modules/function-bind": { 303 | "version": "1.1.2", 304 | "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", 305 | "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", 306 | "funding": { 307 | "url": "https://github.com/sponsors/ljharb" 308 | } 309 | }, 310 | "node_modules/get-intrinsic": { 311 | "version": "1.2.4", 312 | "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz", 313 | "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==", 314 | "dependencies": { 315 | "es-errors": "^1.3.0", 316 | "function-bind": "^1.1.2", 317 | "has-proto": "^1.0.1", 318 | "has-symbols": "^1.0.3", 319 | "hasown": "^2.0.0" 320 | }, 321 | "engines": { 322 | "node": ">= 0.4" 323 | }, 324 | "funding": { 325 | "url": "https://github.com/sponsors/ljharb" 326 | } 327 | }, 328 | "node_modules/gopd": { 329 | "version": "1.0.1", 330 | "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", 331 | "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", 332 | "dependencies": { 333 | "get-intrinsic": "^1.1.3" 334 | }, 335 | "funding": { 336 | "url": "https://github.com/sponsors/ljharb" 337 | } 338 | }, 339 | "node_modules/has-property-descriptors": { 340 | "version": "1.0.1", 341 | "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.1.tgz", 342 | "integrity": "sha512-VsX8eaIewvas0xnvinAe9bw4WfIeODpGYikiWYLH+dma0Jw6KHYqWiWfhQlgOVK8D6PvjubK5Uc4P0iIhIcNVg==", 343 | "dependencies": { 344 | "get-intrinsic": "^1.2.2" 345 | }, 346 | "funding": { 347 | "url": "https://github.com/sponsors/ljharb" 348 | } 349 | }, 350 | "node_modules/has-proto": { 351 | "version": "1.0.1", 352 | "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.1.tgz", 353 | "integrity": "sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg==", 354 | "engines": { 355 | "node": ">= 0.4" 356 | }, 357 | "funding": { 358 | "url": "https://github.com/sponsors/ljharb" 359 | } 360 | }, 361 | "node_modules/has-symbols": { 362 | "version": "1.0.3", 363 | "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", 364 | "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", 365 | "engines": { 366 | "node": ">= 0.4" 367 | }, 368 | "funding": { 369 | "url": "https://github.com/sponsors/ljharb" 370 | } 371 | }, 372 | "node_modules/hasown": { 373 | "version": "2.0.0", 374 | "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.0.tgz", 375 | "integrity": "sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA==", 376 | "dependencies": { 377 | "function-bind": "^1.1.2" 378 | }, 379 | "engines": { 380 | "node": ">= 0.4" 381 | } 382 | }, 383 | "node_modules/http-errors": { 384 | "version": "2.0.0", 385 | "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", 386 | "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", 387 | "dependencies": { 388 | "depd": "2.0.0", 389 | "inherits": "2.0.4", 390 | "setprototypeof": "1.2.0", 391 | "statuses": "2.0.1", 392 | "toidentifier": "1.0.1" 393 | }, 394 | "engines": { 395 | "node": ">= 0.8" 396 | } 397 | }, 398 | "node_modules/iconv-lite": { 399 | "version": "0.4.24", 400 | "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", 401 | "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", 402 | "dependencies": { 403 | "safer-buffer": ">= 2.1.2 < 3" 404 | }, 405 | "engines": { 406 | "node": ">=0.10.0" 407 | } 408 | }, 409 | "node_modules/inherits": { 410 | "version": "2.0.4", 411 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", 412 | "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" 413 | }, 414 | "node_modules/ipaddr.js": { 415 | "version": "1.9.1", 416 | "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", 417 | "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", 418 | "engines": { 419 | "node": ">= 0.10" 420 | } 421 | }, 422 | "node_modules/media-typer": { 423 | "version": "0.3.0", 424 | "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", 425 | "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", 426 | "engines": { 427 | "node": ">= 0.6" 428 | } 429 | }, 430 | "node_modules/memory-pager": { 431 | "version": "1.5.0", 432 | "resolved": "https://registry.npmjs.org/memory-pager/-/memory-pager-1.5.0.tgz", 433 | "integrity": "sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg==" 434 | }, 435 | "node_modules/merge-descriptors": { 436 | "version": "1.0.1", 437 | "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", 438 | "integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==" 439 | }, 440 | "node_modules/methods": { 441 | "version": "1.1.2", 442 | "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", 443 | "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", 444 | "engines": { 445 | "node": ">= 0.6" 446 | } 447 | }, 448 | "node_modules/mime": { 449 | "version": "1.6.0", 450 | "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", 451 | "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", 452 | "bin": { 453 | "mime": "cli.js" 454 | }, 455 | "engines": { 456 | "node": ">=4" 457 | } 458 | }, 459 | "node_modules/mime-db": { 460 | "version": "1.52.0", 461 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", 462 | "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", 463 | "engines": { 464 | "node": ">= 0.6" 465 | } 466 | }, 467 | "node_modules/mime-types": { 468 | "version": "2.1.35", 469 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", 470 | "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", 471 | "dependencies": { 472 | "mime-db": "1.52.0" 473 | }, 474 | "engines": { 475 | "node": ">= 0.6" 476 | } 477 | }, 478 | "node_modules/mongodb": { 479 | "version": "6.3.0", 480 | "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.3.0.tgz", 481 | "integrity": "sha512-tt0KuGjGtLUhLoU263+xvQmPHEGTw5LbcNC73EoFRYgSHwZt5tsoJC110hDyO1kjQzpgNrpdcSza9PknWN4LrA==", 482 | "dependencies": { 483 | "@mongodb-js/saslprep": "^1.1.0", 484 | "bson": "^6.2.0", 485 | "mongodb-connection-string-url": "^3.0.0" 486 | }, 487 | "engines": { 488 | "node": ">=16.20.1" 489 | }, 490 | "peerDependencies": { 491 | "@aws-sdk/credential-providers": "^3.188.0", 492 | "@mongodb-js/zstd": "^1.1.0", 493 | "gcp-metadata": "^5.2.0", 494 | "kerberos": "^2.0.1", 495 | "mongodb-client-encryption": ">=6.0.0 <7", 496 | "snappy": "^7.2.2", 497 | "socks": "^2.7.1" 498 | }, 499 | "peerDependenciesMeta": { 500 | "@aws-sdk/credential-providers": { 501 | "optional": true 502 | }, 503 | "@mongodb-js/zstd": { 504 | "optional": true 505 | }, 506 | "gcp-metadata": { 507 | "optional": true 508 | }, 509 | "kerberos": { 510 | "optional": true 511 | }, 512 | "mongodb-client-encryption": { 513 | "optional": true 514 | }, 515 | "snappy": { 516 | "optional": true 517 | }, 518 | "socks": { 519 | "optional": true 520 | } 521 | } 522 | }, 523 | "node_modules/mongodb-connection-string-url": { 524 | "version": "3.0.0", 525 | "resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-3.0.0.tgz", 526 | "integrity": "sha512-t1Vf+m1I5hC2M5RJx/7AtxgABy1cZmIPQRMXw+gEIPn/cZNF3Oiy+l0UIypUwVB5trcWHq3crg2g3uAR9aAwsQ==", 527 | "dependencies": { 528 | "@types/whatwg-url": "^11.0.2", 529 | "whatwg-url": "^13.0.0" 530 | } 531 | }, 532 | "node_modules/ms": { 533 | "version": "2.0.0", 534 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", 535 | "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" 536 | }, 537 | "node_modules/negotiator": { 538 | "version": "0.6.3", 539 | "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", 540 | "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", 541 | "engines": { 542 | "node": ">= 0.6" 543 | } 544 | }, 545 | "node_modules/object-assign": { 546 | "version": "4.1.1", 547 | "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", 548 | "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", 549 | "engines": { 550 | "node": ">=0.10.0" 551 | } 552 | }, 553 | "node_modules/object-inspect": { 554 | "version": "1.13.1", 555 | "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.1.tgz", 556 | "integrity": "sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ==", 557 | "funding": { 558 | "url": "https://github.com/sponsors/ljharb" 559 | } 560 | }, 561 | "node_modules/on-finished": { 562 | "version": "2.4.1", 563 | "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", 564 | "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", 565 | "dependencies": { 566 | "ee-first": "1.1.1" 567 | }, 568 | "engines": { 569 | "node": ">= 0.8" 570 | } 571 | }, 572 | "node_modules/parseurl": { 573 | "version": "1.3.3", 574 | "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", 575 | "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", 576 | "engines": { 577 | "node": ">= 0.8" 578 | } 579 | }, 580 | "node_modules/path-to-regexp": { 581 | "version": "0.1.7", 582 | "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", 583 | "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==" 584 | }, 585 | "node_modules/proxy-addr": { 586 | "version": "2.0.7", 587 | "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", 588 | "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", 589 | "dependencies": { 590 | "forwarded": "0.2.0", 591 | "ipaddr.js": "1.9.1" 592 | }, 593 | "engines": { 594 | "node": ">= 0.10" 595 | } 596 | }, 597 | "node_modules/punycode": { 598 | "version": "2.3.1", 599 | "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", 600 | "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", 601 | "engines": { 602 | "node": ">=6" 603 | } 604 | }, 605 | "node_modules/qs": { 606 | "version": "6.11.0", 607 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", 608 | "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", 609 | "dependencies": { 610 | "side-channel": "^1.0.4" 611 | }, 612 | "engines": { 613 | "node": ">=0.6" 614 | }, 615 | "funding": { 616 | "url": "https://github.com/sponsors/ljharb" 617 | } 618 | }, 619 | "node_modules/range-parser": { 620 | "version": "1.2.1", 621 | "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", 622 | "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", 623 | "engines": { 624 | "node": ">= 0.6" 625 | } 626 | }, 627 | "node_modules/raw-body": { 628 | "version": "2.5.1", 629 | "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz", 630 | "integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==", 631 | "dependencies": { 632 | "bytes": "3.1.2", 633 | "http-errors": "2.0.0", 634 | "iconv-lite": "0.4.24", 635 | "unpipe": "1.0.0" 636 | }, 637 | "engines": { 638 | "node": ">= 0.8" 639 | } 640 | }, 641 | "node_modules/safe-buffer": { 642 | "version": "5.2.1", 643 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", 644 | "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", 645 | "funding": [ 646 | { 647 | "type": "github", 648 | "url": "https://github.com/sponsors/feross" 649 | }, 650 | { 651 | "type": "patreon", 652 | "url": "https://www.patreon.com/feross" 653 | }, 654 | { 655 | "type": "consulting", 656 | "url": "https://feross.org/support" 657 | } 658 | ] 659 | }, 660 | "node_modules/safer-buffer": { 661 | "version": "2.1.2", 662 | "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", 663 | "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" 664 | }, 665 | "node_modules/send": { 666 | "version": "0.18.0", 667 | "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", 668 | "integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==", 669 | "dependencies": { 670 | "debug": "2.6.9", 671 | "depd": "2.0.0", 672 | "destroy": "1.2.0", 673 | "encodeurl": "~1.0.2", 674 | "escape-html": "~1.0.3", 675 | "etag": "~1.8.1", 676 | "fresh": "0.5.2", 677 | "http-errors": "2.0.0", 678 | "mime": "1.6.0", 679 | "ms": "2.1.3", 680 | "on-finished": "2.4.1", 681 | "range-parser": "~1.2.1", 682 | "statuses": "2.0.1" 683 | }, 684 | "engines": { 685 | "node": ">= 0.8.0" 686 | } 687 | }, 688 | "node_modules/send/node_modules/ms": { 689 | "version": "2.1.3", 690 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", 691 | "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" 692 | }, 693 | "node_modules/serve-static": { 694 | "version": "1.15.0", 695 | "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz", 696 | "integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==", 697 | "dependencies": { 698 | "encodeurl": "~1.0.2", 699 | "escape-html": "~1.0.3", 700 | "parseurl": "~1.3.3", 701 | "send": "0.18.0" 702 | }, 703 | "engines": { 704 | "node": ">= 0.8.0" 705 | } 706 | }, 707 | "node_modules/set-function-length": { 708 | "version": "1.2.1", 709 | "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.1.tgz", 710 | "integrity": "sha512-j4t6ccc+VsKwYHso+kElc5neZpjtq9EnRICFZtWyBsLojhmeF/ZBd/elqm22WJh/BziDe/SBiOeAt0m2mfLD0g==", 711 | "dependencies": { 712 | "define-data-property": "^1.1.2", 713 | "es-errors": "^1.3.0", 714 | "function-bind": "^1.1.2", 715 | "get-intrinsic": "^1.2.3", 716 | "gopd": "^1.0.1", 717 | "has-property-descriptors": "^1.0.1" 718 | }, 719 | "engines": { 720 | "node": ">= 0.4" 721 | } 722 | }, 723 | "node_modules/setprototypeof": { 724 | "version": "1.2.0", 725 | "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", 726 | "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" 727 | }, 728 | "node_modules/side-channel": { 729 | "version": "1.0.5", 730 | "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.5.tgz", 731 | "integrity": "sha512-QcgiIWV4WV7qWExbN5llt6frQB/lBven9pqliLXfGPB+K9ZYXxDozp0wLkHS24kWCm+6YXH/f0HhnObZnZOBnQ==", 732 | "dependencies": { 733 | "call-bind": "^1.0.6", 734 | "es-errors": "^1.3.0", 735 | "get-intrinsic": "^1.2.4", 736 | "object-inspect": "^1.13.1" 737 | }, 738 | "engines": { 739 | "node": ">= 0.4" 740 | }, 741 | "funding": { 742 | "url": "https://github.com/sponsors/ljharb" 743 | } 744 | }, 745 | "node_modules/sparse-bitfield": { 746 | "version": "3.0.3", 747 | "resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz", 748 | "integrity": "sha512-kvzhi7vqKTfkh0PZU+2D2PIllw2ymqJKujUcyPMd9Y75Nv4nPbGJZXNhxsgdQab2BmlDct1YnfQCguEvHr7VsQ==", 749 | "dependencies": { 750 | "memory-pager": "^1.0.2" 751 | } 752 | }, 753 | "node_modules/statuses": { 754 | "version": "2.0.1", 755 | "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", 756 | "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==", 757 | "engines": { 758 | "node": ">= 0.8" 759 | } 760 | }, 761 | "node_modules/toidentifier": { 762 | "version": "1.0.1", 763 | "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", 764 | "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", 765 | "engines": { 766 | "node": ">=0.6" 767 | } 768 | }, 769 | "node_modules/tr46": { 770 | "version": "4.1.1", 771 | "resolved": "https://registry.npmjs.org/tr46/-/tr46-4.1.1.tgz", 772 | "integrity": "sha512-2lv/66T7e5yNyhAAC4NaKe5nVavzuGJQVVtRYLyQ2OI8tsJ61PMLlelehb0wi2Hx6+hT/OJUWZcw8MjlSRnxvw==", 773 | "dependencies": { 774 | "punycode": "^2.3.0" 775 | }, 776 | "engines": { 777 | "node": ">=14" 778 | } 779 | }, 780 | "node_modules/type-is": { 781 | "version": "1.6.18", 782 | "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", 783 | "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", 784 | "dependencies": { 785 | "media-typer": "0.3.0", 786 | "mime-types": "~2.1.24" 787 | }, 788 | "engines": { 789 | "node": ">= 0.6" 790 | } 791 | }, 792 | "node_modules/unpipe": { 793 | "version": "1.0.0", 794 | "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", 795 | "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", 796 | "engines": { 797 | "node": ">= 0.8" 798 | } 799 | }, 800 | "node_modules/utils-merge": { 801 | "version": "1.0.1", 802 | "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", 803 | "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==", 804 | "engines": { 805 | "node": ">= 0.4.0" 806 | } 807 | }, 808 | "node_modules/vary": { 809 | "version": "1.1.2", 810 | "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", 811 | "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", 812 | "engines": { 813 | "node": ">= 0.8" 814 | } 815 | }, 816 | "node_modules/webidl-conversions": { 817 | "version": "7.0.0", 818 | "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz", 819 | "integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==", 820 | "engines": { 821 | "node": ">=12" 822 | } 823 | }, 824 | "node_modules/whatwg-url": { 825 | "version": "13.0.0", 826 | "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-13.0.0.tgz", 827 | "integrity": "sha512-9WWbymnqj57+XEuqADHrCJ2eSXzn8WXIW/YSGaZtb2WKAInQ6CHfaUUcTyyver0p8BDg5StLQq8h1vtZuwmOig==", 828 | "dependencies": { 829 | "tr46": "^4.1.1", 830 | "webidl-conversions": "^7.0.0" 831 | }, 832 | "engines": { 833 | "node": ">=16" 834 | } 835 | } 836 | } 837 | } 838 | -------------------------------------------------------------------------------- /mern/server/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "server", 3 | "version": "1.0.0", 4 | "description": "Node.js, Express, and MongoDB REST CRUD API", 5 | "type": "module", 6 | "main": "server.js", 7 | "scripts": { 8 | "start": "node --env-file=config.env server", 9 | "test": "echo \"Error: no test specified\" && exit 1" 10 | }, 11 | "keywords": [], 12 | "author": "", 13 | "license": "ISC", 14 | "dependencies": { 15 | "cors": "^2.8.5", 16 | "express": "^4.18.2", 17 | "mongodb": "^6.3.0" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /mern/server/routes/record.js: -------------------------------------------------------------------------------- 1 | import express from "express"; 2 | 3 | // This will help us connect to the database 4 | import db from "../db/connection.js"; 5 | 6 | // This help convert the id from string to ObjectId for the _id. 7 | import { ObjectId } from "mongodb"; 8 | 9 | // router is an instance of the express router. 10 | // We use it to define our routes. 11 | // The router will be added as a middleware and will take control of requests starting with path /record. 12 | const router = express.Router(); 13 | 14 | // This section will help you get a list of all the records. 15 | router.get("/", async (req, res) => { 16 | let collection = await db.collection("records"); 17 | let results = await collection.find({}).toArray(); 18 | res.send(results).status(200); 19 | }); 20 | 21 | // This section will help you get a single record by id 22 | router.get("/:id", async (req, res) => { 23 | let collection = await db.collection("records"); 24 | let query = { _id: new ObjectId(req.params.id) }; 25 | let result = await collection.findOne(query); 26 | 27 | if (!result) res.send("Not found").status(404); 28 | else res.send(result).status(200); 29 | }); 30 | 31 | // This section will help you create a new record. 32 | router.post("/", async (req, res) => { 33 | try { 34 | let newDocument = { 35 | name: req.body.name, 36 | position: req.body.position, 37 | level: req.body.level, 38 | }; 39 | let collection = await db.collection("records"); 40 | let result = await collection.insertOne(newDocument); 41 | res.send(result).status(204); 42 | } catch (err) { 43 | console.error(err); 44 | res.status(500).send("Error adding record"); 45 | } 46 | }); 47 | 48 | // This section will help you update a record by id. 49 | router.patch("/:id", async (req, res) => { 50 | try { 51 | const query = { _id: new ObjectId(req.params.id) }; 52 | const updates = { 53 | $set: { 54 | name: req.body.name, 55 | position: req.body.position, 56 | level: req.body.level, 57 | }, 58 | }; 59 | 60 | let collection = await db.collection("records"); 61 | let result = await collection.updateOne(query, updates); 62 | res.send(result).status(200); 63 | } catch (err) { 64 | console.error(err); 65 | res.status(500).send("Error updating record"); 66 | } 67 | }); 68 | 69 | // This section will help you delete a record 70 | router.delete("/:id", async (req, res) => { 71 | try { 72 | const query = { _id: new ObjectId(req.params.id) }; 73 | 74 | const collection = db.collection("records"); 75 | let result = await collection.deleteOne(query); 76 | 77 | res.send(result).status(200); 78 | } catch (err) { 79 | console.error(err); 80 | res.status(500).send("Error deleting record"); 81 | } 82 | }); 83 | 84 | export default router; 85 | -------------------------------------------------------------------------------- /mern/server/server.js: -------------------------------------------------------------------------------- 1 | import express from "express"; 2 | import cors from "cors"; 3 | import records from "./routes/record.js"; 4 | 5 | const PORT = process.env.PORT || 5050; 6 | const app = express(); 7 | 8 | app.use(cors()); 9 | app.use(express.json()); 10 | app.use("/record", records); 11 | 12 | // start the Express server 13 | app.listen(PORT, () => { 14 | console.log(`Server listening on port ${PORT}`); 15 | }); 16 | --------------------------------------------------------------------------------