Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@middy/util
Advanced tools
🛵 The stylish Node.js middleware engine for AWS Lambda (util package)
@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-2024 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 225,948 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 0 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.