From 6e1fc95f168cccc202a617e41c15d588de2bc22c Mon Sep 17 00:00:00 2001 From: Marco Comi Date: Wed, 15 Jan 2025 18:13:09 +0100 Subject: [PATCH] Replace old logic and parse path parameter --- .../src/adapters/azure/functions/delete-task.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/to-do-api/src/adapters/azure/functions/delete-task.ts b/apps/to-do-api/src/adapters/azure/functions/delete-task.ts index 4de126a..b55752a 100644 --- a/apps/to-do-api/src/adapters/azure/functions/delete-task.ts +++ b/apps/to-do-api/src/adapters/azure/functions/delete-task.ts @@ -3,10 +3,11 @@ import { httpAzureFunction } from "@pagopa/handler-kit-azure-func"; import * as RTE from "fp-ts/lib/ReaderTaskEither.js"; import { pipe } from "fp-ts/lib/function.js"; -import { aTask } from "../../../domain/__tests__/data.js"; import { Capabilities } from "../../../domain/Capabilities.js"; +import { TaskIdCodec } from "../../../domain/Task.js"; import { deleteTask } from "../../../domain/TaskRepository.js"; import { toHttpProblemJson } from "../../http/codec.js"; +import { parsePathParameter } from "../../http/middleware.js"; type Env = Pick; @@ -15,11 +16,14 @@ const makeHandlerKitHandler: H.Handler< | H.HttpResponse | H.HttpResponse, Env -> = H.of(() => +> = H.of((req: H.HttpRequest) => pipe( RTE.ask(), // validate request body - RTE.apSW("id", RTE.of(aTask.id)), + RTE.apSW( + "id", + RTE.fromEither(parsePathParameter(TaskIdCodec, "taskId")(req)), + ), // execute use case RTE.flatMap(({ id }) => deleteTask(id)), // handle result and prepare response