nestjs-clamscan

    1.0.1 • Public • Published

    Nestjs-clamscan

    NPM

    npm version total downloads of badging badging's License star github.com/YounGoat/nodejs.badging

    A ClamAV client on nest.js

    The library uses TCP socket communicate with clamd (ClamAV daemon) through some commands

    Clamd protocol is explained here: http://linux.die.net/man/8/clamd

    Run the Docker ClamAV daemon

    $ docker run --name clamav -d -p 3310:3310 quay.io/ukhomeofficedigital/clamav:latest

    Installation

    $ npm install nestjs-clamscan

    Usage

    Intialize Module

    import { Module } from '@nestjs/common';
    import { AppController } from './app.controller';
    import { ClamscanModule, ClamScanOptions } from 'nestjs-clamscan';
     
    const options: ClamScanOptions = {
      host: process.env.HOST || '127.0.0.1',
      port: Number(process.env.PORT) || 3310,
    }
     
    @Module({
      imports: [ClamscanModule.forRoot(options)],
      controllers: [AppController]
    })
    export class AppModule {}
     

    Intialize Service

    import { Controller, Get } from '@nestjs/common';
    import { ClamScanService } from 'nestjs-clamscan';
     
    @Controller()
    export class AppController {
      constructor(
        private readonly clamScanService: ClamScanService
      ) {
      }
     
      @Get()
      getVersion(): Promise<string> {
        return this.clamScanService.version();
      }
     
      @Get('/scan-infected')
      async scanInfected(): Promise<boolean> {
        return this.clamScanService.scanFile(__dirname + '/files/test.virus.txt');
      }
     
      @Get('/scan-safe')
      async scanSafe(): Promise<boolean> {
        return this.clamScanService.scanFile(__dirname + '/files/test.safe.txt');
      }
     
      @Get('/scan-directory')
      async scanDirectory(): Promise<ClamScanDirectoryResult> {
        return this.clamScanService.scanDirectory(__dirname + '/files', {
          timeout: 5000,
          chunkSize: 64 * 1024,
          scanningFile: 10,
          detail: true,
          cont: true
        });
      }
    }
     

    Install

    npm i nestjs-clamscan

    DownloadsWeekly Downloads

    3

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    430 kB

    Total Files

    44

    Last publish

    Collaborators

    • kaushiksamanta23