diff --git a/.changeset/sparkly-rivers-sell.md b/.changeset/sparkly-rivers-sell.md new file mode 100644 index 00000000000..ff0524f84e2 --- /dev/null +++ b/.changeset/sparkly-rivers-sell.md @@ -0,0 +1,5 @@ +--- +'@sap-ux/backend-proxy-middleware': patch +--- + +fix: simplify type usage diff --git a/packages/backend-proxy-middleware/package.json b/packages/backend-proxy-middleware/package.json index 141921c4385..fbd94372725 100644 --- a/packages/backend-proxy-middleware/package.json +++ b/packages/backend-proxy-middleware/package.json @@ -55,9 +55,6 @@ "supertest": "7.1.4", "yaml": "2.2.2" }, - "ui5": { - "dependencies": [] - }, "engines": { "node": ">=20.x" } diff --git a/packages/backend-proxy-middleware/src/base/types.ts b/packages/backend-proxy-middleware/src/base/types.ts index 48ed34251c6..5465524f247 100644 --- a/packages/backend-proxy-middleware/src/base/types.ts +++ b/packages/backend-proxy-middleware/src/base/types.ts @@ -68,10 +68,3 @@ export interface BackendMiddlewareConfig { options?: Partial; debug?: boolean; } - -export interface MiddlewareParameters { - resources: object; - options: { - configuration: T; - }; -} diff --git a/packages/backend-proxy-middleware/src/middleware.ts b/packages/backend-proxy-middleware/src/middleware.ts index 84894189a85..a2d880ddc30 100644 --- a/packages/backend-proxy-middleware/src/middleware.ts +++ b/packages/backend-proxy-middleware/src/middleware.ts @@ -3,8 +3,9 @@ import { LogLevel, ToolsLogger, UI5ToolingTransport } from '@sap-ux/logger'; import type { RequestHandler } from 'express'; import express from 'express'; import { createProxyMiddleware } from 'http-proxy-middleware'; -import type { BackendMiddlewareConfig, MiddlewareParameters } from './base/types'; +import type { BackendMiddlewareConfig } from './base/types'; import { generateProxyMiddlewareOptions, initI18n } from './base/proxy'; +import type { MiddlewareParameters } from '@ui5/server'; /** * Hides the proxy credentials for displaying the proxy configuration in the console. @@ -33,6 +34,11 @@ function formatProxyForLogging(proxy: string | undefined): string | undefined { * @returns {*} {(Promise)} */ module.exports = async ({ options }: MiddlewareParameters): Promise => { + const backend = options.configuration?.backend; + if (!backend) { + throw new Error('no backend configuration found.'); + } + const logger = new ToolsLogger({ logLevel: options.configuration?.debug ? LogLevel.Debug : LogLevel.Info, transports: [new UI5ToolingTransport({ moduleName: 'backend-proxy-middleware' })] @@ -42,13 +48,12 @@ module.exports = async ({ options }: MiddlewareParameters