有没有一种方法可以使用NestJS的命令来执行服务的方法?

huangapple go评论66阅读模式
英文:

Is there a way to execute a method of a service using a command with nestjs?

问题

我需要执行一个服务的方法,而不使用 REST API,也就是通过单个执行命令来执行它。

英文:

I need to execute a method of a service without using api rest, that is, execute it through a single execution command

答案1

得分: 1

看起来你想要构建一个命令行界面(CLI)或者只是一个脚本。这在NestJS独立应用程序中是可行的,就像任何Node.js应用程序一样,文档在这里:https://docs.nestjs.com/standalone-applications

你也可以使用第三方包像 nest-commander,文档在这里:https://docs.nestjs.com/recipes/nest-commander

我建议你深入阅读官方文档。

英文:

looks like you want to build a command line interface (CLI) or just a script. This is feasible with nestjs standalone app like any nodejs app, as the docs shows here: https://docs.nestjs.com/standalone-applications

you can also use a 3rd-party package like nest-commander, as the docs shows here: https://docs.nestjs.com/recipes/nest-commander

I suggest you to dive into the official docs.

huangapple
  • 本文由 发表于 2023年5月21日 06:43:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/76297605.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定