Skip to content

Commit

Permalink
Update server
Browse files Browse the repository at this point in the history
  • Loading branch information
infomiho committed Oct 31, 2024
1 parent 10fa111 commit d1c8db5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/tasks/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ import { HttpError } from "wasp/server";
import { type GetTasks } from "wasp/server/operations";

//Using TypeScript's new 'satisfies' keyword, it will infer the types of the arguments and return value
export const getTasks = ((_args, context) => {
export const getTasks = (async (_args, context) => {
if (!context.user) {
throw new HttpError(401);
}

return context.entities.Task.findMany({
const tasks = await context.entities.Task.findMany({
where: { user: { id: context.user.id } },
orderBy: { id: "asc" },
});
return tasks.map((task) => {
task.description = task.description.toUpperCase();
return task;
});
}) satisfies GetTasks<void, Task[]>;

0 comments on commit d1c8db5

Please sign in to comment.