diff --git a/src/core/aws-web.core.ts b/src/core/aws-web.core.ts index 98b066d..185b1cd 100644 --- a/src/core/aws-web.core.ts +++ b/src/core/aws-web.core.ts @@ -2,7 +2,7 @@ import { AWSWebCoreState, Body, LemonCredentials, LemonKMS, LemonOAuthToken, Par import { AWSStorageService, USE_X_LEMON_IDENTITY_KEY } from '../token-storage'; import { calcSignature, LoggerService } from '../utils'; import { AxiosRequestConfig, AxiosResponse } from 'axios'; -import { AWSHttpRequestBuilder } from '../http'; +import { AWSHttpRequestBuilder, HttpRequestBuilder } from '../http'; import AWS from 'aws-sdk/global.js'; /** @@ -62,6 +62,46 @@ export class AWSWebCore implements WebCoreService { return 'build'; } + /** + * Builds a request using HttpRequestBuilder without Credentials. + * @param {AxiosRequestConfig} config - The Axios request configuration. + * @returns {HttpRequestBuilder} - The HttpRequestBuilder instance. + */ + buildRequest(config: AxiosRequestConfig): HttpRequestBuilder { + return new HttpRequestBuilder(config); + } + + /** + * Executes a HTTP request without Credentials. + * @template T + * @param {string} method - The HTTP method. + * @param {string} url - The request URL. + * @param {Params} [params={}] - The request parameters. + * @param {Body} body - The request body. + * @param {AxiosRequestConfig} [config] - Additional Axios request configuration. + * @returns {Promise>} - The Axios response. + */ + async request( + method: string, + url: string, + params: Params = {}, + body?: Body, + config?: AxiosRequestConfig + ): Promise> { + const builder = new HttpRequestBuilder({ + method, + baseURL: url, + params, + }); + if (body) { + builder.setBody(body); + } + if (config) { + builder.addAxiosRequestConfig(config); + } + return await builder.execute(); + } + /** * Builds a signed request using AWSHttpRequestBuilder. * @param {AxiosRequestConfig} config - The Axios request configuration. diff --git a/src/core/azure-web.core.ts b/src/core/azure-web.core.ts index bf47411..c677cec 100644 --- a/src/core/azure-web.core.ts +++ b/src/core/azure-web.core.ts @@ -2,7 +2,7 @@ import { AzureWebCoreState, Body, LemonOAuthToken, Params, WebCoreConfig, WebCor import { AzureStorageService, USE_X_LEMON_IDENTITY_KEY } from '../token-storage'; import { LoggerService } from '../utils'; import { AxiosRequestConfig, AxiosResponse } from 'axios'; -import { AzureHttpRequestBuilder } from '../http'; +import { AzureHttpRequestBuilder, HttpRequestBuilder } from '../http'; /** * Class to handle Azure-specific web core operations. @@ -42,6 +42,46 @@ export class AzureWebCore implements WebCoreService { return 'has-token'; } + /** + * Builds a request using HttpRequestBuilder without Credentials. + * @param {AxiosRequestConfig} config - The Axios request configuration. + * @returns {HttpRequestBuilder} - The HttpRequestBuilder instance. + */ + buildRequest(config: AxiosRequestConfig): HttpRequestBuilder { + return new HttpRequestBuilder(config); + } + + /** + * Executes a HTTP request without Credentials. + * @template T + * @param {string} method - The HTTP method. + * @param {string} url - The request URL. + * @param {Params} [params={}] - The request parameters. + * @param {Body} body - The request body. + * @param {AxiosRequestConfig} [config] - Additional Axios request configuration. + * @returns {Promise>} - The Axios response. + */ + async request( + method: string, + url: string, + params: Params = {}, + body?: Body, + config?: AxiosRequestConfig + ): Promise> { + const builder = new HttpRequestBuilder({ + method, + baseURL: url, + params, + }); + if (body) { + builder.setBody(body); + } + if (config) { + builder.addAxiosRequestConfig(config); + } + return await builder.execute(); + } + /** * Builds a signed request using the provided Axios configuration. * @param {AxiosRequestConfig} config - The Axios request configuration.