
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
nestjs-console
Advanced tools
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
npm install nestjs-console
# or unig yarn
yarn install nestjs-console
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.
// console.ts
import { bootstrap } from 'nestjs-console';
import { MyAppModule } from './my.application.module';
bootstrap(MyAppModule, { logger: false }).catch(e => console.log('Error', e));
An example of nestjs module that import the ConsoleModule
// module.ts
import { Module } from '@nestjs/common';
import { ConsoleModule } from 'nestjs-console';
import { MyService } from './service';
@Module({
imports: [
ConsoleModule
],
providers: [MyService]
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
console.log(options.all);
spin.stop();
}
}
Add scripts in your package.json (Only if you want to use them)
{
"scripts": {
"console:dev": "ts-node -r tsconfig-paths/register src/console.ts",
"console": "node lib/console.js"
}
}
Usage from cli (we suppose your app was built in the lib forlder)
# direct call
node lib/console.js --help
# using npm
npm run console -- --help
# using yarn
yarn run console --help
# during dev you can call the console using ts-node
yarn run console:dev --help
A typedoc is generated and available on github https://pop-code.github.io/nestjs-console
FAQs
A NestJS module that provide a cli
The npm package nestjs-console receives a total of 19,831 weekly downloads. As such, nestjs-console popularity was classified as popular.
We found that nestjs-console demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.