# nest-aws

> AWS Module for Nest.js

Latest version **1.0.0-alpha.0** (published 2020-07-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install nest-aws
pnpm add nest-aws
yarn add nest-aws
bun add nest-aws
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0-alpha.0 |
| Published | 2020-07-12 |
| First published | 2020-07-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 18.8 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | asomethings |
| Maintainers | asomethings |

## Links

- npm: https://www.npmjs.com/package/nest-aws
- Repository: https://github.com/asomethings/nest-aws
- Homepage: https://github.com/asomethings/nest-aws#readme
- Issues: https://github.com/asomethings/nest-aws/issues
- npm.io page: https://npm.io/package/nest-aws

## Dependencies (1)

- [aws-sdk](https://npm.io/package/aws-sdk.md) ^2.713.0

## Recent versions

- 1.0.0-alpha.0 (latest) — 2020-07-12
- 1.0.0-alpha.1 (alpha) — 2020-07-27

## README

<p align="center">
  <a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo_text.svg" width="320" alt="Nest Logo" /></a>
</p>

## Description

**Alpha Release: Use it with caution**


AWS Module for Nest.js framework


## Installation

NPM

```
npm i --save nest-aws
```

Yarn

```
yarn add nest-aws
```

## Usage

Import AwsModule into root AwsModule

```typescript
@Module({
  imports: [
    AwsModule.forRoot({
      region: 'ap-northeast-2'
      accessKeyId: 'your-aws-access-key',
      secretAccessKeyId: 'your-aws-secret-key',
    }),
  ],
  providers: [...],
})
export class AppModule {}
```

Define AWS Services that you wan't to use

```typescript
import { S3, SES } from 'aws-sdk'

@Module({
  imports: [
    AwsModule.forFeature(S3, SES),
  ],
  providers: [...],
})
export class AppModule {}
```

Now, inject S3 and SES with InjectAwsService

```typescript
@Injectable()
export class UserService {
  constructor(
    @InjectAwsService(S3)
    private readonly s3: S3,
    @InjectAwsService(SES)
    private readonly ses: SES,
  ) {}
}
```

All AWS Services will be initiated with settings that you have provided in `forRoot`

## Options

```typescript
AwsModule.forRoot({
  // AWS Region (Optional)
  region: '',


  // AWS Access Key Id (Optional)
  accessKeyId: '...',

  // AWS Secret Access Key Id (Optional)
  secretAccessKeyId: '...',
}),
```

## Async Options

1. Use factory

```typescript
AwsModule.forRootAsync({
  useFactory: () => ({
    region: 'ap-northeast-2',
  }),
})
```

OR

```typescript
AwsModule.forRootAsync({
  imports: [ConfigModule],
  useFactory: (configService: ConfigService) => ({
    accessKeyId: configService.get('accessKeyId'),
    secretAccessKeyId: configService.get('secretAccessKeyId'),
  }),
  inject: [ConfigService],
})
```

2. Use Class

```typescript
AwsModule.forRootAsync({
  useClass: AwsConfigService
})
```

```typescript
class AwsConfigService implements AwsOptionsFactory {
  createAwsOptions(): Promise<AwsModuleOptions> | AwsModuleOptions {
    return {
      region: 'ap-northeast-2',
    }
  }
}
```

3. Use existing

```typescript
AwsModule.forRootAsync({
  imports: [ConfigModule],
  useExisting: ConfigService,
})

```

## TODO

- [ ] Write Tests
- [ ] Support More Options
- [ ] Seperate AwsModule with AwsCoreModule (Like @nestjs/typeorm)

---
_Source: https://npm.io/package/nest-aws · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
