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

nestjs-console

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nestjs-console

A NestJS module that provide a cli

  • 0.1.2
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

nestjs-console

NestJS Console is a module that provide a cli. A ready to use service class for your module that exposes the required methods to register commands and sub commands using the npm package commander

Install

npm install nestjs-console
# or unig yarn
yarn install nestjs-console

Prepare the cli endpoint

Create a file next to main.ts named console.ts
Import your app module or any module you want to be loaded. Usually this is your main nestjs module.

import { bootstrap } from 'nestjs-console';
import { AppModule } from './bundles/app';

bootstrap(AppModule, { logger: false }).catch(e => console.log('Error', e));

Usage

Import the ConsoleModule inside your module

// module.ts
import { Module } from '@nestjs/common';
import { ConsoleModule } from 'nestjs-console';
import { MyService } from './service';

@Module({
    imports: [
        ConsoleModule // Import the module where you need it
    ],
    exports: [MyService]
})
export class MyModule {}

You can now inject the ConsoleService inside any nestjs providers, controllers...

// service.ts
import { Injectable } from '@nestjs/common';
import { ConsoleService } from 'nestjs-console';

@Injectable()
export class MyService {
    constructor(private readonly consoleService: ConsoleService) {
        this.consoleService
            .getCli()
            .command('mycommand')
            .options('-a, --all', 'an exemple of options')
            .action(this.myCommand.bind(this));
    }

    myCommand(options) {
        //See Ora npm package for details about spinner
        const spin = this.consoleService.createSpinner();
        spin.start();
        // DO SOME WORK
        spin.stop();
    }
}

Documentation

A typedoc is generated and available on github https://pop-code.github.io/nestjs-console

FAQs

Package last updated on 06 Mar 2019

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