From 1aaa0bd4a06b759cf847f1af9b88efdbe02962ca Mon Sep 17 00:00:00 2001 From: OfrenDialsa Date: Fri, 12 Dec 2025 23:11:12 +0700 Subject: [PATCH 1/2] major fix: login endpoint error and pnpm runtime --- .github/workflows/ci.yml | 32 +++++++++++-------- src/Infrastructures/http/createServer.js | 1 - .../authentications/swagger/authentication.js | 32 +++++++++++++------ .../http/api/users/swagger/users.js | 2 +- 4 files changed, 41 insertions(+), 26 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cf46223..05d3ac1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,27 +1,26 @@ name: Continuous Integration - + on: pull_request: branches: - main - + jobs: test: runs-on: ubuntu-latest - + strategy: matrix: node-version: ['20.x'] - # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ - + services: postgres: image: postgres env: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: mysecretpassword - POSTGRES_DB: forumapi_test - + POSTGRES_USER: postgres + POSTGRES_PASSWORD: mysecretpassword + POSTGRES_DB: forumapi_test + options: >- --health-cmd pg_isready --health-interval 10s @@ -29,18 +28,23 @@ jobs: --health-retries 5 ports: - 5432:5432 - + steps: - uses: actions/checkout@v2 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v2 with: node-version: ${{ matrix.node-version }} - - name: npm install migrate and test + cache: 'pnpm' + + - name: Install pnpm + run: npm install -g pnpm + + - name: pnpm install migrate and test run: | - npm install - npm run migrate up - npm run test + pnpm install + pnpm run migrate up + pnpm run test env: CI: true HOST: localhost diff --git a/src/Infrastructures/http/createServer.js b/src/Infrastructures/http/createServer.js index 78e19b7..fa86e6e 100644 --- a/src/Infrastructures/http/createServer.js +++ b/src/Infrastructures/http/createServer.js @@ -86,7 +86,6 @@ const createServer = async (container) => { const { response } = request; if (response instanceof Error) { - console.error(response); // <-- tambahkan ini agar error asli muncul const translatedError = DomainErrorTranslator.translate(response); diff --git a/src/Interfaces/http/api/authentications/swagger/authentication.js b/src/Interfaces/http/api/authentications/swagger/authentication.js index 0144d3a..7dabbcf 100644 --- a/src/Interfaces/http/api/authentications/swagger/authentication.js +++ b/src/Interfaces/http/api/authentications/swagger/authentication.js @@ -3,8 +3,9 @@ const Joi = require("joi"); const postAuthentication = { tags: ["api", "Authentications"], description: "Membuat authentication baru (login)", - notes: "User mengirimkan username dan password, akan dikembalikan accessToken & refreshToken", - + notes: + "User mengirimkan username dan password, akan dikembalikan accessToken & refreshToken", + validate: { payload: Joi.object({ username: Joi.string().required().description("Username user"), @@ -14,8 +15,11 @@ const postAuthentication = { response: { schema: Joi.object({ - accessToken: Joi.string().required(), - refreshToken: Joi.string().required(), + status: Joi.string().valid("success").required(), + data: Joi.object({ + accessToken: Joi.string().required(), + refreshToken: Joi.string().required(), + }).required(), }).label("PostAuthenticationResponse"), }, }; @@ -23,17 +27,23 @@ const postAuthentication = { const putAuthentication = { tags: ["api", "Authentications"], description: "Memperbarui access token menggunakan refresh token", - notes: "User mengirimkan refreshToken yang valid, akan dikembalikan accessToken baru", - + notes: + "User mengirimkan refreshToken yang valid, akan dikembalikan accessToken baru", + validate: { payload: Joi.object({ - refreshToken: Joi.string().required().description("Refresh token yang valid"), + refreshToken: Joi.string() + .required() + .description("Refresh token yang valid"), }), }, response: { schema: Joi.object({ - accessToken: Joi.string().required(), + status: Joi.string().valid("success").required(), + data: Joi.object({ + accessToken: Joi.string().required(), + }).required(), }).label("PutAuthenticationResponse"), }, }; @@ -42,10 +52,12 @@ const deleteAuthentication = { tags: ["api", "Authentications"], description: "Menghapus refresh token (logout)", notes: "User mengirimkan refreshToken yang ingin dihapus", - + validate: { payload: Joi.object({ - refreshToken: Joi.string().required().description("Refresh token yang ingin dihapus"), + refreshToken: Joi.string() + .required() + .description("Refresh token yang ingin dihapus"), }), }, diff --git a/src/Interfaces/http/api/users/swagger/users.js b/src/Interfaces/http/api/users/swagger/users.js index 6f10039..28f14d2 100644 --- a/src/Interfaces/http/api/users/swagger/users.js +++ b/src/Interfaces/http/api/users/swagger/users.js @@ -10,7 +10,7 @@ const postUser = { username: Joi.string().required().description('Username unik'), password: Joi.string().required().description('Password user'), fullname: Joi.string().required().description('Nama lengkap user'), - }), + }) }, response: { From d1d561b919aff948e44c82c502b3085161deb35e Mon Sep 17 00:00:00 2001 From: OfrenDialsa Date: Fri, 12 Dec 2025 23:12:55 +0700 Subject: [PATCH 2/2] minor fix: rollback to npm --- .github/workflows/ci.yml | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 05d3ac1..cf46223 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,26 +1,27 @@ name: Continuous Integration - + on: pull_request: branches: - main - + jobs: test: runs-on: ubuntu-latest - + strategy: matrix: node-version: ['20.x'] - + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + services: postgres: image: postgres env: - POSTGRES_USER: postgres - POSTGRES_PASSWORD: mysecretpassword - POSTGRES_DB: forumapi_test - + POSTGRES_USER: postgres + POSTGRES_PASSWORD: mysecretpassword + POSTGRES_DB: forumapi_test + options: >- --health-cmd pg_isready --health-interval 10s @@ -28,23 +29,18 @@ jobs: --health-retries 5 ports: - 5432:5432 - + steps: - uses: actions/checkout@v2 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v2 with: node-version: ${{ matrix.node-version }} - cache: 'pnpm' - - - name: Install pnpm - run: npm install -g pnpm - - - name: pnpm install migrate and test + - name: npm install migrate and test run: | - pnpm install - pnpm run migrate up - pnpm run test + npm install + npm run migrate up + npm run test env: CI: true HOST: localhost