Skip to content
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

[CES-644] List tasks #57

Merged
merged 6 commits into from
Jan 15, 2025
Merged

[CES-644] List tasks #57

merged 6 commits into from
Jan 15, 2025

Conversation

kin0992
Copy link
Contributor

@kin0992 kin0992 commented Jan 15, 2025

Add OpenAPI operation to list tasks.

Implement the list operation on CosmosDB, to get the persisted tasks

Copy link

changeset-bot bot commented Jan 15, 2025

🦋 Changeset detected

Latest commit: 648843f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
to-do-api Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@kin0992 kin0992 force-pushed the features/list-tasks branch from 6d667b1 to a92f0dc Compare January 15, 2025 12:54
pipe(
RTE.ask<Env>(),
// execute use case
RTE.flatMap(listTasks),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: in this case, the listTasks isn't a use case but a function under the domain layer.

this is wanted because the use case would be just a wrapper around the function already used, the listTasks.
If the list operation is going to be more complicated, with some custom logic before sending the result, then a use case would be the place where to hide that logic.

@@ -12,4 +14,13 @@ export const makeTaskRepository = (container: Container): TaskRepository => ({
TE.tryCatch(() => container.items.create(task), E.toError),
TE.mapBoth(cosmosErrorToDomainError, () => task),
),
list: () =>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Currently, due to the goal of this playground, no pagination is available.

If we need that, we are going to update this function

*
* @param codec the io-ts codec to use to decode the resources
*/
export const decodeFromFeed =
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thought: this function, and also other decode functions, might be in a separate package and could be used to parse what's coming from the CosmosDB server to a well-known domain type.

@kin0992 kin0992 marked this pull request as ready for review January 15, 2025 14:54
@kin0992 kin0992 requested a review from a team as a code owner January 15, 2025 14:54
@kin0992 kin0992 merged commit 964afe1 into main Jan 15, 2025
4 checks passed
@kin0992 kin0992 deleted the features/list-tasks branch January 15, 2025 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant