Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
@middy/util
Advanced tools
@middy/util is a utility package that provides a set of helper functions and middlewares to simplify the development of AWS Lambda functions. It is part of the Middy middleware engine, which allows you to compose reusable middleware for your Lambda functions.
createError
The `createError` function helps in creating HTTP errors with a specified status code and message. This is useful for handling errors in a standardized way in your Lambda functions.
const { createError } = require('@middy/util');
const error = createError(400, 'Bad Request');
console.log(error);
jsonSafeParse
The `jsonSafeParse` function safely parses a JSON string into an object. If the string is not valid JSON, it returns `null` instead of throwing an error.
const { jsonSafeParse } = require('@middy/util');
const jsonString = '{"key": "value"}';
const parsedObject = jsonSafeParse(jsonString);
console.log(parsedObject);
normalizeHttpResponse
The `normalizeHttpResponse` function ensures that the HTTP response object conforms to the expected format, making it easier to handle responses in a consistent manner.
const { normalizeHttpResponse } = require('@middy/util');
const response = { statusCode: 200, body: 'Success' };
const normalizedResponse = normalizeHttpResponse(response);
console.log(normalizedResponse);
The `aws-lambda-middleware` package provides a collection of middleware functions for AWS Lambda. It offers similar functionalities to @middy/util, such as error handling and response normalization, but it is not as comprehensive in terms of utility functions.
The `lambda-middleware` package is another alternative that provides middleware for AWS Lambda functions. It focuses on simplifying common tasks like input validation, error handling, and response formatting, similar to @middy/util.
The `lambda-api` package is designed to help build RESTful APIs using AWS Lambda. It includes middleware support and offers functionalities like routing, error handling, and response formatting, making it a good alternative to @middy/util for API development.
Util component of the middy middleware, the stylish Node.js middleware engine for AWS Lambda
You can read the documentation at: https://middy.js.org/docs/intro/utilities
Licensed under MIT License. Copyright (c) 2017-2023 Luciano Mammino, will Farrell, and the Middy team.
FAQs
🛵 The stylish Node.js middleware engine for AWS Lambda (util package)
The npm package @middy/util receives a total of 195,522 weekly downloads. As such, @middy/util popularity was classified as popular.
We found that @middy/util demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.