@house-of-angular/nestjs-streaming
TypeScript icon, indicating that this package has built-in type declarations

0.3.0 • Public • Published

@house-of-angular/nestjs-streaming

version downloads

Useful providers that allows working with streaming like responses

Installation

npm install --save-dev @house-of-angular/nestjs-streaming

Available modules

  • DownloadExpressModule
  • StreamingExpressModule
  • UrlStreamerNativeModule

Usage

Download nad Streaming modules provide services that pass your stream as a response and set headers appropriate for each case.

UrlStreamer provide a service that allows you to easily get the url as a stream.

Example

app.controller.ts

import { Controller, Get, Inject, Res } from '@nestjs/common';
import {
  ResponseStreamerFactory,
  responseStreamerFactoryToken,
  StreamingType
} from '@house-of-angular/nestjs-streaming';

@Controller()
export class AppController {
  constructor(
    @Inject(responseStreamerFactoryToken)
    private responseStreamerFactory: ResponseStreamerFactory
  ) {}

  @Get('')
  async downloadFile(@Res() res): Promise<void> {
    return this.responseStreamerFactory(StreamingType.Full, res).stream({
      contentType: 'application/png',
      size: 1024,
      stream: () => fs.createReadStream('file.png')
    });
  }
}

app.module.ts

import { Module } from '@nestjs/common';
import { DownloadExpressModule } from '@house-of-angular/nestjs-streaming';
import { AppController } from './app.controller';

@Module({
  imports: [DownloadExpressModule],
  controllers: [AppController]
})
export class AppModule {}

Readme

Keywords

Package Sidebar

Install

npm i @house-of-angular/nestjs-streaming

Weekly Downloads

1

Version

0.3.0

License

MIT

Unpacked Size

38.3 kB

Total Files

58

Last publish

Collaborators

  • mateusz-dobrowolski-va
  • krzysztofskorupkadev
  • mateusz.stefanczyk
  • mateuszbasinski-va
  • adam.bartoszko
  • kordrad