I am a big fan of byebug, a powerful ruby debugger, and I was thrilled to know about the REPL server in the NestJS V9 release notes.
source: manshagraphics-Flaticon
The REPL server acts as a debugger for NestJS by launching an interactive server with all of the context required for your nest app. So you can basically interact with all of your methods directly.
To start the REPL server in your NestJS app,
Make a REPL entry file called
repl.ts
alongsidemain.ts
.Include your app module to the repl method in the
repl.ts
file.
// repl.ts
import { repl } from '@nestjs/core';
import { AppModule } from './app.module';
async function bootstrap() {
await repl(AppModule);
}
bootstrap();
- Launch your repl server using the below command,
npm run start -- --entryFile repl
It will initiate an interactive node server, from which you can easily access your nest app methods by getting them,
get(AppService).sayHelloWorld()
for more usage methods on REPL click here to read the official documentation.
Top comments (0)