UNPKG

@traversets/code-extractor

Version:

The TypeScript Code Extractor and Analyzer can be handy for RAG (Retrieval-Augmented Generation) systems for codebases. It provides a detailed and structured representation of the codebase that can be converted into embeddings, enabling more effective adv

34 lines (33 loc) 1.81 kB
import * as https from "https"; import { IHttpClient } from "./http-service.interface"; import { ApplicationLogger } from "../logger/logger-service"; /** * A custom HTTP client implementation that provides a set of methods for sending HTTP requests. * This client supports GET, POST, PUT, and DELETE requests, and allows for optional request options and payload. * It also handles JSON parsing and error logging. */ export declare class HttpClient implements IHttpClient { logger: ApplicationLogger; constructor(); get<T>(payload: any, options?: https.RequestOptions): Promise<T>; post<TRequest, TResponse>(payload: TRequest, options?: https.RequestOptions): Promise<TResponse>; put<TRequest, TResponse>(payload: TRequest, options?: https.RequestOptions): Promise<TResponse>; delete<TResponse>(options?: https.RequestOptions): Promise<TResponse>; private sendRequest; /** * Returns an object with the required headers for API requests. * The authorization header uses a JWT token stored in local storage, which has a lifespan of 4 days (4 * 24 * 60 * 60). * @returns An object with the "Authorization" and "Content-Type" headers */ private generateRequestHeader; private generateRequestOptions; /** * Initiates a request to the server with the provided data and request type. * @param url - The URL of the request. * @param data - The data to be sent with the request. * @param requestType - The type of request (either "post" or "get"). * @param requestToken - An optional request token for authentication. * @returns A promise that resolves to the response from the server. */ inititateRequest<T>(method: string, path: string, baseUrl: string, data: any, jwtToken?: string): Promise<T | undefined>; }