NestJS → Postman collection

The usual route from NestJS to Postman goes through @nestjs/swagger: install it, decorate the DTOs, boot the app, export the JSON, import it. routeman-cli reads your controllers and DTOs directly and skips all of that. You don't need decorators, a build or a running app.

$ npx routeman-cli

What routeman-cli reads from a NestJS app

Example

// src/main.ts
const app = await NestFactory.create(AppModule);
app.setGlobalPrefix('api');
app.enableVersioning({ type: VersioningType.URI, defaultVersion: '1' });
await app.listen(3000);

// src/app.module.ts
@Module({
  controllers: [AuthController, ProductsController],
  providers: [{ provide: APP_GUARD, useClass: JwtAuthGuard }],
})
export class AppModule {}

// src/products/product.dto.ts
export class CreateProductDto {
  @IsString() @Length(3, 120) name: string;
  @IsNumber() @Min(1) price: number;
  @IsEnum(Category) category: Category;
  @IsInt() @Min(0) @Max(10000) stock: number;
  @IsOptional() @IsString() description?: string;
}
export class UpdateProductDto extends PartialType(CreateProductDto) {}

// src/auth/auth.controller.ts
@Controller('auth')
export class AuthController {
  /** Exchange email and password for an access token */
  @Public()
  @Post('login')
  login(@Body() dto: LoginDto) { ... }

  /** The signed-in user */
  @Get('me')
  me(@Req() req) { ... }
}

// src/products/products.controller.ts
@Controller('products')
export class ProductsController {
  @Public() @Get()
  findAll(@Query('page') page?: number, @Query('q') q?: string) { ... }

  @Public() @Get(':id')
  findOne(@Param('id', ParseIntPipe) id: number) { ... }

  @Post()
  create(@Body() dto: CreateProductDto) { ... }

  @Patch(':id')
  update(@Param('id', ParseIntPipe) id: number, @Body() dto: UpdateProductDto) { ... }

  @Post(':id/image')
  @UseInterceptors(FileInterceptor('file'))
  upload(@Param('id', ParseIntPipe) id: number, @UploadedFile() file) { ... }

  @Delete(':id')
  remove(@Param('id', ParseIntPipe) id: number) { ... }
}
$ npx routeman-cli
✓ nest: 8 requests (3 POST, 3 GET, 1 PATCH, 1 DELETE)
✓ auth: bearer (login: POST /api/v1/auth/login)
✓ wrote postman/nest-shop-api.postman_collection.json
✓ wrote postman/nest-shop-api.local.postman_environment.json
  done in 0.07s - import the files in Postman (File → Import)

$ npx routeman-cli routes
POST    /api/v1/auth/login             json: email, password
GET     /api/v1/auth/me              🔒
GET     /api/v1/products
POST    /api/v1/products             🔒 json: name, price, category, stock, description
DELETE  /api/v1/products/{id}        🔒
GET     /api/v1/products/{id}
PATCH   /api/v1/products/{id}        🔒 json: name, price, category, stock, description
POST    /api/v1/products/{id}/image  🔒 form: file
8 routes, auth: bearer (login: POST /api/v1/auth/login)

This is real output from routeman-cli 0.1.0. Notice what it put together:

Already using @nestjs/swagger?

routeman-cli reads @ApiProperty and @ApiOperation when they're present, so you lose nothing. You can also build from the spec your app serves: npx routeman-cli --openapi http://localhost:3000/docs-json. Building from the code means no running app and no forgotten decorators.

Full walkthrough: NestJS to Postman without @nestjs/swagger.

Read the Node.js docs