@invisit/nest-repl

Command line repl module for nestjs applications


License
MIT
Install
npm install @invisit/nest-repl@1.0.9

Documentation

@invisit/nest-repl

REPL: Interact with Nest Services, Controllers, Providers, Modules, etc in a Simple Interactive Repo

Simple library for NestJS to interact with your runtime env to make development inside of the Nest ecosystem easy to debug

Quickstart

To get started, install dependencies:

yarn add @invisit/nest-repl
# OR - dev only

A simple example

import { Injectable, Module } from "@nestjs/common"
import * as _ from "lodash"
import * as Prelude from "@3fv/prelude-ts"

import { NestReplModule } from "@invisit/nest-repl"
import { NestApplication, NestFactory } from "@nestjs/core"

const log = console.log.bind(console)

@Module({
  imports: [
    NestReplModule.register({
      // Optionally, you can configured the repl to not autostart, up to u
      // autostart: false // default is autostart=true
      prompt: "InvisitREPL >>",
      context: {
        mainGlobal: global,
        Lodash: _,
        Prelude
      }
    })
  ]
})
export class SimpleReplExampleModule {}

/**
 * Boilerplate cli below
 */ 
async function run() {
  const app = await NestFactory.create<NestApplication>(SimpleReplExampleModule,{})
  await app.init()

  // If autostart = false - by default autostart=true so this is not needed
  // const repl = await app.resolve(NodeRepl)
  // await repl.start()
}

run().catch(err => {
  console.error(`Failed to run SimpleReplExample`, err)
})