diff --git a/.env.development b/.env.development index 6d34599..0c4d5ee 100644 --- a/.env.development +++ b/.env.development @@ -1,3 +1,5 @@ VITE_API_ORIGIN = http://176.53.196.42:6001/api/v1 VITE_API_PLACES = /place -VITE_API_USERS = /profile \ No newline at end of file +VITE_API_USERS = /profile +VITE_API_USERS_ACCOUNT = /account +VITE_API_USERS_PROFILE = /profile \ No newline at end of file diff --git a/src/business-logic/core/users/create-user/create-account/data/repository/protocols.ts b/src/business-logic/core/users/create-user/create-account/data/repository/protocols.ts index e904070..9263d97 100644 --- a/src/business-logic/core/users/create-user/create-account/data/repository/protocols.ts +++ b/src/business-logic/core/users/create-user/create-account/data/repository/protocols.ts @@ -1,4 +1,4 @@ -import { CreateAccountDTOReturnType } from '../dto/protocols'; +import { INewUserData } from '../dto/protocols'; import { CreateAcountResponseApi } from '../response-object/protocols'; -export type HttpHandler = (newUser: CreateAccountDTOReturnType) => Promise; +export type HttpHandler = (newUser: INewUserData) => Promise; diff --git a/src/driven/adapters/create-account-adapter/createAccountAdapter.ts b/src/driven/adapters/create-account-adapter/createAccountAdapter.ts new file mode 100644 index 0000000..063bf86 --- /dev/null +++ b/src/driven/adapters/create-account-adapter/createAccountAdapter.ts @@ -0,0 +1,30 @@ +import { INewUserData } from '~/business-logic/core/users/create-user/create-account/data/dto/protocols'; +import { CreateAcountResponseApi } from '~/business-logic/core/users/create-user/create-account/data/response-object/protocols'; +import createUserPort from '~/business-logic/core/users/create-user/ports'; +import { HTTPPovider } from '~/driven/boundaries/http-boundary/httpBoundary'; +import { HttpOptionsType } from '~/driven/boundaries/http-boundary/protocols'; +import { apiUrls } from '~/driven/utils/configs/appConfig'; + +const createAccountAdapter = (): createUserPort['httpAccountHandler'] => { + // make url + const url = apiUrls.core.createUserAccount; + // call http provider + const httpProvider = new HTTPPovider(); + + const httpHandler = (newUserData: INewUserData) => { + // api options + const httpOptions: HttpOptionsType = { + url, + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + data: newUserData, + }; + return httpProvider.request(httpOptions); + }; + + return httpHandler; +}; + +export default createAccountAdapter; diff --git a/src/driven/utils/configs/appConfig.ts b/src/driven/utils/configs/appConfig.ts index 9043e87..bb2a9bd 100644 --- a/src/driven/utils/configs/appConfig.ts +++ b/src/driven/utils/configs/appConfig.ts @@ -27,5 +27,7 @@ export const apiUrls = { core: { getPlaces: `${baseApiUrl}${ENVs.apiGetPlaces}`, getUsers: `${baseApiUrl}${ENVs.apiGetUsers}`, + createUserAccount: `${baseApiUrl}${ENVs.apiCreateUserAccount}`, + createUserProfile: `${baseApiUrl}${ENVs.apiCreateUserProfile}`, }, }; diff --git a/src/driven/utils/constants/envs.ts b/src/driven/utils/constants/envs.ts index 2d5b6eb..180dc4c 100644 --- a/src/driven/utils/constants/envs.ts +++ b/src/driven/utils/constants/envs.ts @@ -2,4 +2,6 @@ export const ENVs = { apiOrigin: process.env.VITE_API_ORIGIN, apiGetPlaces: process.env.VITE_API_PLACES, apiGetUsers: process.env.VITE_API_USERS, + apiCreateUserAccount: process.env.VITE_API_USERS_ACCOUNT, + apiCreateUserProfile: process.env.VITE_API_USERS_PROFILE, };