Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
@aws-sdk/util-create-request
Advanced tools
[![NPM version](https://img.shields.io/npm/v/@aws-sdk/util-create-request/beta.svg)](https://www.npmjs.com/package/@aws-sdk/util-create-request) [![NPM downloads](https://img.shields.io/npm/dm/@aws-sdk/util-create-request.svg)](https://www.npmjs.com/packa
This package provides function to create request object from given client and command. You can supply either Node client or browser client. A common use case for it can be generating request object and then supply to presigners to create presigned url.
When calling the createRequest()
, the initialize
and serialize
middlewares
from both client and command are extracted and resolved into a handler. This handler
will return a promise of HttpRequest
object. So any modifications happen in build
and finalize
middleware won't be reflected to generated httpRequest
object. For
example, the Content-Length
header won't be included in the result.
Import:
//JavaScript:
const createRequest = require("@aws-sdk/util-create-request").createRequest;
//TypeScript:
import { createRequest } from "@aws-sdk/util-create-request";
JavaScript usage examples:
const S3Client = require("@aws-sdk/client-s3-node/S3Client").S3Client;
const GetObject = require("@aws-sdk/client-s3-node/commands/GetObjectCommand").GetObjectCommand;
const request = await createRequest(
new S3Client({}),
new GetObject({
Bucket: "bucket",
Key: "key",
})
);
/**
{
protocol: 'https:',
path: '/js-sdk-test-bucket/key',
hostname: 's3.us-east-2.amazonaws.com',
body: null,
headers: {},
method: 'GET',
query: {}
}
*/
TypeScript usage example:
import { S3Client } from "@aws-sdk/client-s3-node/S3Client";
import { GetObjectCommand } from "@aws-sdk/client-s3-node/commands/GetObjectCommand";
import { InputTypesUnion, GetObjectInput } from "@aws-sdk/client-s3-node/types";
import { Readable } from "stream";
const request = await createRequest<InputTypesUnion, GetObjectInput, Readable>(
new S3Client({}),
new GetObjectCommand({
Bucket: "bucket",
Key: "key",
})
);
You can omit the generics in this function and rely on the type inference. In this way you will lose the type safety for insuring client and command comes from the same service.
import { DynamoDBClient } from "@aws-sdk/client-dynamodb-node/DynamoDBClient";
import { GetObjectCommand } from "@aws-sdk/client-s3-node/commands/GetObjectCommand";
/*THIS IS WRONG, but TypeScript won't tell you*/
const request = await createRequest(
new DynamoDBClient({}),
new GetObjectCommand({
Bucket: "bucket",
Key: "key",
})
);
FAQs
[![NPM version](https://img.shields.io/npm/v/@aws-sdk/util-create-request/latest.svg)](https://www.npmjs.com/package/@aws-sdk/util-create-request) [![NPM downloads](https://img.shields.io/npm/dm/@aws-sdk/util-create-request.svg)](https://www.npmjs.com/pac
The npm package @aws-sdk/util-create-request receives a total of 244,054 weekly downloads. As such, @aws-sdk/util-create-request popularity was classified as popular.
We found that @aws-sdk/util-create-request demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 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
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.