From 6ad6c844b45116344297ad3f1026d0a8d1a54c48 Mon Sep 17 00:00:00 2001 From: fran hernandez Date: Fri, 3 May 2024 09:45:11 +0200 Subject: [PATCH 1/2] Fix problems with coverage --- .github/workflows/build.yml | 2 +- package.json | 1 + sonar-project.properties | 2 +- src/routers/users.routers/user.router.ts | 16 +++++++++++----- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index eb685fc..45de8b2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,7 +20,7 @@ jobs: - name: Install module run: npm ci - name: Testing coverage - run: npm run test:dev + run: npm run test:prod - name: SonarCloud Scan uses: SonarSource/sonarcloud-github-action@master env: diff --git a/package.json b/package.json index ce7700e..11e7b06 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "dev": "tsc -w", "test": "jest", "test:dev": "cross-env NODE_ENV=test jest --watchAll --coverage", + "test:prod": "jest --passWithNoTests --coverage", "lint": "eslint . --ext .ts", "prepare": "husky" }, diff --git a/sonar-project.properties b/sonar-project.properties index 91081c3..dba303f 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -3,7 +3,7 @@ sonar.projectKey=Francisco-Hernandez-Final-Project-202402-Mad-Back sonar.organization=isdi-coders-2023 # This is the name and version displayed in the SonarCloud UI. -#sonar.projectName=Danielle-Quintiliani-Final-Project-202402-Mad-Back +#sonar.projectName=Francisco-Hernandez-Final-Project-202402-Mad-Back #sonar.projectVersion=1.0 diff --git a/src/routers/users.routers/user.router.ts b/src/routers/users.routers/user.router.ts index 33905ed..51d89a9 100644 --- a/src/routers/users.routers/user.router.ts +++ b/src/routers/users.routers/user.router.ts @@ -22,10 +22,16 @@ export class UserRouter { this.router.get('/:id', userController.getById.bind(userController)); - this.router.post('/', userController.create.bind(userController)); - - this.router.patch('/:id', userController.update.bind(userController)); - - this.router.delete('/:id', userController.delete.bind(userController)); + this.router.patch( + '/:id', + authMiddleware.authentication.bind(authMiddleware), + userController.update.bind(userController) + ); + + this.router.delete( + '/:id', + authMiddleware.authentication.bind(authMiddleware), + userController.delete.bind(userController) + ); } } From 3e8e6d3df28e8ad16608752d326837f68f0b43d8 Mon Sep 17 00:00:00 2001 From: fran hernandez Date: Fri, 3 May 2024 09:55:38 +0200 Subject: [PATCH 2/2] Fix problems with sonar --- sonar-project.properties | 3 +-- src/services/auth.services/auth.services.ts | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/sonar-project.properties b/sonar-project.properties index dba303f..89befa1 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,5 +1,4 @@ -sonar.projectKey=Francisco-Hernandez-Final-Project-202402-Mad-Back - +sonar.projectKey=isdi-coders-2023_Francisco-Hernandez-Final-Project-202402-Mad-Back sonar.organization=isdi-coders-2023 # This is the name and version displayed in the SonarCloud UI. diff --git a/src/services/auth.services/auth.services.ts b/src/services/auth.services/auth.services.ts index df5c4e9..b35193f 100644 --- a/src/services/auth.services/auth.services.ts +++ b/src/services/auth.services/auth.services.ts @@ -10,7 +10,7 @@ export type Payload = { } & jwt.JwtPayload; export class Auth { - static secret = process.env.SECRES_JWT; + static secret = process.env.SECRET_JWT; static async hash(value: string) { return hash(value, 10);