[FEAT]: add adapter of create account in driven layer
This commit is contained in:
parent
cec906f519
commit
896914daaa
@ -1,3 +1,5 @@
|
||||
VITE_API_ORIGIN = http://176.53.196.42:6001/api/v1
|
||||
VITE_API_PLACES = /place
|
||||
VITE_API_USERS = /profile
|
||||
VITE_API_USERS_ACCOUNT = /account
|
||||
VITE_API_USERS_PROFILE = /profile
|
@ -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<CreateAcountResponseApi>;
|
||||
export type HttpHandler = (newUser: INewUserData) => Promise<CreateAcountResponseApi>;
|
||||
|
@ -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<CreateAcountResponseApi>(httpOptions);
|
||||
};
|
||||
|
||||
return httpHandler;
|
||||
};
|
||||
|
||||
export default createAccountAdapter;
|
@ -27,5 +27,7 @@ export const apiUrls = {
|
||||
core: {
|
||||
getPlaces: `${baseApiUrl}${ENVs.apiGetPlaces}`,
|
||||
getUsers: `${baseApiUrl}${ENVs.apiGetUsers}`,
|
||||
createUserAccount: `${baseApiUrl}${ENVs.apiCreateUserAccount}`,
|
||||
createUserProfile: `${baseApiUrl}${ENVs.apiCreateUserProfile}`,
|
||||
},
|
||||
};
|
||||
|
@ -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,
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user