Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@byndyusoft/nest-dynamic-module

Package Overview
Dependencies
Maintainers
4
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@byndyusoft/nest-dynamic-module

DynamicModule helper for NestJS

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
32
decreased by-8.57%
Maintainers
4
Weekly downloads
 
Created
Source

nest-dynamic-module

npm@latest test workflow code style: prettier semantic-release

DynamicModule helper for NestJS

Requirements

  • Node.js v12 LTS or later
  • npm or yarn

Install

npm install @byndyusoft/nest-dynamic-module

or

yarn add @byndyusoft/nest-dynamic-module

Usage

Example usage:

import {
  DynamicModuleHelper,
  TRegisterAsyncOptions,
} from "@byndyusoft/nest-dynamic-module";
import { DynamicModule, Inject, Injectable, Module } from "@nestjs/common";

class ExampleOptionsDto {
  public readonly connectionString!: string;
}

const EXAMPLE_OPTIONS_TOKEN = Symbol("EXAMPLE_OPTIONS_TOKEN");

@Injectable()
class ExampleProvider {
  public constructor(
    @Inject(EXAMPLE_OPTIONS_TOKEN)
    options: ExampleOptionsDto,
  ) {
    console.log(options.connectionString);
  }
}

@Module({})
class ExampleModule {
  public static registerAsync(
    options?: TRegisterAsyncOptions<ExampleOptionsDto>,
  ): DynamicModule {
    return DynamicModuleHelper.registerAsync(
      {
        module: ExampleModule,
        global: true,
        providers: [ExampleProvider],
        exports: [ExampleProvider],
      },
      EXAMPLE_OPTIONS_TOKEN,
      options,
    );
  }
}

class ConfigDto {
  public readonly exampleOptions!: ExampleOptionsDto;
}

@Module({
  imports: [
    ExampleModule.registerAsync({
      inject: [ConfigDto],
      useFactory: (config: ConfigDto) => config.exampleOptions,
    }),
  ],
})
class AppModule {}

Maintainers

License

This repository is released under version 2.0 of the Apache License.

FAQs

Package last updated on 30 Sep 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc