29 lines
938 B
TypeScript
29 lines
938 B
TypeScript
import { apiUrls } from '~/driven/utils/configs/appConfig';
|
|
import { HttpOptionsType } from '~/driven/boundaries/http-boundary/protocols';
|
|
import { HTTPPovider } from '~/driven/boundaries/http-boundary/httpBoundary';
|
|
import { GetUsersResponse } from '~/business-logic/core/users/get-users/data/response-object/protocols';
|
|
import IGetUsersPort from '~/business-logic/core/users/get-users/ports';
|
|
import { getUsersAdapterReturnType } from './protocols';
|
|
|
|
const getUsersAdapter = (): IGetUsersPort & getUsersAdapterReturnType => {
|
|
// url of api
|
|
const url = apiUrls.core.getUsers;
|
|
// make the options of request
|
|
const options: HttpOptionsType = {
|
|
url,
|
|
method: 'GET',
|
|
};
|
|
// make the httpHandler
|
|
const httpProvider = new HTTPPovider();
|
|
|
|
const httpHandler = async () => httpProvider.request<GetUsersResponse>(options);
|
|
|
|
// return the method
|
|
return {
|
|
httpHandler,
|
|
url,
|
|
};
|
|
};
|
|
|
|
export default getUsersAdapter;
|