31 lines
934 B
TypeScript
31 lines
934 B
TypeScript
import { GetPlacesResponse } from "~/business-logic/core/places/get-places/data/response-object/protocols";
|
|
import IGetPlacesPort from "~/business-logic/core/places/get-places/port";
|
|
import { HTTPPovider } from "~/driven/boundaries/http-boundary/httpBoundary";
|
|
import { HttpOptionsType } from "~/driven/boundaries/http-boundary/protocols";
|
|
import { apiUrls } from "~/driven/utils/configs/appConfig";
|
|
|
|
const getPlacesAdapter = async (): Promise<IGetPlacesPort> => {
|
|
// url of api
|
|
const url = apiUrls.core.places;
|
|
// make the options of request
|
|
const options: HttpOptionsType = {
|
|
url,
|
|
method: "GET",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
};
|
|
// make the httpHandler
|
|
const httpProvider = new HTTPPovider();
|
|
|
|
const httpHandler = async () =>
|
|
httpProvider.request<GetPlacesResponse>(options);
|
|
|
|
// return the method
|
|
return {
|
|
httpHandler,
|
|
};
|
|
};
|
|
|
|
export default getPlacesAdapter;
|