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

nestjs-mux

Package Overview
Dependencies
Maintainers
3
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nestjs-mux

Mux module for NestJS.

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
increased by100%
Maintainers
3
Weekly downloads
 
Created
Source

nestjs-mux

Mux module that provides standardized setup and dependency injection in a Nest project for the Mux API client.

Installation

Yarn

yarn add nestjs-mux

npm

npm install nestjs-mux --save

Getting Started

Configuration

Import and configure MuxModule with Mux's access and secret tokens into the root module AppModule.

import { Module } from '@nestjs/common';
import { MuxModule } from 'nestjs-mux';

@Module({
  imports: [
    MuxModule.forRoot({
      id: idToken,
      secret: secretToken,
    }),
  ],
})
export default class AppModule {}
Asynchronous

If you need to load the configuration options asynchronously you can use the following options:

Use Factory Function
import { Module } from '@nestjs/common';
import { MuxModule } from 'nestjs-mux';
import { ConfigModule } from './config/config.module';
import { ConfigService } from './config/config.service';

@Module({
  imports: [
    MuxModule.forRootAsync({
      imports: [ConfigModule],
      useFactory: (configService: ConfigService) => ({
        id: configService.getString('MUX_ID_TOKEN'),
        secret: configService.getString('MUX_SECRET_TOKEN'),
      }),
      inject: [ConfigService],
    }),
  ],
})
export class AppModule {}
Use Class
import { Module } from '@nestjs/common';
import { MuxModule } from 'nestjs-mux';
import { MuxConfigService } from './config/mux.config.service';

@Module({
  imports: [
    MuxModule.forRootAsync({
      useClass: MuxConfigService,
    }),
  ],
})
export class AppModule {}
Use Existing
import { Module } from '@nestjs/common';
import { MuxModule } from 'nestjs-mux';
import { ConfigModule } from './config/config.module';
import { ConfigService } from './config/mux.config.service';

@Module({
  imports: [
    MuxModule.forRootAsync({
      imports: [ConfigModule],
      useExisting: ConfigService,
    }),
  ],
})
export class AppModule {}

Usage

You can then inject the Mux client into constructors with its decorator.

import * as Mux from '@mux/mux-node';
import { Injectable } from '@nestjs/common';
import { InjectMux } from 'nestjs-mux';

@Injectable()
export default class AppService {
  public constructor(@InjectMux() private readonly muxClient: Mux) {}
}

Keywords

FAQs

Package last updated on 26 May 2020

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