Socket
Socket
Sign inDemoInstall

@smithy/middleware-endpoint

Package Overview
Dependencies
7
Maintainers
2
Versions
43
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@smithy/middleware-endpoint


Version published
Maintainers
2
Install size
538 kB
Created

Package description

What is @smithy/middleware-endpoint?

@smithy/middleware-endpoint is a middleware package for the AWS SDK for JavaScript (v3) that helps in resolving and customizing endpoints for service clients. It allows developers to modify endpoint resolution logic, making it easier to direct requests to different endpoints based on custom logic or configuration.

What are @smithy/middleware-endpoint's main functionalities?

Custom Endpoint Resolution

This feature allows you to customize the endpoint resolution logic. In this example, the middleware modifies the request's hostname to a custom endpoint before passing it to the next middleware in the stack.

const { EndpointMiddleware } = require('@smithy/middleware-endpoint');
const { HttpRequest } = require('@smithy/protocol-http');

const customEndpointMiddleware = (next, context) => async (args) => {
  const request = args.request;
  if (HttpRequest.isInstance(request)) {
    request.hostname = 'custom-endpoint.example.com';
  }
  return next({ ...args, request });
};

// Usage in a client configuration
const client = new SomeAWSClient({
  region: 'us-west-2',
  middlewareStack: [customEndpointMiddleware]
});

Conditional Endpoint Resolution

This feature allows you to conditionally resolve endpoints based on the operation being performed. In this example, the middleware changes the endpoint only for the 'GetItem' operation.

const { EndpointMiddleware } = require('@smithy/middleware-endpoint');
const { HttpRequest } = require('@smithy/protocol-http');

const conditionalEndpointMiddleware = (next, context) => async (args) => {
  const request = args.request;
  if (HttpRequest.isInstance(request) && context.operationName === 'GetItem') {
    request.hostname = 'get-item-endpoint.example.com';
  }
  return next({ ...args, request });
};

// Usage in a client configuration
const client = new SomeAWSClient({
  region: 'us-west-2',
  middlewareStack: [conditionalEndpointMiddleware]
});

Other packages similar to @smithy/middleware-endpoint

Readme

Source

@smithy/middleware-endpoint

NPM version NPM downloads

An internal package

Usage

You probably shouldn't, at least directly.

FAQs

Last updated on 05 Dec 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