-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* spalsh user check * spalsh user check format * navigation according to dat * navigation according to dat format * changes for names convention * changes for names convention format * changes for names to camelcase * changes for names to camelcase format
- Loading branch information
1 parent
46c5b9e
commit bc5c6e5
Showing
27 changed files
with
220 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import { UserModel } from 'shared' | ||
|
||
export interface DatabasePort { | ||
adduser(params?: { email: string; password: string; token: string }): Promise<boolean> | ||
getUserDetails(data: UserModel): Promise<UserModel> | ||
addUser(params?: { email: string; password: string; token: string }): Promise<boolean> | ||
fetchUserData(data: UserModel): Promise<UserModel> | ||
fetchUserExists(data: UserModel): Promise<boolean> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { UserModel } from 'shared' | ||
|
||
export interface NetworkPort { | ||
loginCall(params?: { email: string; password: string }): Promise<UserModel> | ||
login(params?: { email: string; password: string }): Promise<UserModel> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,22 @@ | ||
import { LoginCheckUsecase, UserDetailsUseCase } from 'domain-layer' | ||
import { UserRepository } from './../repository/user_repository' | ||
import { DataModule } from 'data' | ||
import { Graph, ObjectGraph, Provides, Singleton } from 'di' | ||
import { LoginUseCase } from '../usecases/login_user_usecase' | ||
import { FetchUserDataUseCase, FetchUserExistsUseCase } from '../domain' | ||
|
||
@Singleton() | ||
@Graph({ subgraphs: [DataModule] }) | ||
export class DomainModule extends ObjectGraph { | ||
@Provides() | ||
providesLoginCheckUseCase(provideUserRepository: UserRepository): LoginCheckUsecase { | ||
return new LoginCheckUsecase(provideUserRepository) | ||
providesLoginUseCase(provideUserRepository: UserRepository): LoginUseCase { | ||
return new LoginUseCase(provideUserRepository) | ||
} | ||
@Provides() | ||
provideUserDetailsUseCase(provideUserRepository: UserRepository): UserDetailsUseCase { | ||
return new UserDetailsUseCase(provideUserRepository) | ||
provideUserDataUseCase(provideUserRepository: UserRepository): FetchUserDataUseCase { | ||
return new FetchUserDataUseCase(provideUserRepository) | ||
} | ||
@Provides() | ||
provideUserExistsUseCase(provideUserRepository: UserRepository): FetchUserExistsUseCase { | ||
return new FetchUserExistsUseCase(provideUserRepository) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
import { LoginCheckParams, LoginCheckUsecase } from './usecases/login_check_usecase' | ||
import { FetchUserExistsUseCase, FetchUserExistsUseCaseParams } from './usecases/user_present_data_usecase' | ||
import { FetchUserDataUseCase, FetchUserDataUseCaseParams } from './usecases/user_details_usecase' | ||
import { LoginUseCase, LoginParams } from './usecases/login_user_usecase' | ||
import { DomainModule } from './di/domain_module' | ||
import { UserRepository } from './repository/user_repository' | ||
import { UserDetailsUseCaseParams, UserDetailsUseCase } from './usecases/user_details_usecase' | ||
|
||
export { | ||
LoginCheckParams, | ||
LoginCheckUsecase, | ||
DomainModule, | ||
UserRepository, | ||
UserDetailsUseCase, | ||
UserDetailsUseCaseParams | ||
LoginUseCase, | ||
LoginParams, | ||
FetchUserDataUseCase, | ||
FetchUserDataUseCaseParams, | ||
FetchUserExistsUseCase, | ||
FetchUserExistsUseCaseParams | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import { UserModel } from 'shared' | ||
|
||
export interface UserRepository { | ||
loginCheck(params?: { email: string; password: string }): Promise<boolean> | ||
getuserdata(params?: { email: string }): Promise<UserModel> | ||
login(params?: { email: string; password: string }): Promise<boolean> | ||
fetchUserData(params?: { email: string }): Promise<UserModel> | ||
fetchUserExists(params?: { email: string }): Promise<boolean> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { UserModel } from 'packages/shared/src/shared' | ||
import { UserRepository } from '../domain' | ||
import { FutureUseCase } from './base/base_usecase' | ||
import { Params } from './base/params' | ||
|
||
export class FetchUserExistsUseCase extends FutureUseCase<FetchUserExistsUseCaseParams, boolean> { | ||
private readonly userRepository: UserRepository | ||
constructor(repo: UserRepository) { | ||
super() | ||
this.userRepository = repo | ||
} | ||
async execute(params?: FetchUserExistsUseCaseParams): Promise<boolean> { | ||
if (params?.verify) { | ||
return await this.userRepository.fetchUserExists({ | ||
email: params.email | ||
}) | ||
} | ||
} | ||
} | ||
export class FetchUserExistsUseCaseParams extends Params { | ||
readonly email?: string | ||
|
||
constructor(params?: { email: string }) { | ||
super({}) | ||
this.email = params.email | ||
} | ||
|
||
verify(): boolean { | ||
return true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
export enum REQUEST_USER { | ||
MAKE_REQUEST = 'MAKE_REQUEST', | ||
REQUEST_USER_SUCCESS = 'REQUEST_USER_SUCCESS', | ||
REQUEST_USER_FAILURE = 'REQUEST_USER_FAILURE' | ||
export enum LOGIN { | ||
request = 'LOGIN_REQUEST', | ||
success = 'LOGIN_SUCCESS', | ||
failure = 'LOGIN_FAILURE' | ||
} | ||
|
||
export const userRequest = params => ({ | ||
type: REQUEST_USER.MAKE_REQUEST, | ||
export const loginAction = params => ({ | ||
type: LOGIN.request, | ||
params | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
import data from 'packages/data/lib/data' | ||
import { Resource } from '../../utils/resource' | ||
import { REQUEST_USER } from './actions' | ||
import { LOGIN } from './actions' | ||
|
||
const userRequestReducer = (initialState = Resource.none, action) => { | ||
const loginReducer = (initialState = Resource.none, action) => { | ||
switch (action.type) { | ||
case REQUEST_USER.MAKE_REQUEST: | ||
case LOGIN.request: | ||
return Resource.loading() | ||
|
||
case REQUEST_USER.REQUEST_USER_SUCCESS: | ||
case LOGIN.success: | ||
return Resource.success({ | ||
data: action | ||
}) | ||
|
||
case REQUEST_USER.REQUEST_USER_FAILURE: | ||
case LOGIN.failure: | ||
return Resource.error({ | ||
error: 'User Not logged in' | ||
}) | ||
default: | ||
return initialState | ||
} | ||
} | ||
export default userRequestReducer | ||
export default loginReducer |
Oops, something went wrong.