From f1d32834cb33ca84aa8c28e6f2dd79c6d5a65057 Mon Sep 17 00:00:00 2001 From: Abel Busto Dopazo Date: Sat, 29 Apr 2023 01:19:52 +0200 Subject: [PATCH 01/17] Views test --- webapp/src/podManager/MapManager.ts | 6 +++- webapp/src/test/views/HomeView.test.tsx | 28 ++++++++++++++++++ webapp/src/test/views/LoggedView.test.tsx | 36 +++++++++++++++++++++++ webapp/src/test/views/LoginView.test.tsx | 27 +++++++++++++++++ webapp/src/test/views/NoFound.test.tsx | 27 +++++++++++++++++ webapp/src/test/views/PodView.test.tsx | 30 +++++++++++++++++++ webapp/src/test/views/SignupView.test.tsx | 27 +++++++++++++++++ webapp/src/views/LoggedView.tsx | 15 +++------- 8 files changed, 184 insertions(+), 12 deletions(-) create mode 100644 webapp/src/test/views/HomeView.test.tsx create mode 100644 webapp/src/test/views/LoggedView.test.tsx create mode 100644 webapp/src/test/views/LoginView.test.tsx create mode 100644 webapp/src/test/views/NoFound.test.tsx create mode 100644 webapp/src/test/views/PodView.test.tsx create mode 100644 webapp/src/test/views/SignupView.test.tsx diff --git a/webapp/src/podManager/MapManager.ts b/webapp/src/podManager/MapManager.ts index 712d90b..6381c82 100644 --- a/webapp/src/podManager/MapManager.ts +++ b/webapp/src/podManager/MapManager.ts @@ -12,6 +12,10 @@ export async function verMapaDe(user: User, session: Session): Promise return grupos } +export async function obtenerFoto(webId: any) { + return await pod.getPhoto(webId); +} + export async function verMapaDeAmigo(user: User, session: Session): Promise { let grupos = await pod.getFriendsGroups(session, user.webID) return grupos @@ -47,7 +51,7 @@ export async function eliminarGrupo(grupo: Group, session: Session): Promise { - return await pod.addReadPermissionsToFriend(webId, friendWebId, session); + return await pod.addReadPermissionsToFriend(webId, friendWebId, session); } export async function eliminarLugarDeGrupo(lugar: Place, grupo: Group, session: Session): Promise { diff --git a/webapp/src/test/views/HomeView.test.tsx b/webapp/src/test/views/HomeView.test.tsx new file mode 100644 index 0000000..83a4584 --- /dev/null +++ b/webapp/src/test/views/HomeView.test.tsx @@ -0,0 +1,28 @@ +import { render, screen } from '@testing-library/react'; +import { MemoryRouter, Route, Routes } from 'react-router-dom'; +import { Provider } from 'react-redux'; +import store from 'utils/redux/store'; +import HomeView from 'views/HomeView'; + +jest.mock('components/mainComponents/Header', () => ({ Header: () => { return (
Mock
) } })) +jest.mock('components/mainComponents/Footer', () => ({ Footer: () => { return (
Mock
) } })) + +test('home view renders outletpage, header and footer', () => { + render( + + + + }> + } /> + + + + + ); + let linkElement = screen.getByTestId("mockHeader") + expect(linkElement).toBeInTheDocument(); + linkElement = screen.getByTestId("mockFooter") + expect(linkElement).toBeInTheDocument(); + linkElement = screen.getByTestId("outletElement"); + expect(linkElement).toBeInTheDocument(); +}); \ No newline at end of file diff --git a/webapp/src/test/views/LoggedView.test.tsx b/webapp/src/test/views/LoggedView.test.tsx new file mode 100644 index 0000000..337c21c --- /dev/null +++ b/webapp/src/test/views/LoggedView.test.tsx @@ -0,0 +1,36 @@ +import "@inrupt/jest-jsdom-polyfills"; +import { render, screen } from '@testing-library/react'; +import { MemoryRouter, Route, Routes } from 'react-router-dom'; +import { Provider } from 'react-redux'; +import store from 'utils/redux/store'; +import LoggedView from 'views/LoggedView'; +import { act } from "react-dom/test-utils"; +import { SessionProvider } from "@inrupt/solid-ui-react"; + +jest.mock('components/mainComponents/Header', () => ({ Header: () => { return (
Mock
) } })) +jest.mock('components/mainComponents/Footer', () => ({ Footer: () => { return (
Mock
) } })) + +test('logged view no welcome renders outletpage, header and footer', async () => { + + await act(async () => { + render( + + + + + }> + } /> + + + + + + ); + }); + let linkElement = screen.getByTestId("mockHeader") + expect(linkElement).toBeInTheDocument(); + linkElement = screen.getByTestId("mockFooter") + expect(linkElement).toBeInTheDocument(); + linkElement = screen.getByTestId("outletElement"); + expect(linkElement).toBeInTheDocument(); +}); \ No newline at end of file diff --git a/webapp/src/test/views/LoginView.test.tsx b/webapp/src/test/views/LoginView.test.tsx new file mode 100644 index 0000000..e612bbe --- /dev/null +++ b/webapp/src/test/views/LoginView.test.tsx @@ -0,0 +1,27 @@ +import { render, screen } from '@testing-library/react'; +import { MemoryRouter, Route, Routes } from 'react-router-dom'; +import { Provider } from 'react-redux'; +import store from 'utils/redux/store'; +import LoginView from 'views/LoginView'; + +jest.mock('components/userIdentification/LoginForm', () => ({ Login: () => { return (
Mock
) } })) +jest.mock('components/mainComponents/Header', () => ({ Header: () => { return (
Mock
) } })) +jest.mock('components/mainComponents/Footer', () => ({ Footer: () => { return (
Mock
) } })) + +test('login view render login, header and footer', () => { + render( + + + + } /> + + + + ); + let linkElement = screen.getByTestId("mockHeader") + expect(linkElement).toBeInTheDocument(); + linkElement = screen.getByTestId("mockFooter") + expect(linkElement).toBeInTheDocument(); + linkElement = screen.getByTestId("mockLogin"); + expect(linkElement).toBeInTheDocument(); +}); \ No newline at end of file diff --git a/webapp/src/test/views/NoFound.test.tsx b/webapp/src/test/views/NoFound.test.tsx new file mode 100644 index 0000000..9b230c8 --- /dev/null +++ b/webapp/src/test/views/NoFound.test.tsx @@ -0,0 +1,27 @@ +import { render, screen } from '@testing-library/react'; +import { MemoryRouter, Route, Routes } from 'react-router-dom'; +import { Provider } from 'react-redux'; +import store from 'utils/redux/store'; +import HomeView from 'views/HomeView'; +import { NoFound } from 'views/NoFound'; + +jest.mock('components/mainComponents/Header', () => ({ Header: () => { return (
Mock
) } })) +jest.mock('components/mainComponents/Footer', () => ({ Footer: () => { return (
Mock
) } })) + +test('no found renders errorPage, footer and header', () => { + render( + + + + } /> + + + + ); + let linkElement = screen.getByTestId("mockHeader") + expect(linkElement).toBeInTheDocument(); + linkElement = screen.getByTestId("mockFooter") + expect(linkElement).toBeInTheDocument(); + linkElement = screen.getByText(/Error 404/i); + expect(linkElement).toBeInTheDocument(); +}); \ No newline at end of file diff --git a/webapp/src/test/views/PodView.test.tsx b/webapp/src/test/views/PodView.test.tsx new file mode 100644 index 0000000..ba17118 --- /dev/null +++ b/webapp/src/test/views/PodView.test.tsx @@ -0,0 +1,30 @@ +import "@inrupt/jest-jsdom-polyfills"; +import { render, screen } from '@testing-library/react'; +import { MemoryRouter, Route, Routes } from 'react-router-dom'; +import { Provider } from 'react-redux'; +import store from 'utils/redux/store'; +import PodView from 'views/PodView'; +import { act } from 'react-dom/test-utils'; + +jest.mock('components/mainComponents/Header', () => ({ Header: () => { return (
Mock
) } })) +jest.mock('components/mainComponents/Footer', () => ({ Footer: () => { return (
Mock
) } })) + +test('pod view renders podPage, header and footer', async () => { + await act(async () => { + render( + + + + } /> + + + + ); + }) + let linkElement = screen.getByTestId("mockHeader") + expect(linkElement).toBeInTheDocument(); + linkElement = screen.getByTestId("mockFooter") + expect(linkElement).toBeInTheDocument(); + linkElement = screen.getByText(/Inicia sesión con tu proveedor de pod/); + expect(linkElement).toBeInTheDocument(); +}); \ No newline at end of file diff --git a/webapp/src/test/views/SignupView.test.tsx b/webapp/src/test/views/SignupView.test.tsx new file mode 100644 index 0000000..f8c5714 --- /dev/null +++ b/webapp/src/test/views/SignupView.test.tsx @@ -0,0 +1,27 @@ +import { render, screen } from '@testing-library/react'; +import { MemoryRouter, Route, Routes } from 'react-router-dom'; +import { Provider } from 'react-redux'; +import store from 'utils/redux/store'; +import SignupView from 'views/SignupView'; + +jest.mock('components/userIdentification/SignupForm', () => ({ Signup: () => { return (
Mock
) } })) +jest.mock('components/mainComponents/Header', () => ({ Header: () => { return (
Mock
) } })) +jest.mock('components/mainComponents/Footer', () => ({ Footer: () => { return (
Mock
) } })) + +test('login view render login, header and footer', () => { + render( + + + + } /> + + + + ); + let linkElement = screen.getByTestId("mockHeader") + expect(linkElement).toBeInTheDocument(); + linkElement = screen.getByTestId("mockFooter") + expect(linkElement).toBeInTheDocument(); + linkElement = screen.getByTestId("mockSignup"); + expect(linkElement).toBeInTheDocument(); +}); \ No newline at end of file diff --git a/webapp/src/views/LoggedView.tsx b/webapp/src/views/LoggedView.tsx index 903fc35..832e2fb 100644 --- a/webapp/src/views/LoggedView.tsx +++ b/webapp/src/views/LoggedView.tsx @@ -13,7 +13,7 @@ import { Outlet, useNavigate, useParams } from 'react-router-dom'; import { readCookie } from 'utils/CookieReader'; import { useDispatch } from 'react-redux'; import { setProfileImage } from 'utils/redux/action'; -import PodManager from 'podManager/PodManager'; +import { obtenerFoto } from 'podManager/MapManager'; //#region DEFINICION DE COMPONENTES STYLED const MyContainer = styled(Container)({ @@ -47,7 +47,7 @@ export default function LoggedView() { const profileImageUrl = async () => { - return await new PodManager().getPhoto(session.info.webId); + return await obtenerFoto(session.info.webId); } if (session.info.webId) { @@ -57,7 +57,6 @@ export default function LoggedView() { React.useEffect(() => { if (welcome && readCookie("sameWebId") !== "true" && session.info.webId) checkWebId(); - const fetchImgUrl = async () => { const url = await profileImageUrl(); dispatch(setProfileImage(url)) @@ -85,8 +84,6 @@ export default function LoggedView() { const checkWebId = () => { let user: User = getUserInSesion(); setTimeout(() => { - console.log(user.webID) - console.log(readCookie("userWebId")) if (user.webID !== readCookie("userWebId")) { Swal.fire({ title: "Actualizar webId", @@ -104,17 +101,13 @@ export default function LoggedView() { editUserDetails(updatedUser); saludo(); } else { - logout(); - navigate("/login") + logout(); navigate("/login") } }) } else { - saludo(); - document.cookie = "sameWebId=true; path=/" + saludo(); document.cookie = "sameWebId=true; path=/" } - }, 3000); - } return ( From 7e4a2f1167fba476a54993cfb3a5b535765c538a Mon Sep 17 00:00:00 2001 From: Abel Busto Dopazo Date: Sat, 29 Apr 2023 01:33:03 +0200 Subject: [PATCH 02/17] Update sonar-project.properties --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index 08c48b8..24b6fa2 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -7,7 +7,7 @@ sonar.projectName=lomap_es2c sonar.projectVersion=1.0.4 sonar.coverage.exclusions=**/*.test.tsx,**/*.test.ts -sonar.sources=webapp/src/components,restapi +sonar.sources=webapp/src/components,restapi/src sonar.sourceEncoding=UTF-8 sonar.exclusions=node_modules/** sonar.typescript.lcov.reportPaths=**/coverage/lcov.info From 6e8a31863a5ad9a13684b8a4e6614abac3ab8221 Mon Sep 17 00:00:00 2001 From: Abel Busto Dopazo Date: Sat, 29 Apr 2023 11:55:33 +0200 Subject: [PATCH 03/17] Update sonar-project.properties --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index 24b6fa2..08c48b8 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -7,7 +7,7 @@ sonar.projectName=lomap_es2c sonar.projectVersion=1.0.4 sonar.coverage.exclusions=**/*.test.tsx,**/*.test.ts -sonar.sources=webapp/src/components,restapi/src +sonar.sources=webapp/src/components,restapi sonar.sourceEncoding=UTF-8 sonar.exclusions=node_modules/** sonar.typescript.lcov.reportPaths=**/coverage/lcov.info From ac001e196a9156bad89fb67608cf75505fe53362 Mon Sep 17 00:00:00 2001 From: uo269745 Date: Sat, 29 Apr 2023 12:48:39 +0200 Subject: [PATCH 04/17] changes for deployment --- .github/workflows/lomap_es2c.yml | 3 + .gitignore | 1 + restapi/Dockerfile | 4 + restapi/package-lock.json | 611 +---------------------- restapi/package.json | 2 - restapi/src/controllers/FriendManager.ts | 2 - restapi/src/controllers/UserManager.ts | 1 - restapi/src/entities/FriendRequest.ts | 1 - restapi/src/persistence/DataBase.tsx | 6 +- restapi/src/persistence/DefaultMongo.ts | 7 +- restapi/src/persistence/Repository.tsx | 1 - 11 files changed, 21 insertions(+), 618 deletions(-) diff --git a/.github/workflows/lomap_es2c.yml b/.github/workflows/lomap_es2c.yml index cc28c90..f04e1ce 100644 --- a/.github/workflows/lomap_es2c.yml +++ b/.github/workflows/lomap_es2c.yml @@ -59,6 +59,8 @@ jobs: docker-push-restapi: name: Push restapi Docker Image to GitHub Packages runs-on: ubuntu-latest + env: + DATABASE_URL: ${{ secrets.DATABASE_URL }} needs: [e2e-tests] steps: - uses: actions/checkout@v3 @@ -70,6 +72,7 @@ jobs: password: ${{ secrets.DOCKER_PUSH_TOKEN }} registry: ghcr.io workdir: restapi + buildargs: DATABASE_URL deploy: name: Deploy over SSH runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index 3d25154..80d79ed 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,4 @@ yarn-error.log* #documentation build does not go into master docs/build +restapi/.env diff --git a/restapi/Dockerfile b/restapi/Dockerfile index 9e91404..5198114 100644 --- a/restapi/Dockerfile +++ b/restapi/Dockerfile @@ -4,4 +4,8 @@ COPY . /app WORKDIR /app #Install the dependencies RUN npm install + +ARG DATABASE_URL="DATABASE_URL" +ENV DATABASE_URL=$DATABASE_URL + CMD [ "npm", "start" ] diff --git a/restapi/package-lock.json b/restapi/package-lock.json index cd41f77..93eb9d9 100644 --- a/restapi/package-lock.json +++ b/restapi/package-lock.json @@ -12,8 +12,6 @@ "bcrypt": "^5.1.0", "bcryptjs": "^2.4.3", "body-parser": "^1.20.1", - "cloudinary": "^1.35.0", - "cloudinary-client": "^0.0.1", "cors": "^2.8.5", "dotenv": "^16.0.3", "express": "^4.18.2", @@ -1113,15 +1111,6 @@ "@sinonjs/commons": "^1.7.0" } }, - "node_modules/@tootallnate/once": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz", - "integrity": "sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==", - "optional": true, - "engines": { - "node": ">= 6" - } - }, "node_modules/@tsconfig/node10": { "version": "1.0.9", "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz", @@ -1326,14 +1315,6 @@ "@types/node": "*" } }, - "node_modules/@types/sha1": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@types/sha1/-/sha1-1.1.3.tgz", - "integrity": "sha512-bXfx/6xrPu1l6pLItGRMPX00lhnJavpj2qiQeLHflXvL2Ix97aC8FTF2/pQoqukRzcCwKyN3csZvOLzamIoaSA==", - "dependencies": { - "@types/node": "*" - } - }, "node_modules/@types/stack-utils": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.1.tgz", @@ -1421,7 +1402,7 @@ "version": "8.8.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz", "integrity": "sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA==", - "devOptional": true, + "dev": true, "bin": { "acorn": "bin/acorn" }, @@ -1433,7 +1414,7 @@ "version": "8.2.0", "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz", "integrity": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==", - "devOptional": true, + "dev": true, "engines": { "node": ">=0.4.0" } @@ -1564,18 +1545,6 @@ "integrity": "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==", "dev": true }, - "node_modules/ast-types": { - "version": "0.13.4", - "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.13.4.tgz", - "integrity": "sha512-x1FCFnFifvYDDzTaLII71vG5uvDwgtmDTEVWAxrgeiR8VjMONcCXJx7E+USjDtHlwFmt9MysbqgF9b9Vjr6w+w==", - "optional": true, - "dependencies": { - "tslib": "^2.0.1" - }, - "engines": { - "node": ">=4" - } - }, "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", @@ -1896,14 +1865,6 @@ "node": ">=10" } }, - "node_modules/charenc": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz", - "integrity": "sha512-yrLQ/yVUFXkzg7EDQsPieE/53+0RlaWTs+wBrvW36cyilJ2SaDWfl4Yj7MtLTXleV9uEKefbAGUPv2/iWSooRA==", - "engines": { - "node": "*" - } - }, "node_modules/chokidar": { "version": "3.5.3", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", @@ -1974,40 +1935,6 @@ "node": ">=12" } }, - "node_modules/cloudinary": { - "version": "1.35.0", - "resolved": "https://registry.npmjs.org/cloudinary/-/cloudinary-1.35.0.tgz", - "integrity": "sha512-0aRLVOaVsoiqDCNkSzlPGR/oYOlE3AGrtwFTPx7xlZCPyKNzqeD9t9ENmPwzHn3yn/afAvy4h1sqb2yPyJOAow==", - "dependencies": { - "cloudinary-core": "^2.10.2", - "core-js": "^3.6.5", - "lodash": "^4.17.21", - "q": "^1.5.1" - }, - "engines": { - "node": ">=0.6" - }, - "optionalDependencies": { - "proxy-agent": "^5.0.0" - } - }, - "node_modules/cloudinary-client": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/cloudinary-client/-/cloudinary-client-0.0.1.tgz", - "integrity": "sha512-PXsMgwY4hgIGwiHQuZYQdlC4e9gTQJ3XGHhtYhr2y2nWg9nPqTdHF9RWdJ4TNT7TvoWZjh70pcW+8OZHBL6zMA==", - "dependencies": { - "@types/sha1": "^1.1.2", - "sha1": "^1.1.1" - } - }, - "node_modules/cloudinary-core": { - "version": "2.13.0", - "resolved": "https://registry.npmjs.org/cloudinary-core/-/cloudinary-core-2.13.0.tgz", - "integrity": "sha512-Nt0Q5I2FtenmJghtC4YZ3MZZbGg1wLm84SsxcuVwZ83OyJqG9CNIGp86CiI6iDv3QobaqBUpOT7vg+HqY5HxEA==", - "peerDependencies": { - "lodash": ">=4.0" - } - }, "node_modules/co": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", @@ -2122,22 +2049,6 @@ "integrity": "sha512-LDx6oHrK+PhzLKJU9j5S7/Y3jM/mUHvD/DeI1WQmJn652iPC5Y4TBzC9l+5OMOXlyTTA+SmVUPm0HQUwpD5Jqw==", "dev": true }, - "node_modules/core-js": { - "version": "3.30.0", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.30.0.tgz", - "integrity": "sha512-hQotSSARoNh1mYPi9O2YaWeiq/cEB95kOrFb4NCrO4RIFt1qqNpKsaE+vy/L3oiqvND5cThqXzUU3r9F7Efztg==", - "hasInstallScript": true, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/core-js" - } - }, - "node_modules/core-util-is": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", - "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", - "optional": true - }, "node_modules/cors": { "version": "2.8.5", "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", @@ -2170,23 +2081,6 @@ "node": ">= 8" } }, - "node_modules/crypt": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz", - "integrity": "sha512-mCxBlsHFYh9C+HVpiEacem8FEBnMXgU9gy4zmNC+SXAZNB/1idgp/aulFJ4FgCi7GPEVbfyng092GqL2k2rmow==", - "engines": { - "node": "*" - } - }, - "node_modules/data-uri-to-buffer": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-3.0.1.tgz", - "integrity": "sha512-WboRycPNsVw3B3TL559F7kuBUM4d8CgMEvk6xEJlOp7OBPjt6G7z8WMWlD2rOFZLk6OYfFIUGsCOWzcQH9K2og==", - "optional": true, - "engines": { - "node": ">= 6" - } - }, "node_modules/debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", @@ -2201,12 +2095,6 @@ "integrity": "sha512-Q6fKUPqnAHAyhiUgFU7BUzLiv0kd8saH9al7tnu5Q/okj6dnupxyTgFIBjVzJATdfIAm9NAsvXNzjaKa+bxVyA==", "dev": true }, - "node_modules/deep-is": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", - "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", - "optional": true - }, "node_modules/deepmerge": { "version": "4.2.2", "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.2.2.tgz", @@ -2216,21 +2104,6 @@ "node": ">=0.10.0" } }, - "node_modules/degenerator": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/degenerator/-/degenerator-3.0.3.tgz", - "integrity": "sha512-FTq/qYMeBJACu1gHcXJvzsRBTK6aw5zWCYbEnIOyamOt5UJufWJRQ5XfDb6OuayfJWvmWAHgcZyt43vm/hbj7g==", - "optional": true, - "dependencies": { - "ast-types": "^0.13.2", - "escodegen": "^1.8.1", - "esprima": "^4.0.0", - "vm2": "^3.9.11" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", @@ -2392,33 +2265,11 @@ "node": ">=8" } }, - "node_modules/escodegen": { - "version": "1.14.3", - "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.14.3.tgz", - "integrity": "sha512-qFcX0XJkdg+PB3xjZZG/wKSuT1PnQWx57+TVSjIMmILd2yC/6ByYElPwJnslDsuWuSAp4AwJGumarAAmJch5Kw==", - "optional": true, - "dependencies": { - "esprima": "^4.0.1", - "estraverse": "^4.2.0", - "esutils": "^2.0.2", - "optionator": "^0.8.1" - }, - "bin": { - "escodegen": "bin/escodegen.js", - "esgenerate": "bin/esgenerate.js" - }, - "engines": { - "node": ">=4.0" - }, - "optionalDependencies": { - "source-map": "~0.6.1" - } - }, "node_modules/esprima": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", - "devOptional": true, + "dev": true, "bin": { "esparse": "bin/esparse.js", "esvalidate": "bin/esvalidate.js" @@ -2427,24 +2278,6 @@ "node": ">=4" } }, - "node_modules/estraverse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", - "optional": true, - "engines": { - "node": ">=4.0" - } - }, - "node_modules/esutils": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", - "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", - "optional": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/etag": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", @@ -2575,12 +2408,6 @@ "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", "dev": true }, - "node_modules/fast-levenshtein": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", - "optional": true - }, "node_modules/fast-safe-stringify": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz", @@ -2596,15 +2423,6 @@ "bser": "2.1.1" } }, - "node_modules/file-uri-to-path": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-2.0.0.tgz", - "integrity": "sha512-hjPFI8oE/2iQPVe4gbrJ73Pp+Xfub2+WI2LlXDbsaJBwT5wuMh35WNWVYYTpnz895shtwfyutMFLFywpQAFdLg==", - "optional": true, - "engines": { - "node": ">= 6" - } - }, "node_modules/fill-range": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", @@ -2678,20 +2496,6 @@ "node": ">= 0.6" } }, - "node_modules/fs-extra": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz", - "integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==", - "optional": true, - "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^4.0.0", - "universalify": "^0.1.0" - }, - "engines": { - "node": ">=6 <7 || >=8" - } - }, "node_modules/fs-minipass": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz", @@ -2724,37 +2528,6 @@ "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" }, - "node_modules/ftp": { - "version": "0.3.10", - "resolved": "https://registry.npmjs.org/ftp/-/ftp-0.3.10.tgz", - "integrity": "sha512-faFVML1aBx2UoDStmLwv2Wptt4vw5x03xxX172nhA5Y5HBshW5JweqQ2W4xL4dezQTG8inJsuYcpPHHU3X5OTQ==", - "optional": true, - "dependencies": { - "readable-stream": "1.1.x", - "xregexp": "2.0.0" - }, - "engines": { - "node": ">=0.8.0" - } - }, - "node_modules/ftp/node_modules/readable-stream": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "integrity": "sha512-+MeVjFf4L44XUkhM1eYbD8fyEsxcV81pqMSR5gblfcLCHfZvbrqy4/qYHE+/R5HoBUT11WV5O08Cr1n3YXkWVQ==", - "optional": true, - "dependencies": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "node_modules/ftp/node_modules/string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha512-ev2QzSzWPYmy9GuqfIVildA4OdcGLeFZQrq5ys6RtiuF+RQQiZWr8TZNyAcuVXyQRYfEO+MsoB/1BuQVhOJuoQ==", - "optional": true - }, "node_modules/function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", @@ -2831,46 +2604,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/get-uri": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/get-uri/-/get-uri-3.0.2.tgz", - "integrity": "sha512-+5s0SJbGoyiJTZZ2JTpFPLMPSch72KEqGOTvQsBqg0RBWvwhWUSYZFAtz3TPW0GXJuLBJPts1E241iHg+VRfhg==", - "optional": true, - "dependencies": { - "@tootallnate/once": "1", - "data-uri-to-buffer": "3", - "debug": "4", - "file-uri-to-path": "2", - "fs-extra": "^8.1.0", - "ftp": "^0.3.10" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/get-uri/node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "optional": true, - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/get-uri/node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "optional": true - }, "node_modules/glob": { "version": "7.2.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", @@ -2915,7 +2648,7 @@ "version": "4.2.10", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==", - "devOptional": true + "dev": true }, "node_modules/has": { "version": "1.0.3", @@ -2983,43 +2716,6 @@ "node": ">= 0.8" } }, - "node_modules/http-proxy-agent": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-4.0.1.tgz", - "integrity": "sha512-k0zdNgqWTGA6aeIRVpvfVob4fL52dTfaehylg0Y4UvSySvOq/Y+BOyPrgpUrA7HylqvU8vIZGsRuXmspskV0Tg==", - "optional": true, - "dependencies": { - "@tootallnate/once": "1", - "agent-base": "6", - "debug": "4" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/http-proxy-agent/node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "optional": true, - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/http-proxy-agent/node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "optional": true - }, "node_modules/https-proxy-agent": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", @@ -3217,12 +2913,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==", - "optional": true - }, "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", @@ -3968,15 +3658,6 @@ "node": ">=6" } }, - "node_modules/jsonfile": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", - "integrity": "sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==", - "optional": true, - "optionalDependencies": { - "graceful-fs": "^4.1.6" - } - }, "node_modules/kareem": { "version": "2.5.1", "resolved": "https://registry.npmjs.org/kareem/-/kareem-2.5.1.tgz", @@ -4003,19 +3684,6 @@ "node": ">=6" } }, - "node_modules/levn": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", - "integrity": "sha512-0OO4y2iOHix2W6ujICbKIaEQXvFQHue65vUG3pb5EUomzPI90z9hsA1VsO/dbIIpC53J8gxM9Q4Oho0jrCM/yA==", - "optional": true, - "dependencies": { - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2" - }, - "engines": { - "node": ">= 0.8.0" - } - }, "node_modules/lines-and-columns": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", @@ -4049,7 +3717,7 @@ "version": "5.1.1", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", - "devOptional": true, + "dev": true, "dependencies": { "yallist": "^3.0.2" } @@ -4361,15 +4029,6 @@ "node": ">= 0.6" } }, - "node_modules/netmask": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/netmask/-/netmask-2.0.2.tgz", - "integrity": "sha512-dBpDMdxv9Irdq66304OLfEmQ9tbNRFnFTuZiLo+bD+r332bBmMJ8GBLXklIXXgxd3+v9+KUnZaUR5PJMa75Gsg==", - "optional": true, - "engines": { - "node": ">= 0.4.0" - } - }, "node_modules/node-addon-api": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-5.1.0.tgz", @@ -4526,23 +4185,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/optionator": { - "version": "0.8.3", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", - "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", - "optional": true, - "dependencies": { - "deep-is": "~0.1.3", - "fast-levenshtein": "~2.0.6", - "levn": "~0.3.0", - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2", - "word-wrap": "~1.2.3" - }, - "engines": { - "node": ">= 0.8.0" - } - }, "node_modules/p-limit": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", @@ -4594,69 +4236,6 @@ "node": ">=6" } }, - "node_modules/pac-proxy-agent": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/pac-proxy-agent/-/pac-proxy-agent-5.0.0.tgz", - "integrity": "sha512-CcFG3ZtnxO8McDigozwE3AqAw15zDvGH+OjXO4kzf7IkEKkQ4gxQ+3sdF50WmhQ4P/bVusXcqNE2S3XrNURwzQ==", - "optional": true, - "dependencies": { - "@tootallnate/once": "1", - "agent-base": "6", - "debug": "4", - "get-uri": "3", - "http-proxy-agent": "^4.0.1", - "https-proxy-agent": "5", - "pac-resolver": "^5.0.0", - "raw-body": "^2.2.0", - "socks-proxy-agent": "5" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/pac-proxy-agent/node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "optional": true, - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/pac-proxy-agent/node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "optional": true - }, - "node_modules/pac-resolver": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/pac-resolver/-/pac-resolver-5.0.1.tgz", - "integrity": "sha512-cy7u00ko2KVgBAjuhevqpPeHIkCIqPe1v24cydhWjmeuzaBfmUWFCZJ1iAh5TuVzVZoUzXIW7K8sMYOZ84uZ9Q==", - "optional": true, - "dependencies": { - "degenerator": "^3.0.2", - "ip": "^1.1.5", - "netmask": "^2.0.2" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/pac-resolver/node_modules/ip": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.8.tgz", - "integrity": "sha512-PuExPYUiu6qMBQb4l06ecm6T6ujzhmh+MeJcW9wa89PoAz5pvd4zPgN5WJV104mb6S2T1AwNIAaB70JNrLQWhg==", - "optional": true - }, "node_modules/parse-json": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", @@ -4759,15 +4338,6 @@ "node": ">=8" } }, - "node_modules/prelude-ls": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", - "integrity": "sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w==", - "optional": true, - "engines": { - "node": ">= 0.8.0" - } - }, "node_modules/pretty-format": { "version": "29.3.1", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.3.1.tgz", @@ -4830,54 +4400,6 @@ "node": ">= 0.10" } }, - "node_modules/proxy-agent": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/proxy-agent/-/proxy-agent-5.0.0.tgz", - "integrity": "sha512-gkH7BkvLVkSfX9Dk27W6TyNOWWZWRilRfk1XxGNWOYJ2TuedAv1yFpCaU9QSBmBe716XOTNpYNOzhysyw8xn7g==", - "optional": true, - "dependencies": { - "agent-base": "^6.0.0", - "debug": "4", - "http-proxy-agent": "^4.0.0", - "https-proxy-agent": "^5.0.0", - "lru-cache": "^5.1.1", - "pac-proxy-agent": "^5.0.0", - "proxy-from-env": "^1.0.0", - "socks-proxy-agent": "^5.0.0" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/proxy-agent/node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "optional": true, - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/proxy-agent/node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "optional": true - }, - "node_modules/proxy-from-env": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", - "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", - "optional": true - }, "node_modules/punycode": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz", @@ -4886,15 +4408,6 @@ "node": ">=6" } }, - "node_modules/q": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/q/-/q-1.5.1.tgz", - "integrity": "sha512-kV/CThkXo6xyFEZUugw/+pIOywXcDbFYgSct5cT3gqlbkBE1SJdwy6UQoZvodiWF/ckQLZyDE/Bu1M6gVu5lVw==", - "engines": { - "node": ">=0.6.0", - "teleport": ">=0.2.0" - } - }, "node_modules/qs": { "version": "6.11.0", "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", @@ -5133,18 +4646,6 @@ "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" }, - "node_modules/sha1": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/sha1/-/sha1-1.1.1.tgz", - "integrity": "sha512-dZBS6OrMjtgVkopB1Gmo4RQCDKiZsqcpAQpkV/aaj+FCrCg8r4I4qMkDPQjBgLIxlmu9k4nUbWq6ohXahOneYA==", - "dependencies": { - "charenc": ">= 0.0.1", - "crypt": ">= 0.0.1" - }, - "engines": { - "node": "*" - } - }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -5226,48 +4727,11 @@ "npm": ">= 3.0.0" } }, - "node_modules/socks-proxy-agent": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-5.0.1.tgz", - "integrity": "sha512-vZdmnjb9a2Tz6WEQVIurybSwElwPxMZaIc7PzqbJTrezcKNznv6giT7J7tZDZ1BojVaa1jvO/UiUdhDVB0ACoQ==", - "optional": true, - "dependencies": { - "agent-base": "^6.0.2", - "debug": "4", - "socks": "^2.3.3" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/socks-proxy-agent/node_modules/debug": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", - "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", - "optional": true, - "dependencies": { - "ms": "2.1.2" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/socks-proxy-agent/node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "optional": true - }, "node_modules/source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "devOptional": true, + "dev": true, "engines": { "node": ">=0.10.0" } @@ -5825,24 +5289,6 @@ "node": ">=0.10.0" } }, - "node_modules/tslib": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", - "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==", - "optional": true - }, - "node_modules/type-check": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", - "integrity": "sha512-ZCmOJdvOWDBYJlzAoFkC+Q0+bUyEOS1ltgp1MGU03fqHG+dbi9tBFU2Rd9QKiDZFAYrhPh2JUf7rZRIuHRKtOg==", - "optional": true, - "dependencies": { - "prelude-ls": "~1.1.2" - }, - "engines": { - "node": ">= 0.8.0" - } - }, "node_modules/type-detect": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", @@ -5889,15 +5335,6 @@ "node": ">=4.2.0" } }, - "node_modules/universalify": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", - "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", - "optional": true, - "engines": { - "node": ">= 4.0.0" - } - }, "node_modules/unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", @@ -5995,22 +5432,6 @@ "node": ">= 0.8" } }, - "node_modules/vm2": { - "version": "3.9.17", - "resolved": "https://registry.npmjs.org/vm2/-/vm2-3.9.17.tgz", - "integrity": "sha512-AqwtCnZ/ERcX+AVj9vUsphY56YANXxRuqMb7GsDtAr0m0PcQX3u0Aj3KWiXM0YAHy7i6JEeHrwOnwXbGYgRpAw==", - "optional": true, - "dependencies": { - "acorn": "^8.7.0", - "acorn-walk": "^8.2.0" - }, - "bin": { - "vm2": "bin/vm2" - }, - "engines": { - "node": ">=6.0" - } - }, "node_modules/walker": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/walker/-/walker-1.0.8.tgz", @@ -6063,15 +5484,6 @@ "string-width": "^1.0.2 || 2 || 3 || 4" } }, - "node_modules/word-wrap": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", - "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", - "optional": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/wrap-ansi": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", @@ -6107,15 +5519,6 @@ "node": "^12.13.0 || ^14.15.0 || >=16.0.0" } }, - "node_modules/xregexp": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/xregexp/-/xregexp-2.0.0.tgz", - "integrity": "sha512-xl/50/Cf32VsGq/1R8jJE5ajH1yMCQkpmoS10QbFZWl2Oor4H0Me64Pu2yxvsRWK3m6soJbmGfzSR7BYmDcWAA==", - "optional": true, - "engines": { - "node": "*" - } - }, "node_modules/xtend": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", @@ -6138,7 +5541,7 @@ "version": "3.1.1", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", - "devOptional": true + "dev": true }, "node_modules/yargs": { "version": "17.6.2", diff --git a/restapi/package.json b/restapi/package.json index 6afeb16..261a362 100644 --- a/restapi/package.json +++ b/restapi/package.json @@ -12,8 +12,6 @@ "bcrypt": "^5.1.0", "bcryptjs": "^2.4.3", "body-parser": "^1.20.1", - "cloudinary": "^1.35.0", - "cloudinary-client": "^0.0.1", "cors": "^2.8.5", "dotenv": "^16.0.3", "express": "^4.18.2", diff --git a/restapi/src/controllers/FriendManager.ts b/restapi/src/controllers/FriendManager.ts index 2170c1a..4743219 100644 --- a/restapi/src/controllers/FriendManager.ts +++ b/restapi/src/controllers/FriendManager.ts @@ -2,8 +2,6 @@ import { User } from "../facade"; import { FriendRequest } from "../entities/FriendRequest"; import FriendshipSchema from "../entities/FriendshipSchema"; import UserSchema from "../entities/UserSchema"; -import { UserImpl } from "../entities/User"; -import { Repository } from "../persistence/Repository"; diff --git a/restapi/src/controllers/UserManager.ts b/restapi/src/controllers/UserManager.ts index d8a74ea..45b75c5 100644 --- a/restapi/src/controllers/UserManager.ts +++ b/restapi/src/controllers/UserManager.ts @@ -1,4 +1,3 @@ -import { UserImpl } from "../entities/User"; import type { User } from "../facade"; import UserSchema from "../entities/UserSchema"; import mongoose from "mongoose"; diff --git a/restapi/src/entities/FriendRequest.ts b/restapi/src/entities/FriendRequest.ts index f6800dd..9130fcc 100644 --- a/restapi/src/entities/FriendRequest.ts +++ b/restapi/src/entities/FriendRequest.ts @@ -1,4 +1,3 @@ -import { User } from "../facade"; export { FriendRequest } class FriendRequest { sender: string; diff --git a/restapi/src/persistence/DataBase.tsx b/restapi/src/persistence/DataBase.tsx index bb44958..b7d57b0 100644 --- a/restapi/src/persistence/DataBase.tsx +++ b/restapi/src/persistence/DataBase.tsx @@ -1,9 +1,7 @@ import mongoose from 'mongoose' +require("dotenv").config(); -import User from '../entities/UserSchema' - -const uri = "mongodb+srv://admin:admin@prueba.bwoulkv.mongodb.net/?retryWrites=true&w=majority" - +const uri = process.env.DATABASE_URL; mongoose.connect(uri).then(() => { console.log("Database succesfully connected") diff --git a/restapi/src/persistence/DefaultMongo.ts b/restapi/src/persistence/DefaultMongo.ts index c74f0af..02972d8 100644 --- a/restapi/src/persistence/DefaultMongo.ts +++ b/restapi/src/persistence/DefaultMongo.ts @@ -1,4 +1,5 @@ import mongoose from "mongoose"; +require("dotenv").config(); export async function OpenConnection(uri: string, mongoose: any) { await mongoose.connect(uri).catch((e: any) => { @@ -13,13 +14,13 @@ export async function CloseConnection(mongoose: any) { } export async function getBD() { - const uri = "mongodb+srv://admin:admin@prueba.bwoulkv.mongodb.net/?retryWrites=true&w=majority"; + const uri = process.env.DATABASE_URL; const mongoose = require('mongoose'); await mongoose.set('strictQuery', true).catch((e: any) => { - throw new Error("Fallo de Juan: " + e) + throw new Error("Fallo BD: " + e) }); await mongoose.set('debug', true).catch((e: any) => { - throw new Error("Fallo de Juan: " + e) + throw new Error("Fallo BD: " + e) }); return { uri, mongoose }; } diff --git a/restapi/src/persistence/Repository.tsx b/restapi/src/persistence/Repository.tsx index 21b7284..69a9c9a 100644 --- a/restapi/src/persistence/Repository.tsx +++ b/restapi/src/persistence/Repository.tsx @@ -1,4 +1,3 @@ -import { UserImpl } from "../entities/User"; import UserSchema from "../entities/UserSchema" import type { User } from "../facade"; From 1d5061694fb5f59f27f9ed675a538e886dc79618 Mon Sep 17 00:00:00 2001 From: uo269745 Date: Sat, 29 Apr 2023 13:07:31 +0200 Subject: [PATCH 05/17] fix bug --- restapi/src/persistence/DataBase.tsx | 2 +- restapi/src/persistence/DefaultMongo.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/restapi/src/persistence/DataBase.tsx b/restapi/src/persistence/DataBase.tsx index b7d57b0..2dda4d1 100644 --- a/restapi/src/persistence/DataBase.tsx +++ b/restapi/src/persistence/DataBase.tsx @@ -3,7 +3,7 @@ require("dotenv").config(); const uri = process.env.DATABASE_URL; -mongoose.connect(uri).then(() => { +mongoose.connect(uri!).then(() => { console.log("Database succesfully connected") }).catch((err) => { console.error(err); diff --git a/restapi/src/persistence/DefaultMongo.ts b/restapi/src/persistence/DefaultMongo.ts index 02972d8..b99efec 100644 --- a/restapi/src/persistence/DefaultMongo.ts +++ b/restapi/src/persistence/DefaultMongo.ts @@ -2,7 +2,7 @@ import mongoose from "mongoose"; require("dotenv").config(); export async function OpenConnection(uri: string, mongoose: any) { - await mongoose.connect(uri).catch((e: any) => { + await mongoose.connect(uri!).catch((e: any) => { throw new Error("Error al conectar a la BD: " + e) }) } @@ -27,7 +27,7 @@ export async function getBD() { export async function findOne(schema: any, filter: any, options: any) { const { uri, mongoose } = await getBD(); - await OpenConnection(uri, mongoose); + await OpenConnection(uri!, mongoose); await schema.findOne(filter, options).catch((e: any) => { throw new Error("Fallo en el FindOne: " + e) }) From c74fd4d8f5458b8ae0630ae89280530b87237463 Mon Sep 17 00:00:00 2001 From: uo269745 Date: Sat, 29 Apr 2023 13:27:02 +0200 Subject: [PATCH 06/17] changes for deployment --- restapi/api.ts | 5 ----- restapi/server.ts | 2 -- restapi/src/persistence/DataBase.tsx | 16 +++++++++++----- restapi/src/persistence/DefaultMongo.ts | 2 ++ 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/restapi/api.ts b/restapi/api.ts index 733fabd..87e0f88 100644 --- a/restapi/api.ts +++ b/restapi/api.ts @@ -3,11 +3,6 @@ import * as fac from './src/facade'; const api: Router = express.Router() -interface User { - name: string; - email: string; -} - api.get( "/usermanager/find/username", async (req: Request, res: Response): Promise => { diff --git a/restapi/server.ts b/restapi/server.ts index 609a598..8db8b92 100644 --- a/restapi/server.ts +++ b/restapi/server.ts @@ -3,8 +3,6 @@ import cors from 'cors'; import bp from 'body-parser'; import promBundle from 'express-prom-bundle'; import api from "./api"; -import * as repo from "./src/persistence/Repository"; -import {UserImpl} from "./src/entities/User"; import dotenv from 'dotenv'; dotenv.config(); diff --git a/restapi/src/persistence/DataBase.tsx b/restapi/src/persistence/DataBase.tsx index 2dda4d1..bfb3213 100644 --- a/restapi/src/persistence/DataBase.tsx +++ b/restapi/src/persistence/DataBase.tsx @@ -2,9 +2,15 @@ import mongoose from 'mongoose' require("dotenv").config(); const uri = process.env.DATABASE_URL; +mongoose.connect(uri!); -mongoose.connect(uri!).then(() => { - console.log("Database succesfully connected") -}).catch((err) => { - console.error(err); -}); \ No newline at end of file +const database = mongoose.connection; + +database.once('open', (error: Error) => { + console.log('Database succesfully connected!'); +}); + +database.on('error', (error: Error) => { + console.log('Database connection error:', error); + process.exit(); +}) \ No newline at end of file diff --git a/restapi/src/persistence/DefaultMongo.ts b/restapi/src/persistence/DefaultMongo.ts index b99efec..dd03976 100644 --- a/restapi/src/persistence/DefaultMongo.ts +++ b/restapi/src/persistence/DefaultMongo.ts @@ -15,6 +15,8 @@ export async function CloseConnection(mongoose: any) { export async function getBD() { const uri = process.env.DATABASE_URL; + console.log("getDB") + console.log(uri) const mongoose = require('mongoose'); await mongoose.set('strictQuery', true).catch((e: any) => { throw new Error("Fallo BD: " + e) From 8e5e342c0056584740ecc587c50d01bb4e07b449 Mon Sep 17 00:00:00 2001 From: uo269745 Date: Sat, 29 Apr 2023 13:57:30 +0200 Subject: [PATCH 07/17] attempt to set .env variables --- .github/workflows/lomap_es2c.yml | 10 ++++++- restapi/Dockerfile | 10 +++++-- restapi/src/persistence/DataBase.tsx | 20 +++++++------- restapi/src/persistence/DefaultMongo.ts | 36 ------------------------- 4 files changed, 26 insertions(+), 50 deletions(-) delete mode 100644 restapi/src/persistence/DefaultMongo.ts diff --git a/.github/workflows/lomap_es2c.yml b/.github/workflows/lomap_es2c.yml index f04e1ce..7701303 100644 --- a/.github/workflows/lomap_es2c.yml +++ b/.github/workflows/lomap_es2c.yml @@ -34,7 +34,13 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: - node-version: 18 + node-version: 18´ + - name: Create env + run: | + cd restapi + touch .env + echo DATABASE_URL=${{ secrets.DATABASE_URL }} >> .env + cat .env - run: npm --prefix webapp install - run: npm --prefix restapi install - run: npm --prefix webapp run build @@ -58,6 +64,8 @@ jobs: buildargs: API_URI docker-push-restapi: name: Push restapi Docker Image to GitHub Packages + env: + DATABASE_USER: ${{ secrets.DATABASE_URL }} runs-on: ubuntu-latest env: DATABASE_URL: ${{ secrets.DATABASE_URL }} diff --git a/restapi/Dockerfile b/restapi/Dockerfile index 5198114..eaad357 100644 --- a/restapi/Dockerfile +++ b/restapi/Dockerfile @@ -5,7 +5,13 @@ WORKDIR /app #Install the dependencies RUN npm install -ARG DATABASE_URL="DATABASE_URL" -ENV DATABASE_URL=$DATABASE_URL +ARG DATABASE_USER="DATABASE_USER" +ENV DATABASE_USER=$DATABASE_USER + +ARG DATABASE_PASSWORD="DATABASE_PASSWORD" +ENV DATABASE_PASSWORD=$DATABASE_PASSWORD + +ARG DATABASE_NAME="DATABASE_NAME" +ENV DATABASE_NAME=$DATABASE_NAME CMD [ "npm", "start" ] diff --git a/restapi/src/persistence/DataBase.tsx b/restapi/src/persistence/DataBase.tsx index bfb3213..b611c87 100644 --- a/restapi/src/persistence/DataBase.tsx +++ b/restapi/src/persistence/DataBase.tsx @@ -1,16 +1,14 @@ -import mongoose from 'mongoose' +var mongoose = require('mongoose'); require("dotenv").config(); const uri = process.env.DATABASE_URL; -mongoose.connect(uri!); -const database = mongoose.connection; - -database.once('open', (error: Error) => { +mongoose.connect(uri, + { + useNewUrlParser: true, + useUnifiedTopology: true + }).then(() =>{ console.log('Database succesfully connected!'); -}); - -database.on('error', (error: Error) => { - console.log('Database connection error:', error); - process.exit(); -}) \ No newline at end of file +}).catch((error: any) => { + console.log('Error connecting to database:', error); +}); \ No newline at end of file diff --git a/restapi/src/persistence/DefaultMongo.ts b/restapi/src/persistence/DefaultMongo.ts deleted file mode 100644 index dd03976..0000000 --- a/restapi/src/persistence/DefaultMongo.ts +++ /dev/null @@ -1,36 +0,0 @@ -import mongoose from "mongoose"; -require("dotenv").config(); - -export async function OpenConnection(uri: string, mongoose: any) { - await mongoose.connect(uri!).catch((e: any) => { - throw new Error("Error al conectar a la BD: " + e) - }) -} - -export async function CloseConnection(mongoose: any) { - await mongoose.connection.close().catch((e: any) => { - throw new Error("Error al cerrar BD: " + e) - }) -} - -export async function getBD() { - const uri = process.env.DATABASE_URL; - console.log("getDB") - console.log(uri) - const mongoose = require('mongoose'); - await mongoose.set('strictQuery', true).catch((e: any) => { - throw new Error("Fallo BD: " + e) - }); - await mongoose.set('debug', true).catch((e: any) => { - throw new Error("Fallo BD: " + e) - }); - return { uri, mongoose }; -} - -export async function findOne(schema: any, filter: any, options: any) { - const { uri, mongoose } = await getBD(); - await OpenConnection(uri!, mongoose); - await schema.findOne(filter, options).catch((e: any) => { - throw new Error("Fallo en el FindOne: " + e) - }) -} \ No newline at end of file From 21061f1e1c378a1904b25222f061311074d1c642 Mon Sep 17 00:00:00 2001 From: uo269745 Date: Sat, 29 Apr 2023 14:02:07 +0200 Subject: [PATCH 08/17] fix error? --- .github/workflows/lomap_es2c.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/lomap_es2c.yml b/.github/workflows/lomap_es2c.yml index 7701303..04c4f0a 100644 --- a/.github/workflows/lomap_es2c.yml +++ b/.github/workflows/lomap_es2c.yml @@ -36,11 +36,11 @@ jobs: with: node-version: 18´ - name: Create env - run: | - cd restapi - touch .env - echo DATABASE_URL=${{ secrets.DATABASE_URL }} >> .env - cat .env + run: | + cd restapi + touch .env + echo DATABASE_URL=${{ secrets.DATABASE_URL }} >> .env + cat .env - run: npm --prefix webapp install - run: npm --prefix restapi install - run: npm --prefix webapp run build From 28e38e27ebc311d7e434080e6d0b3d70c4d085aa Mon Sep 17 00:00:00 2001 From: uo269745 Date: Sat, 29 Apr 2023 14:03:13 +0200 Subject: [PATCH 09/17] ... --- .github/workflows/lomap_es2c.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lomap_es2c.yml b/.github/workflows/lomap_es2c.yml index 04c4f0a..2818536 100644 --- a/.github/workflows/lomap_es2c.yml +++ b/.github/workflows/lomap_es2c.yml @@ -36,7 +36,7 @@ jobs: with: node-version: 18´ - name: Create env - run: | + run: | cd restapi touch .env echo DATABASE_URL=${{ secrets.DATABASE_URL }} >> .env From a86ce71ef82a0006f6fcb645997162de347ae4fd Mon Sep 17 00:00:00 2001 From: uo269745 Date: Sat, 29 Apr 2023 14:06:07 +0200 Subject: [PATCH 10/17] fixing errors .yml --- .github/workflows/lomap_es2c.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/lomap_es2c.yml b/.github/workflows/lomap_es2c.yml index 2818536..7a63b52 100644 --- a/.github/workflows/lomap_es2c.yml +++ b/.github/workflows/lomap_es2c.yml @@ -37,10 +37,10 @@ jobs: node-version: 18´ - name: Create env run: | - cd restapi - touch .env - echo DATABASE_URL=${{ secrets.DATABASE_URL }} >> .env - cat .env + cd restapi + touch .env + echo DATABASE_URL=${{ secrets.DATABASE_URL }} >> .env + cat .env - run: npm --prefix webapp install - run: npm --prefix restapi install - run: npm --prefix webapp run build @@ -67,8 +67,6 @@ jobs: env: DATABASE_USER: ${{ secrets.DATABASE_URL }} runs-on: ubuntu-latest - env: - DATABASE_URL: ${{ secrets.DATABASE_URL }} needs: [e2e-tests] steps: - uses: actions/checkout@v3 From 62fd57549af03562ab5110a0c18118df9fdd4e1f Mon Sep 17 00:00:00 2001 From: Abel Busto Dopazo Date: Sat, 29 Apr 2023 14:39:01 +0200 Subject: [PATCH 11/17] Delete DefaultMongo.ts --- restapi/src/persistence/DefaultMongo.ts | 34 ------------------------- 1 file changed, 34 deletions(-) delete mode 100644 restapi/src/persistence/DefaultMongo.ts diff --git a/restapi/src/persistence/DefaultMongo.ts b/restapi/src/persistence/DefaultMongo.ts deleted file mode 100644 index 02972d8..0000000 --- a/restapi/src/persistence/DefaultMongo.ts +++ /dev/null @@ -1,34 +0,0 @@ -import mongoose from "mongoose"; -require("dotenv").config(); - -export async function OpenConnection(uri: string, mongoose: any) { - await mongoose.connect(uri).catch((e: any) => { - throw new Error("Error al conectar a la BD: " + e) - }) -} - -export async function CloseConnection(mongoose: any) { - await mongoose.connection.close().catch((e: any) => { - throw new Error("Error al cerrar BD: " + e) - }) -} - -export async function getBD() { - const uri = process.env.DATABASE_URL; - const mongoose = require('mongoose'); - await mongoose.set('strictQuery', true).catch((e: any) => { - throw new Error("Fallo BD: " + e) - }); - await mongoose.set('debug', true).catch((e: any) => { - throw new Error("Fallo BD: " + e) - }); - return { uri, mongoose }; -} - -export async function findOne(schema: any, filter: any, options: any) { - const { uri, mongoose } = await getBD(); - await OpenConnection(uri, mongoose); - await schema.findOne(filter, options).catch((e: any) => { - throw new Error("Fallo en el FindOne: " + e) - }) -} \ No newline at end of file From 722a041e9d40d664f3b13dd3a1a969e63db0a3b8 Mon Sep 17 00:00:00 2001 From: uo269745 Date: Sat, 29 Apr 2023 15:25:04 +0200 Subject: [PATCH 12/17] fix restapi test for deploy --- restapi/src/controllers/SessionManager.ts | 4 +++- restapi/src/persistence/DataBase.tsx | 10 ++-------- restapi/tests/FriendsManager.test.ts | 17 ++++++++++------- restapi/tests/SessionManager.test.ts | 12 +++++++++--- restapi/tests/UserManager.test.ts | 12 +++++++++--- restapi/tests/api.test.ts | 10 ++++++++-- 6 files changed, 41 insertions(+), 24 deletions(-) diff --git a/restapi/src/controllers/SessionManager.ts b/restapi/src/controllers/SessionManager.ts index 5011bd6..f0d1b34 100644 --- a/restapi/src/controllers/SessionManager.ts +++ b/restapi/src/controllers/SessionManager.ts @@ -5,6 +5,7 @@ import * as repo from "../persistence/Repository" import mongoose from "mongoose"; const sessionStorage = require('sessionstorage-for-nodejs') const bcrypt = require("bcryptjs"); +require("dotenv").config(); class UserSesionManager implements SesionManager { @@ -17,7 +18,8 @@ class UserSesionManager implements SesionManager { async registrarse(usuario: User): Promise { let usuarioEncontrado; - try { + try + { usuarioEncontrado = await repo.Repository.findOne(usuario) } catch (e: any) { throw new Error("Ha sucedido un error al crear la cuenta, vuelva a intentarlo más tarde."); diff --git a/restapi/src/persistence/DataBase.tsx b/restapi/src/persistence/DataBase.tsx index b611c87..8e33e9c 100644 --- a/restapi/src/persistence/DataBase.tsx +++ b/restapi/src/persistence/DataBase.tsx @@ -1,14 +1,8 @@ var mongoose = require('mongoose'); require("dotenv").config(); -const uri = process.env.DATABASE_URL; +const uri:string = process.env.DATABASE_URL; -mongoose.connect(uri, - { - useNewUrlParser: true, - useUnifiedTopology: true - }).then(() =>{ +mongoose.connect(uri!).then(() =>{ console.log('Database succesfully connected!'); -}).catch((error: any) => { - console.log('Error connecting to database:', error); }); \ No newline at end of file diff --git a/restapi/tests/FriendsManager.test.ts b/restapi/tests/FriendsManager.test.ts index a46efe0..427c060 100644 --- a/restapi/tests/FriendsManager.test.ts +++ b/restapi/tests/FriendsManager.test.ts @@ -1,21 +1,24 @@ import { UserManager, UserManagerImpl } from '../src/controllers/UserManager'; import { UserImpl } from '../src/entities/User'; -import User from "../src/entities/UserSchema"; -import { SesionManager } from "../src/facade"; -import { UserSesionManager } from "../src/controllers/SessionManager"; import { FriendManager, FriendManagerImpl } from "../src/controllers/FriendManager"; import { FriendRequest } from "../src/entities/FriendRequest"; -import mongoose from "mongoose"; -import { ftruncate } from "fs"; -import { response } from "express"; +var mongoose = require('mongoose'); describe('FriendsManager', () => { let userManager: UserManager; let friendManager: FriendManager; + beforeAll(async () => { + await mongoose.connect('mongodb+srv://admin:admin@prueba.bwoulkv.mongodb.net/?retryWrites=true&w=majority', + { + useNewUrlParser: true, + useUnifiedTopology: true + }); + }) + beforeEach(() => { + // Inicializar la instancia de UserManager y SessionManager antes de cada prueba - require("../src/persistence/DataBase") userManager = new UserManagerImpl(); friendManager = new FriendManagerImpl(); }); diff --git a/restapi/tests/SessionManager.test.ts b/restapi/tests/SessionManager.test.ts index e1f4de2..1852a3a 100644 --- a/restapi/tests/SessionManager.test.ts +++ b/restapi/tests/SessionManager.test.ts @@ -1,17 +1,23 @@ import { UserManager, UserManagerImpl } from '../src/controllers/UserManager'; import { UserImpl } from '../src/entities/User'; -import User from "../src/entities/UserSchema"; import { SesionManager } from "../src/facade"; import { UserSesionManager } from "../src/controllers/SessionManager"; -import mongoose from "mongoose"; +var mongoose = require('mongoose'); describe('SessionManager', () => { let userManager: UserManager; let sessionManager: SesionManager; + beforeAll(async () => { + await mongoose.connect('mongodb+srv://admin:admin@prueba.bwoulkv.mongodb.net/?retryWrites=true&w=majority', + { + useNewUrlParser: true, + useUnifiedTopology: true + }); + }) + beforeEach(() => { // Inicializar la instancia de UserManager y SessionManager antes de cada prueba - require("../src/persistence/DataBase") userManager = new UserManagerImpl(); sessionManager = new UserSesionManager(); }); diff --git a/restapi/tests/UserManager.test.ts b/restapi/tests/UserManager.test.ts index 6deeab5..79605d0 100644 --- a/restapi/tests/UserManager.test.ts +++ b/restapi/tests/UserManager.test.ts @@ -1,14 +1,20 @@ import { UserManager, UserManagerImpl } from '../src/controllers/UserManager'; import { UserImpl } from '../src/entities/User'; -import User from "../src/entities/UserSchema"; -import mongoose from "mongoose"; +var mongoose = require('mongoose'); describe('UserManager', () => { let userManager: UserManager; + beforeAll(async () => { + await mongoose.connect('mongodb+srv://admin:admin@prueba.bwoulkv.mongodb.net/?retryWrites=true&w=majority', + { + useNewUrlParser: true, + useUnifiedTopology: true + }); + }) + beforeEach(() => { // Inicializar la instancia de UserManager antes de cada prueba - require("../src/persistence/DataBase") userManager = new UserManagerImpl(); }); diff --git a/restapi/tests/api.test.ts b/restapi/tests/api.test.ts index 4767361..0662008 100644 --- a/restapi/tests/api.test.ts +++ b/restapi/tests/api.test.ts @@ -4,19 +4,25 @@ import promBundle from "express-prom-bundle"; import { Server } from "http"; import request, { Response } from "supertest"; import apiUser from "../api"; -import mongoose from "mongoose"; import { UserImpl } from "../src/entities/User"; import { FriendRequest } from "../src/entities/FriendRequest"; import { FriendManagerImpl } from "../src/controllers/FriendManager"; import FriendshipSchema from "../src/entities/FriendshipSchema"; import UserSchema from "../src/entities/UserSchema"; +var mongoose = require('mongoose'); var server: Server; const app: Application = express(); beforeAll(async () => { - require("../src/persistence/DataBase") + + await mongoose.connect('mongodb+srv://admin:admin@prueba.bwoulkv.mongodb.net/?retryWrites=true&w=majority', + { + useNewUrlParser: true, + useUnifiedTopology: true + }); + const metricsMiddleware: RequestHandler = promBundle({ includeMethod: true }); app.use(metricsMiddleware); From ac63bbd45a9e3fe6313c0f2b8b45d96dda0684ad Mon Sep 17 00:00:00 2001 From: uo269745 Date: Sat, 29 Apr 2023 15:36:55 +0200 Subject: [PATCH 13/17] fix error .yml --- .github/workflows/lomap_es2c.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lomap_es2c.yml b/.github/workflows/lomap_es2c.yml index 7a63b52..e83b842 100644 --- a/.github/workflows/lomap_es2c.yml +++ b/.github/workflows/lomap_es2c.yml @@ -34,7 +34,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: - node-version: 18´ + node-version: 18 - name: Create env run: | cd restapi From 23eeec3c2a1c4415199e0a0cc09c6da6205996b4 Mon Sep 17 00:00:00 2001 From: uo269745 Date: Sat, 29 Apr 2023 15:41:24 +0200 Subject: [PATCH 14/17] hot fix --- restapi/Dockerfile | 10 ++-------- restapi/src/persistence/DataBase.tsx | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/restapi/Dockerfile b/restapi/Dockerfile index eaad357..db6f539 100644 --- a/restapi/Dockerfile +++ b/restapi/Dockerfile @@ -5,13 +5,7 @@ WORKDIR /app #Install the dependencies RUN npm install -ARG DATABASE_USER="DATABASE_USER" -ENV DATABASE_USER=$DATABASE_USER - -ARG DATABASE_PASSWORD="DATABASE_PASSWORD" -ENV DATABASE_PASSWORD=$DATABASE_PASSWORD - -ARG DATABASE_NAME="DATABASE_NAME" -ENV DATABASE_NAME=$DATABASE_NAME +ARG DATABASE_URL="DATABASE_USER" +ENV DATABASE_URL=$DATABASE_URL CMD [ "npm", "start" ] diff --git a/restapi/src/persistence/DataBase.tsx b/restapi/src/persistence/DataBase.tsx index 8e33e9c..7e3cc41 100644 --- a/restapi/src/persistence/DataBase.tsx +++ b/restapi/src/persistence/DataBase.tsx @@ -3,6 +3,6 @@ require("dotenv").config(); const uri:string = process.env.DATABASE_URL; -mongoose.connect(uri!).then(() =>{ +mongoose.connect(uri).then(() =>{ console.log('Database succesfully connected!'); }); \ No newline at end of file From 109745ed555cc21d3f3b786356fbea7207c87727 Mon Sep 17 00:00:00 2001 From: uo269745 Date: Sat, 29 Apr 2023 16:10:23 +0200 Subject: [PATCH 15/17] ... --- .github/workflows/lomap_es2c.yml | 60 ++++++++++++------------- webapp/e2e/steps/login-form.steps.ts | 5 ++- webapp/e2e/steps/register-form.steps.ts | 5 ++- 3 files changed, 36 insertions(+), 34 deletions(-) diff --git a/.github/workflows/lomap_es2c.yml b/.github/workflows/lomap_es2c.yml index e83b842..b3b5705 100644 --- a/.github/workflows/lomap_es2c.yml +++ b/.github/workflows/lomap_es2c.yml @@ -17,7 +17,7 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: - node-version: 18 + node-version: 18 - run: npm --prefix webapp ci - run: npm --prefix restapi ci - run: npm --prefix webapp test --coverage --watchAll @@ -25,8 +25,8 @@ jobs: - name: Analyze with SonarCloud uses: sonarsource/sonarcloud-github-action@master env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} e2e-tests: needs: [unit-tests] runs-on: ubuntu-latest @@ -34,13 +34,13 @@ jobs: - uses: actions/checkout@v3 - uses: actions/setup-node@v3 with: - node-version: 18 + node-version: 18 - name: Create env run: | - cd restapi - touch .env - echo DATABASE_URL=${{ secrets.DATABASE_URL }} >> .env - cat .env + cd restapi + touch .env + echo DATABASE_URL=${{ secrets.DATABASE_URL }} >> .env + cat .env - run: npm --prefix webapp install - run: npm --prefix restapi install - run: npm --prefix webapp run build @@ -54,14 +54,14 @@ jobs: - name: Publish to Registry uses: elgohr/Publish-Docker-Github-Action@v5 env: - API_URI: http://${{ secrets.DEPLOY_HOST }}:5000/api + API_URI: http://${{ secrets.DEPLOY_HOST }}:5000/api with: - name: arquisoft/lomap_es2c/webapp - username: ${{ github.actor }} - password: ${{ secrets.DOCKER_PUSH_TOKEN }} - registry: ghcr.io - workdir: webapp - buildargs: API_URI + name: arquisoft/lomap_es2c/webapp + username: ${{ github.actor }} + password: ${{ secrets.DOCKER_PUSH_TOKEN }} + registry: ghcr.io + workdir: webapp + buildargs: API_URI docker-push-restapi: name: Push restapi Docker Image to GitHub Packages env: @@ -73,12 +73,12 @@ jobs: - name: Publish to Registry uses: elgohr/Publish-Docker-Github-Action@v5 with: - name: arquisoft/lomap_es2c/restapi - username: ${{ github.actor }} - password: ${{ secrets.DOCKER_PUSH_TOKEN }} - registry: ghcr.io - workdir: restapi - buildargs: DATABASE_URL + name: arquisoft/lomap_es2c/restapi + username: ${{ github.actor }} + password: ${{ secrets.DOCKER_PUSH_TOKEN }} + registry: ghcr.io + workdir: restapi + buildargs: DATABASE_URL deploy: name: Deploy over SSH runs-on: ubuntu-latest @@ -87,12 +87,12 @@ jobs: - name: Deploy over SSH uses: fifsky/ssh-action@master with: - host: ${{ secrets.DEPLOY_HOST }} - user: ${{ secrets.DEPLOY_USER }} - key: ${{ secrets.DEPLOY_KEY }} - command: | - wget https://raw.githubusercontent.com/arquisoft/lomap_es2c/master/docker-compose-deploy.yml -O docker-compose.yml - docker-compose stop - docker-compose rm -f - docker-compose pull - docker-compose up -d + host: ${{ secrets.DEPLOY_HOST }} + user: ${{ secrets.DEPLOY_USER }} + key: ${{ secrets.DEPLOY_KEY }} + command: | + wget https://raw.githubusercontent.com/arquisoft/lomap_es2c/master/docker-compose-deploy.yml -O docker-compose.yml + docker-compose stop + docker-compose rm -f + docker-compose pull + docker-compose up -d diff --git a/webapp/e2e/steps/login-form.steps.ts b/webapp/e2e/steps/login-form.steps.ts index 48e6cd4..a374ca9 100644 --- a/webapp/e2e/steps/login-form.steps.ts +++ b/webapp/e2e/steps/login-form.steps.ts @@ -2,6 +2,7 @@ import { defineFeature, loadFeature } from 'jest-cucumber'; import puppeteer from "puppeteer"; const feature = loadFeature('./e2e/features/login-form.feature'); +const apiEndPoint= process.env.REACT_APP_URI|| 'http://localhost:3000' let page: puppeteer.Page; let browser: puppeteer.Browser; @@ -15,7 +16,7 @@ defineFeature(feature, test => { page = await browser.newPage(); await page - .goto("http://localhost:3000/", { + .goto(apiEndPoint, { waitUntil: "networkidle0", }) .catch(() => {}); @@ -61,7 +62,7 @@ defineFeature(feature, test => { when('I fill the data in the form and press submit', async () => { await page - .goto("http://localhost:3000/", { + .goto(apiEndPoint, { waitUntil: "networkidle0", }) .catch(() => {}); diff --git a/webapp/e2e/steps/register-form.steps.ts b/webapp/e2e/steps/register-form.steps.ts index 28f0030..5539feb 100644 --- a/webapp/e2e/steps/register-form.steps.ts +++ b/webapp/e2e/steps/register-form.steps.ts @@ -2,6 +2,7 @@ import { defineFeature, loadFeature } from 'jest-cucumber'; import puppeteer from "puppeteer"; const feature = loadFeature('./e2e/features/register-form.feature'); +const apiEndPoint= process.env.REACT_APP_URI|| 'http://localhost:3000' let page: puppeteer.Page; let browser: puppeteer.Browser; @@ -15,7 +16,7 @@ defineFeature(feature, test => { page = await browser.newPage(); await page - .goto("http://localhost:3000", { + .goto(apiEndPoint, { waitUntil: "networkidle0", }) .catch(() => {}); @@ -34,7 +35,7 @@ defineFeature(feature, test => { when('I fill the data in the form and press submit', async () => { await page - .goto("http://localhost:3000", { + .goto(apiEndPoint, { waitUntil: "networkidle0", }) .catch(() => {}); From 51a8e27e9af27e90bf29e3f868d648877a3c6fba Mon Sep 17 00:00:00 2001 From: uo269745 Date: Sat, 29 Apr 2023 16:20:55 +0200 Subject: [PATCH 16/17] ... --- restapi/Dockerfile | 2 +- restapi/server.ts | 5 ++++- restapi/src/persistence/DataBase.tsx | 8 -------- 3 files changed, 5 insertions(+), 10 deletions(-) delete mode 100644 restapi/src/persistence/DataBase.tsx diff --git a/restapi/Dockerfile b/restapi/Dockerfile index db6f539..5198114 100644 --- a/restapi/Dockerfile +++ b/restapi/Dockerfile @@ -5,7 +5,7 @@ WORKDIR /app #Install the dependencies RUN npm install -ARG DATABASE_URL="DATABASE_USER" +ARG DATABASE_URL="DATABASE_URL" ENV DATABASE_URL=$DATABASE_URL CMD [ "npm", "start" ] diff --git a/restapi/server.ts b/restapi/server.ts index 8db8b92..cb2b212 100644 --- a/restapi/server.ts +++ b/restapi/server.ts @@ -5,6 +5,7 @@ import promBundle from 'express-prom-bundle'; import api from "./api"; import dotenv from 'dotenv'; dotenv.config(); +const mongoose = require('mongoose'); const app: Application = express(); @@ -13,7 +14,9 @@ const port: number = 5000; const metricsMiddleware: RequestHandler = promBundle({ includeMethod: true }); app.use(metricsMiddleware); -require('./src/persistence/DataBase') +mongoose.connect(process.env.DATABASE_URL).then(() =>{ + console.log('Database succesfully connected!'); +}); app.use(cors()); app.use(bp.json()); diff --git a/restapi/src/persistence/DataBase.tsx b/restapi/src/persistence/DataBase.tsx deleted file mode 100644 index 7e3cc41..0000000 --- a/restapi/src/persistence/DataBase.tsx +++ /dev/null @@ -1,8 +0,0 @@ -var mongoose = require('mongoose'); -require("dotenv").config(); - -const uri:string = process.env.DATABASE_URL; - -mongoose.connect(uri).then(() =>{ - console.log('Database succesfully connected!'); -}); \ No newline at end of file From b6329f545f211c09f79551dcae4ea1706eb3887e Mon Sep 17 00:00:00 2001 From: uo269745 Date: Sat, 29 Apr 2023 16:47:36 +0200 Subject: [PATCH 17/17] . --- restapi/server.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/restapi/server.ts b/restapi/server.ts index cb2b212..94e4eac 100644 --- a/restapi/server.ts +++ b/restapi/server.ts @@ -14,7 +14,11 @@ const port: number = 5000; const metricsMiddleware: RequestHandler = promBundle({ includeMethod: true }); app.use(metricsMiddleware); -mongoose.connect(process.env.DATABASE_URL).then(() =>{ +mongoose.connect('mongodb+srv://admin:admin@prueba.bwoulkv.mongodb.net/?retryWrites=true&w=majority', + { + useNewUrlParser: true, + useUnifiedTopology: true + }).then(() =>{ console.log('Database succesfully connected!'); });