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

1.0.8 • Public • Published

@schnellert/nest-aws-s3

Simple nest aws s3 client

Help:

https://discord.dgs4ops.ch

Getting started

Installation

PNPM

  • Install the package along with the aws s3 client peer dependency pnpm install @schnellert/nest-aws-s3 @aws-sdk/client-s3

NPM

  • Install the package along with the aws s3 client peer dependency npm install @schnellert/nest-aws-s3 @aws-sdk/client-s3

YARN

  • Install the package along with the aws s3 client peer dependency yarn add @schnellert/nest-aws-s3 @aws-sdk/client-s3

Example 'forRoot'

import { AwsS3Module } from "@schnellert/nest-aws-s3";
import { Module } from "@nestjs/common";

@Module({
  imports: [
    AwsS3Module.forRoot(AwsS3Module, {
      credentials: {
        secretAccessKey: "<secretAccessKey>",
        accessKeyId: "<accessKeyId>",
      },
    }),
  ],
})
export class AppModule {}

Example 'forRootAsync' with nest.js config service:

import { ConfigModule, ConfigService } from "@nestjs/config";
import { AwsS3Module } from "@schnellert/nest-aws-s3";
import { Module } from "@nestjs/common";

@Module({
  imports: [
    ConfigModule.forRoot(),
    AwsS3Module.forRootAsync(AwsS3Module, {
      useFactory: (configService: ConfigService) => {
        return {
          credentials: {
            secretAccessKey: configService.getOrThrow("AWS_SECRET_ACCESS_KEY"),
            accessKeyId: configService.getOrThrow("AWS_ACCESS_KEY_ID"),
          },
        };
      },
      inject: [ConfigService],
    }),
  ],
})
export class AppModule {}

Inject aws s3 client:

import { S3Client } from "@aws-sdk/client-s3";
import { InjectAwsS3Client } from "@schnellert/nest-aws-s3";
import { Injectable } from "@nestjs/common";

@Injectable()
export class AppService {
  constructor(@InjectAwsS3Client() private readonly client: S3Client) {
    // ...
  }
}

Readme

Keywords

Package Sidebar

Install

npm i @schnellert/nest-aws-s3

Weekly Downloads

9

Version

1.0.8

License

MIT

Unpacked Size

408 kB

Total Files

43

Last publish

Collaborators

  • felix.schnellert