From e19addfa64a729e314cb86006a6a146897a1fba7 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Sat, 17 Aug 2024 13:22:40 +0000 Subject: [PATCH 1/4] chore(release): release 1.3.1 --- CHANGELOG.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c3f2d96..0f4e96d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [1.3.1](https://github.com/montasim/node-express-boilerplate/compare/v1.3.0...v1.3.1) (2024-08-17) + +### Code Refactoring + +- sync with remote ([dfa9b76](https://github.com/montasim/node-express-boilerplate/commit/dfa9b7683f99cbfc9cbec78a2990f488fc05acb9)) + ## [1.3.0](https://github.com/montasim/node-express-boilerplate/compare/v1.2.0...v1.3.0) (2024-08-17) ### Features diff --git a/package.json b/package.json index 1ac6a21..114308b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-express-boilerplate", - "version": "1.3.0", + "version": "1.3.1", "description": "", "private": true, "main": "server.js", From 52ed4744b84adb56fec0c0937a15b00f7db88bb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EF=BC=AD=E2=99=A2=EF=BC=AE=EF=BC=B4=CE=9B=EF=BC=B3?= =?UTF-8?q?=EF=BC=A9=EF=BC=AD?= Date: Sat, 17 Aug 2024 20:32:36 +0600 Subject: [PATCH 2/4] feat: add performance benchmark action --- .github/workflows/performance-benchmark.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/workflows/performance-benchmark.yml diff --git a/.github/workflows/performance-benchmark.yml b/.github/workflows/performance-benchmark.yml new file mode 100644 index 0000000..110d90b --- /dev/null +++ b/.github/workflows/performance-benchmark.yml @@ -0,0 +1,19 @@ +name: Performance Benchmark + +on: [push, pull_request] + +jobs: + benchmark: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Run benchmarks + run: ./run_benchmarks.sh + + - name: Upload results + uses: actions/upload-artifact@v2 + with: + name: benchmark-results + path: ./benchmark_results.csv From fbbdfc8bb36c7c04f863a54fbaf80e648add3b66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EF=BC=AD=E2=99=A2=EF=BC=AE=EF=BC=B4=CE=9B=EF=BC=B3?= =?UTF-8?q?=EF=BC=A9=EF=BC=AD?= Date: Sat, 17 Aug 2024 21:55:01 +0600 Subject: [PATCH 3/4] refactor: remove performance benchmark action --- .github/workflows/performance-benchmark.yml | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 .github/workflows/performance-benchmark.yml diff --git a/.github/workflows/performance-benchmark.yml b/.github/workflows/performance-benchmark.yml deleted file mode 100644 index 110d90b..0000000 --- a/.github/workflows/performance-benchmark.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Performance Benchmark - -on: [push, pull_request] - -jobs: - benchmark: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Run benchmarks - run: ./run_benchmarks.sh - - - name: Upload results - uses: actions/upload-artifact@v2 - with: - name: benchmark-results - path: ./benchmark_results.csv From bbb4f4d931269ed8ff8ffad6a816414c68bcef72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EF=BC=AD=E2=99=A2=EF=BC=AE=EF=BC=B4=CE=9B=EF=BC=B3?= =?UTF-8?q?=EF=BC=A9=EF=BC=AD?= Date: Fri, 30 Aug 2024 16:06:45 +0600 Subject: [PATCH 4/4] feat: add logger --- src/shared/validateWithSchema.js | 9 ++++++--- src/utilities/errorResponse.js | 20 +++++++++++++------- src/utilities/sendResponse.js | 20 +++++++++++++------- 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/src/shared/validateWithSchema.js b/src/shared/validateWithSchema.js index 2dd0b79..75128a8 100644 --- a/src/shared/validateWithSchema.js +++ b/src/shared/validateWithSchema.js @@ -10,6 +10,7 @@ import asyncErrorHandlerService from '../service/asyncErrorHandler.service.js'; import customValidationMessage from './customValidationMessage.js'; import httpStatus from '../constant/httpStatus.constants.js'; +import loggerService from '../service/logger.service.js'; /** * @function validateWithSchema @@ -36,14 +37,16 @@ const validateWithSchema = (schemas, options = {}) => { ); if (error) { + const message = error.details + .map((detail) => detail.message) + .join(', '); + loggerService.debug(message); const errorData = { route: req.originalUrl, timeStamp: new Date(), success: false, data: {}, - message: error.details - .map((detail) => detail.message) - .join(', '), + message, status: httpStatus.BAD_REQUEST, }; diff --git a/src/utilities/errorResponse.js b/src/utilities/errorResponse.js index 636c26e..3fe452a 100644 --- a/src/utilities/errorResponse.js +++ b/src/utilities/errorResponse.js @@ -8,6 +8,7 @@ */ import httpStatus from '../constant/httpStatus.constants.js'; +import loggerService from '../service/logger.service.js'; /** * errorResponse - A function that generates a standardized error response object. @@ -20,12 +21,17 @@ import httpStatus from '../constant/httpStatus.constants.js'; * @returns {Object} - An object representing the error response, including the timestamp, * success flag, data payload, error message, and status code. */ -const errorResponse = (message, status = httpStatus.BAD_REQUEST) => ({ - timeStamp: new Date(), - success: false, - data: {}, - message, - status, -}); +const errorResponse = (message, status = httpStatus.BAD_REQUEST) => { + toString(status).startsWith('5') + ? loggerService.error(message) + : loggerService.debug(message); + return { + timeStamp: new Date(), + success: false, + data: {}, + message, + status, + }; +}; export default errorResponse; diff --git a/src/utilities/sendResponse.js b/src/utilities/sendResponse.js index 55d3734..49d1c09 100644 --- a/src/utilities/sendResponse.js +++ b/src/utilities/sendResponse.js @@ -8,6 +8,7 @@ */ import httpStatus from '../constant/httpStatus.constants.js'; +import loggerService from '../service/logger.service.js'; /** * sendResponse - A function that creates a standardized response object for successful @@ -21,12 +22,17 @@ import httpStatus from '../constant/httpStatus.constants.js'; * @returns {Object} - An object representing the response, including the timestamp, * success flag, data payload, message, and status code. */ -const sendResponse = (data, message, status = httpStatus.OK) => ({ - timeStamp: new Date(), - success: true, - data, - message, - status, -}); +const sendResponse = (data, message, status = httpStatus.OK) => { + toString(status).startsWith('5') + ? loggerService.error(message) + : loggerService.debug(message); + return { + timeStamp: new Date(), + success: true, + data, + message, + status, + }; +}; export default sendResponse;