🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

@middy/util

Package Overview
Dependencies
Maintainers
3
Versions
150
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@middy/util

🛵 The stylish Node.js middleware engine for AWS Lambda (util package)

6.3.0
latest
Source
npm
Version published
Weekly downloads
336K
-0.49%
Maintainers
3
Weekly downloads
 
Created

What is @middy/util?

@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.

What are @middy/util's main functionalities?

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);

Other packages similar to @middy/util

Keywords

Lambda

FAQs

Package last updated on 13 May 2025

Did you know?

Socket

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.

Install

Related posts