Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@middy/util

Package Overview
Dependencies
Maintainers
3
Versions
136
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)

  • 2.0.0-alpha.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
235K
decreased by-28.55%
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

FAQs

Package last updated on 24 Jan 2021

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc