2.0.5 • Published 2 days ago

@pagopa/handler-kit-azure-func v2.0.5

Weekly downloads
-
License
-
Repository
github
Last release
2 days ago

@pagopa/handler-kit-azure-func

@pagopa/handler-kit adapter for Azure Functions

How to use it

import { httpAzureFunction } from "@pagopa/handler-kit-azure-func";

// Given an Handler
// (from the @pagopa/handler README example)

const GetMovies = H.of((req: H.HttpRequest) =>
  pipe(
    req.body,
    // perform a refinement with io-ts, and returns a ValidationError
    // that represents a 422 HTTP response
    H.parse(GetMoviesBody),
    E.map(({ genre }) => genre),
    RTE.fromEither,
    RTE.chainW(getMoviesByGenre),
    RTE.map((movies) => ({ items: movies })),
    // wrap in a 200 HTTP response, with content-type JSON
    RTE.map(H.successJson),
    // converts Error instances to problem json (RFC 7807) objects
    RTE.orElseW(flow(H.toProblemJson, H.problemJson, RTE.of))
  )
);

// instead of wiring manually the dependencies

/*
GetMovies({
  input: ...,
  inputDecoder: ...,
  logger: ...,
  movies: ...
})*/

// just use "httpAzureFunction"

const GetMoviesFunction = httpAzureFunction(GetMovies)({
  movies,
});

// now GetMoviesFunction can be called by the Azure runtime

See the unit tests for other examples

2.0.5

2 days ago

2.0.4

18 days ago

2.0.3

1 month ago

2.0.2

1 month ago

1.2.1

4 months ago

2.0.1

6 months ago

2.0.0

6 months ago

1.2.0

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.0

1 year ago