refactor use cases
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import type { AuthSession, IdentitySessionPort } from '../ports/IdentitySessionPort';
|
||||
import { Result } from '@core/shared/application/Result';
|
||||
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
||||
import type { UseCaseOutputPort, Logger } from '@core/shared/application';
|
||||
import type { Logger } from '@core/shared/application';
|
||||
|
||||
export type GetCurrentUserSessionInput = void;
|
||||
|
||||
@@ -18,16 +18,13 @@ export class GetCurrentUserSessionUseCase {
|
||||
constructor(
|
||||
private readonly sessionPort: IdentitySessionPort,
|
||||
private readonly logger: Logger,
|
||||
private readonly output: UseCaseOutputPort<GetCurrentUserSessionResult>,
|
||||
) {}
|
||||
|
||||
async execute(): Promise<Result<void, GetCurrentUserSessionApplicationError>> {
|
||||
async execute(): Promise<Result<GetCurrentUserSessionResult, GetCurrentUserSessionApplicationError>> {
|
||||
try {
|
||||
const session = await this.sessionPort.getCurrentSession();
|
||||
|
||||
this.output.present(session);
|
||||
|
||||
return Result.ok(undefined);
|
||||
return Result.ok(session);
|
||||
} catch (error) {
|
||||
const message =
|
||||
error instanceof Error && error.message
|
||||
|
||||
Reference in New Issue
Block a user