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

1.0.2 • Public • Published

@schnellert/nest-aws-sqs

Simple nest aws sqs client

Help:

https://discord.dgs4ops.ch

Getting started

Installation

PNPM

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

NPM

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

YARN

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

Example 'forRoot'

import { AwsSQSModule } from "@schnellert/nest-aws-sqs";
import { Module } from "@nestjs/common";

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

Example 'forRootAsync' with nest.js config service:

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

@Module({
  imports: [
    ConfigModule.forRoot(),
    AwsSQSModule.forRootAsync(AwsSQSModule, {
      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 sqs client:

import { SQSClient } from "@aws-sdk/client-sqs";
import { InjectAwsSQSClient } from "@schnellert/nest-aws-sqs";
import { Injectable } from "@nestjs/common";

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

Readme

Keywords

Package Sidebar

Install

npm i @schnellert/nest-aws-sqs

Weekly Downloads

3

Version

1.0.2

License

MIT

Unpacked Size

158 kB

Total Files

15

Last publish

Collaborators

  • felix.schnellert