From a1e22f1459132e191e53b27cd9a22486a08e874f Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Sat, 30 May 2026 09:33:49 +0200 Subject: [PATCH] Refactoring --- apps/api/src/services/fetch/fetch.service.ts | 9 ++++++--- .../fetch/interfaces/web-fetch-domain.interface.ts | 13 ++++++++++++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/apps/api/src/services/fetch/fetch.service.ts b/apps/api/src/services/fetch/fetch.service.ts index 53c06e9dc..a01441a27 100644 --- a/apps/api/src/services/fetch/fetch.service.ts +++ b/apps/api/src/services/fetch/fetch.service.ts @@ -11,7 +11,10 @@ import { createOpenRouter } from '@openrouter/ai-sdk-provider'; import { generateText, jsonSchema, tool } from 'ai'; import ms from 'ms'; -import { WebFetchDomain } from './interfaces/web-fetch-domain.interface'; +import { + HttpRequestMethod, + WebFetchDomain +} from './interfaces/web-fetch-domain.interface'; @Injectable() export class FetchService implements OnModuleInit { @@ -36,7 +39,7 @@ export class FetchService implements OnModuleInit { init?.method ?? (input instanceof Request ? input.method : undefined) ?? 'GET' - ).toUpperCase(); + ).toUpperCase() as HttpRequestMethod; const url = input instanceof Request ? input.url : input.toString(); const urlRedacted = this.redactUrl(url); @@ -167,7 +170,7 @@ export class FetchService implements OnModuleInit { method, url }: { - method: string; + method: HttpRequestMethod; url: string; }) { try { diff --git a/apps/api/src/services/fetch/interfaces/web-fetch-domain.interface.ts b/apps/api/src/services/fetch/interfaces/web-fetch-domain.interface.ts index 122caecc4..048e9b9ab 100644 --- a/apps/api/src/services/fetch/interfaces/web-fetch-domain.interface.ts +++ b/apps/api/src/services/fetch/interfaces/web-fetch-domain.interface.ts @@ -1,5 +1,16 @@ +export type HttpRequestMethod = + | 'CONNECT' + | 'DELETE' + | 'GET' + | 'HEAD' + | 'OPTIONS' + | 'PATCH' + | 'POST' + | 'PUT' + | 'TRACE'; + export interface WebFetchDomain { domain: string; - methods: string[]; + methods: HttpRequestMethod[]; responseContentType: string; }