diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 2e381bd..2362168 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -20,6 +20,6 @@ jobs: script: | cd ~/ForumAPI git pull origin main - npm install - npm run migrate up + pnpm install + pnpm migrate up pm2 restart forum-api \ No newline at end of file diff --git a/src/Infrastructures/http/createServer.js b/src/Infrastructures/http/createServer.js index db7b3e6..78e19b7 100644 --- a/src/Infrastructures/http/createServer.js +++ b/src/Infrastructures/http/createServer.js @@ -83,14 +83,13 @@ const createServer = async (container) => { } server.ext("onPreResponse", (request, h) => { - // mendapatkan konteks response dari request const { response } = request; if (response instanceof Error) { - // bila response tersebut error, tangani sesuai kebutuhan + console.error(response); // <-- tambahkan ini agar error asli muncul + const translatedError = DomainErrorTranslator.translate(response); - // penanganan client error secara internal. if (translatedError instanceof ClientError) { const newResponse = h.response({ status: "fail", @@ -100,12 +99,10 @@ const createServer = async (container) => { return newResponse; } - // mempertahankan penanganan client error oleh hapi secara native, seperti 404, etc. if (!translatedError.isServer) { return h.continue; } - // penanganan server error sesuai kebutuhan const newResponse = h.response({ status: "error", message: "terjadi kegagalan pada server kami", @@ -114,7 +111,6 @@ const createServer = async (container) => { return newResponse; } - // jika bukan error, lanjutkan dengan response sebelumnya (tanpa terintervensi) return h.continue; });