How to expose a cli
Unanswered
Sloth bear posted this in #help-forum
Sloth bearOP
So ive made this webiste, and it uses some ai promts to generate things. Id like to be able to test this via the command line (i dont want to test via some web interface). How can i expose a cli in a nexjs app? The project was created using create-t3-app.
It needs to run in the "same env" as the app does, since i dont want to reimplement any "buissnes" logic.
It needs to run in the "same env" as the app does, since i dont want to reimplement any "buissnes" logic.
13 Replies
@Sloth bear So ive made this webiste, and it uses some ai promts to generate things. Id like to be able to test this via the command line (i dont want to test via some web interface). How can i expose a cli in a nexjs app? The project was created using create-t3-app.
It needs to run in the "same env" as the app does, since i dont want to reimplement any "buissnes" logic.
Jersey Wooly
@Sloth bear I faced the same issue before. I suggest to extract your business logic into a shared module and then call it from both your Next.js app and a Node CLI entrypoint that runs in the same environment.
@Jersey Wooly <@973451621130465290> I faced the same issue before. I suggest to extract your business logic into a shared module and then call it from both your Next.js app and a Node CLI entrypoint that runs in the same environment.
Sloth bearOP
It runs a few db queries (using drizzle), is there some easy way to access it from a separate module? Or should that be extracted too?
Jersey Wooly
Yea it should be extracted but not so crazy. It's easy
You know Drizzle?
I don't remember exactly but ask drizzle to the google
that would be helpful
@Jersey Wooly You know Drizzle?
Sloth bearOP
Yeah but not all to well
Jersey Wooly
🙂
You can find how to use it here
Sloth bearOP
Thanks for the help :)
Jersey Wooly
🤛
My pleasure