made use of first class citizen objects as json validator functions
This commit is contained in:
@@ -45,9 +45,13 @@ class PrismaUserDataSource implements UserDataSource {
|
||||
message: 'Failed to find user by email: ${error.toString()}',
|
||||
),
|
||||
)
|
||||
.flatMap(errorOnNull(AppError.notFound(
|
||||
'User with email $email found',
|
||||
)))
|
||||
.flatMap(
|
||||
errorOnNull(
|
||||
AppError.notFound(
|
||||
'User with email $email found',
|
||||
),
|
||||
),
|
||||
)
|
||||
.flatMap(mapper.from);
|
||||
}
|
||||
|
||||
@@ -63,9 +67,13 @@ class PrismaUserDataSource implements UserDataSource {
|
||||
message: 'Failed to find user by ID: ${error.toString()}',
|
||||
),
|
||||
)
|
||||
.flatMap(errorOnNull(AppError.notFound(
|
||||
"User with id $id not found",
|
||||
)))
|
||||
.flatMap(
|
||||
errorOnNull(
|
||||
AppError.notFound(
|
||||
"User with id $id not found",
|
||||
),
|
||||
),
|
||||
)
|
||||
.flatMap(mapper.from);
|
||||
}
|
||||
|
||||
@@ -104,15 +112,24 @@ class PrismaUserDataSource implements UserDataSource {
|
||||
}
|
||||
|
||||
@override
|
||||
TaskEither<IError, void> delete(String id) {
|
||||
return TaskEither.tryCatch(
|
||||
TaskEither<IError, User> delete(String id) {
|
||||
return TaskEither<IError, UserDbo?>.tryCatch(
|
||||
() async {
|
||||
await prisma.userDbo.delete(where: UserDboWhereUniqueInput(id: id));
|
||||
return await prisma.userDbo
|
||||
.delete(where: UserDboWhereUniqueInput(id: id));
|
||||
},
|
||||
(error, _) => AppError.databaseError(
|
||||
message: 'Failed to delete user: ${error.toString()}',
|
||||
),
|
||||
);
|
||||
)
|
||||
.flatMap(
|
||||
errorOnNull(
|
||||
AppError.notFound(
|
||||
'User not found',
|
||||
),
|
||||
),
|
||||
)
|
||||
.flatMap(mapper.from);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user