Browse Source

Refactoring

pull/6960/head
Thomas Kaul 3 months ago
parent
commit
a1e22f1459
  1. 9
      apps/api/src/services/fetch/fetch.service.ts
  2. 13
      apps/api/src/services/fetch/interfaces/web-fetch-domain.interface.ts

9
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 { generateText, jsonSchema, tool } from 'ai';
import ms from 'ms'; import ms from 'ms';
import { WebFetchDomain } from './interfaces/web-fetch-domain.interface'; import {
HttpRequestMethod,
WebFetchDomain
} from './interfaces/web-fetch-domain.interface';
@Injectable() @Injectable()
export class FetchService implements OnModuleInit { export class FetchService implements OnModuleInit {
@ -36,7 +39,7 @@ export class FetchService implements OnModuleInit {
init?.method ?? init?.method ??
(input instanceof Request ? input.method : undefined) ?? (input instanceof Request ? input.method : undefined) ??
'GET' 'GET'
).toUpperCase(); ).toUpperCase() as HttpRequestMethod;
const url = input instanceof Request ? input.url : input.toString(); const url = input instanceof Request ? input.url : input.toString();
const urlRedacted = this.redactUrl(url); const urlRedacted = this.redactUrl(url);
@ -167,7 +170,7 @@ export class FetchService implements OnModuleInit {
method, method,
url url
}: { }: {
method: string; method: HttpRequestMethod;
url: string; url: string;
}) { }) {
try { try {

13
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 { export interface WebFetchDomain {
domain: string; domain: string;
methods: string[]; methods: HttpRequestMethod[];
responseContentType: string; responseContentType: string;
} }

Loading…
Cancel
Save