From 15a87dd83278e4667794399b7dc8918118b55a4d Mon Sep 17 00:00:00 2001 From: Karan Shah Date: Wed, 9 Feb 2022 11:17:38 +0000 Subject: [PATCH] Added a config.d.ts Signed-off-by: Karan Shah --- plugins/airbrake-backend/config.d.ts | 25 +++++++++++++++++++ plugins/airbrake-backend/package.json | 3 ++- .../src/config/ExtractAirbrakeConfig.ts | 17 +++---------- plugins/airbrake-backend/src/config/index.ts | 2 +- 4 files changed, 32 insertions(+), 15 deletions(-) create mode 100644 plugins/airbrake-backend/config.d.ts diff --git a/plugins/airbrake-backend/config.d.ts b/plugins/airbrake-backend/config.d.ts new file mode 100644 index 0000000000..8787d2c94e --- /dev/null +++ b/plugins/airbrake-backend/config.d.ts @@ -0,0 +1,25 @@ +/* + * Copyright 2021 The Backstage Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export interface Config { + /** Configuration options for the Airbrake plugin */ + airbrake?: { + /** + * The API Key to authenticate requests. More details on how to get this here: https://airbrake.io/docs/api/#authentication + */ + apiKey: string; + }; +} diff --git a/plugins/airbrake-backend/package.json b/plugins/airbrake-backend/package.json index 0ad55d192c..22589c8f21 100644 --- a/plugins/airbrake-backend/package.json +++ b/plugins/airbrake-backend/package.json @@ -38,7 +38,8 @@ "msw": "^0.35.0" }, "files": [ - "dist" + "dist", + "config.d.ts" ], "jest": { "coverageThreshold": { diff --git a/plugins/airbrake-backend/src/config/ExtractAirbrakeConfig.ts b/plugins/airbrake-backend/src/config/ExtractAirbrakeConfig.ts index 6d6c814345..0e3d032190 100644 --- a/plugins/airbrake-backend/src/config/ExtractAirbrakeConfig.ts +++ b/plugins/airbrake-backend/src/config/ExtractAirbrakeConfig.ts @@ -14,18 +14,7 @@ * limitations under the License. */ import { Config } from '@backstage/config'; - -/** - * The Airbrake config object - * - * @public - */ -export type AirbrakeConfig = { - /** - * The API Key - */ - apiKey: string; -}; +import { AirbrakeConfig } from '.'; /** * Extract the Airbrake config from a config object @@ -34,7 +23,9 @@ export type AirbrakeConfig = { * * @param config - The config object to extract from */ -export function extractAirbrakeConfig(config: Config): AirbrakeConfig { +export function extractAirbrakeConfig( + config: Config, +): AirbrakeConfig['airbrake'] { return { apiKey: config.getString('airbrake.apiKey'), }; diff --git a/plugins/airbrake-backend/src/config/index.ts b/plugins/airbrake-backend/src/config/index.ts index 6200baca53..746d9fcafb 100644 --- a/plugins/airbrake-backend/src/config/index.ts +++ b/plugins/airbrake-backend/src/config/index.ts @@ -15,4 +15,4 @@ */ export { extractAirbrakeConfig } from './ExtractAirbrakeConfig'; -export type { AirbrakeConfig } from './ExtractAirbrakeConfig'; +export type { Config as AirbrakeConfig } from '../../config';