-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Few adjustments to allow to use the server properly from the fronten… #1
Changes from all commits
3348303
f73086e
384f048
c4f997d
50e3866
8d4c580
e65ef17
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { CustomError } from '../../../errors'; | ||
import { ISyncRepository } from '../sync.repository'; | ||
import { getConnector } from '../../../connector/infrastructure/factory'; | ||
|
||
export interface GetSyncAuthUseCase { | ||
execute(id: string): Promise<boolean>; | ||
} | ||
|
||
export class GetSyncAuth implements GetSyncAuthUseCase { | ||
constructor(private readonly repository: ISyncRepository) {} | ||
|
||
async execute(id: string) { | ||
const data = await this.repository.getSync(id); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can create an SyncEntity and get the sourceConector from there to get the auth data. it Is better because we will have only one responsible to manage this, the entity |
||
if (data === null) { | ||
throw new CustomError(`Sync with id ${id} not found`, 404); | ||
} | ||
const connectorDefinition = getConnector(data.connector?.name || ''); | ||
if (!connectorDefinition) { | ||
return false; | ||
} | ||
const sourceConnector = connectorDefinition.factory(); | ||
sourceConnector.setParameters(data.connector?.parameters ?? {}); | ||
return sourceConnector.hasAuthData(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to create a sync object without validate the conector data?