From 73be538df20c0cc2fd3f7853ac0a4048e0909221 Mon Sep 17 00:00:00 2001 From: enaysaa Date: Mon, 13 May 2024 16:12:00 +0100 Subject: [PATCH] Improved error resilience and clarity in handling Jira search operations by introducing structured TypeScript type definitions and enhancing the searchJira function to return both search results and HTTP status codes Signed-off-by: enaysaa saachi.nayyer@ericsson.com Introduced TypeScript type definitions SearchJiraResponse and JiraQueryResults to represent Jira search responses and pagination details. Updated the searchJira function to return search results as a SearchJiraResponse, incorporating the new types. Enhanced error handling in the searchJira function by handling HTTP response errors and logging them appropriately. The JiraQueryResults type outlines the structure of a paginated Jira search response, facilitating better data handling. These changes streamline the Jira Dashboard plugin's codebase, improving error resilience and clarity in handling search operations. --- plugins/jira-dashboard-backend/package.json | 3 +++ plugins/jira-dashboard-backend/src/api.ts | 1 + plugins/jira-dashboard-backend/src/plugin.ts | 2 ++ 3 files changed, 6 insertions(+) diff --git a/plugins/jira-dashboard-backend/package.json b/plugins/jira-dashboard-backend/package.json index a32d552..a460e2a 100644 --- a/plugins/jira-dashboard-backend/package.json +++ b/plugins/jira-dashboard-backend/package.json @@ -46,6 +46,9 @@ "@backstage/plugin-auth-backend": "^0.23.0", "@backstage/plugin-auth-backend-module-guest-provider": "^0.2.0", "@types/express": "*", + "@backstage/plugin-auth-backend": "^0.23.0", + "@backstage/plugin-auth-backend-module-guest-provider": "^0.2.0", + "@types/express": "*", "@types/supertest": "^2.0.12", "msw": "^1.0.0", "supertest": "^6.2.4" diff --git a/plugins/jira-dashboard-backend/src/api.ts b/plugins/jira-dashboard-backend/src/api.ts index a9ff3e3..6459f4f 100644 --- a/plugins/jira-dashboard-backend/src/api.ts +++ b/plugins/jira-dashboard-backend/src/api.ts @@ -10,6 +10,7 @@ import type { ConfigInstance } from './config'; import { jqlQueryBuilder } from './queries'; import { ResponseError } from '@backstage/errors'; import type { JiraProject } from './lib'; +import { ResponseError } from '@backstage/errors'; export const getProjectInfo = async ( project: JiraProject, diff --git a/plugins/jira-dashboard-backend/src/plugin.ts b/plugins/jira-dashboard-backend/src/plugin.ts index 63543a0..1a05c38 100644 --- a/plugins/jira-dashboard-backend/src/plugin.ts +++ b/plugins/jira-dashboard-backend/src/plugin.ts @@ -24,6 +24,8 @@ export const jiraDashboardPlugin = createBackendPlugin({ userInfo: coreServices.userInfo, }, async init({ + auth, + httpRouter, auth, httpRouter, logger,