Socket
Socket
Sign inDemoInstall

@middy/util

Package Overview
Dependencies
0
Maintainers
3
Versions
128
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@middy/util


Version published
Weekly downloads
317K
decreased by-7.87%
Maintainers
3
Created
Weekly downloads
 

Package description

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

Readme

Source

Middy Utilities

Middy logo

Util component of the middy middleware, the stylish Node.js middleware engine for AWS Lambda

npm version npm install size GitHub Actions CI status badge
Standard Code Style Known Vulnerabilities CodeQL Core Infrastructure Initiative (CII) Best Practices
Chat on Gitter Ask questions on StackOverflow

You can read the documentation at: https://middy.js.org/docs/intro/utilities

License

Licensed under MIT License. Copyright (c) 2017-2023 Luciano Mammino, will Farrell, and the Middy team.

FOSSA Status

Keywords

FAQs

Last updated on 11 Nov 2023

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc