nestjs-config-aws-ksm
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

Blackstone Studio - In Development We Trust

NestJS ConfigModule With AWS Secret Manager

Version Documentation Maintenance Built with NestJS

Table of Contents

Installation

Using npm:

npm install nestjs-config-aws-ksm

Using yarn:

yarn add nestjs-config-aws-ksm

Initialization

  1. Import ConfigModule in your module.
import { Module } from '@nestjs/common';
import { ConfigModule } from 'nestjs-config-aws-ksm';
import { NameService } from './name.service';

@Module({
  imports: [
    ConfigModule.register({
      accessKey: 'AWS_ACCESS_KEY',
      secretAccessKey: 'AWS_ACCESS_SECRET_KEY',
      region: 'AWS_REGION',
      storage: 'STORAGE_NAME'
    }),
  ],
  providers: :[NameService],
  exports: [NameService],
})

export class NameModule {}
  1. Import and use ConfigService in your Service.
import { Injectable } from '@nestjs/common';
import { ConfigService } from 'nestjs-config-aws-ksm';

@Injectable()
export class NameService {
  constructor(configService: ConfigService) {
    configService.get('SECRET_AWS_OR_ENV_VARIABLE');
  }
}

Notes

Given that the register method is asynchronous the variables may not be loaded yet. If you need to load it via registerAsync we recommend using the loadStorage method. Example:

import { Module } from '@nestjs/common';
import { ConfigModule } from 'nestjs-config-aws-ksm';
import { NameService } from './name.service';

@Module({
  imports: [
    JwtModule.registerAsync({
      imports: [ConfigModule.register({
        accessKey: 'AWS_ACCESS_KEY',
        secretAccessKey: 'AWS_ACCESS_SECRET_KEY',
        region: 'AWS_REGION',
        storage: 'STORAGE_NAME'
      })],
      useFactory: async (configService: ConfigService) => {
        await configService.loadStorage('STORAGE_NAME');
        return ({
          secret: configService.get('JWT_SECRET'),
          signOptions: { expiresIn: "72h" },
        })
      },
      inject: [ConfigService],
    }),
  ],
  providers: :[NameService],
  exports: [NameService],
})

export class NameModule {}

Who are we

We are the development partner of choice for several different sized companies who need a team that delivers fast & scalable code understanding users needs and commercial scope.

Our services

  • Website development
  • UX/UI Design
  • Webapp Development
  • Mobile Development
  • Ecommerce
  • Specialized enterprise software
  • Legacy migrations, debugging and refactors

Why us?

We don't outsource a single thing. Each wireframe, design and every piece of code is written with outmost care by Blackstone's diverse teams.

🛠 Built With

🤝 Contributing

Contributions, issues and feature requests are welcome!

You can also suggest a new feature by creating an Issue. Please wait for confirmation before working on it.

📝 License

Copyright © 2020 Blackstone Studio.

This project is MIT licensed.

We are blackstone - Contact us

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.50latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.50
1.0.40
1.0.30
1.0.10
1.0.00

Package Sidebar

Install

npm i nestjs-config-aws-ksm

Weekly Downloads

0

Version

1.0.5

License

MIT

Unpacked Size

23.6 kB

Total Files

32

Last publish

Collaborators

  • orlandolml
  • estefaniagtz
  • joseordorica
  • nishikawa7863
  • aleexsolis