@effect-aws/client-s3
TypeScript icon, indicating that this package has built-in type declarations

1.3.0 • Public • Published

@effect-aws/client-s3

Installation

npm install --save @effect-aws/client-s3

Usage

With default S3Client instance:

import { S3Service, DefaultS3ServiceLayer } from "@effect-aws/client-s3";

const program = Effect.flatMap(S3Service, (s3) => s3.headObject(args));

const result = pipe(
  program,
  Effect.provide(DefaultS3ServiceLayer),
  Effect.runPromise,
);

With custom S3Client instance:

import {
  S3Service,
  BaseS3ServiceLayer,
  S3ClientInstance,
} from "@effect-aws/client-s3";

const program = Effect.flatMap(S3Service, (s3) => s3.headObject(args));

const S3ClientInstanceLayer = Layer.succeed(
  S3ClientInstance,
  new S3Client({ region: "eu-central-1" }),
);

const result = await pipe(
  program,
  Effect.provide(BaseS3ServiceLayer),
  Effect.provide(S3ClientInstanceLayer),
  Effect.runPromise,
);

With custom S3Client configuration:

import {
  S3Service,
  BaseS3ServiceLayer,
  DefaultS3ClientConfigLayer,
  S3ClientInstance,
  S3ClientInstanceConfig,
} from "@effect-aws/client-s3";

const program = Effect.flatMap(S3Service, (s3) => s3.headObject(args));

const S3ClientInstanceLayer = Layer.provide(
  Layer.effect(
    S3ClientInstance,
    S3ClientInstanceConfig.pipe(
      Effect.map(
        (config) => new S3Client({ ...config, region: "eu-central-1" }),
      ),
    ),
  ),
  DefaultS3ClientConfigLayer,
);

const result = await pipe(
  program,
  Effect.provide(BaseS3ServiceLayer),
  Effect.provide(S3ClientInstanceLayer),
  Effect.runPromiseExit,
);

or map over DefaultS3ClientConfigLayer layer context and update the configuration...

Readme

Keywords

none

Package Sidebar

Install

npm i @effect-aws/client-s3

Weekly Downloads

769

Version

1.3.0

License

MIT

Unpacked Size

220 kB

Total Files

21

Last publish

Collaborators

  • f1oyd