phero-hq / phero

Full-stack type-safety with pure TypeScript

Home Page:https://phero.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

programmatic server start

uplight-dev opened this issue · comments

I'm using a backend and a set of microservices. I'd like to use phero for communication.

Problem is I'd like to start phero server in same process space as my microservice.
Also I'm using pm2 to start services. Having a programmatic way to start a phero server would allow phero code to run under a pm2 process more naturally.
This way you'd be able to spawn multiple phero servers under same nodejs process and share state, etc.

Is it possible to start a phero.ts file programmatically instead of relying on the CLI?

any feedback?

Hey @uplight-dev sorry for my late response.

What you’re asking is currently not possible. But how about the following setup:

You can define multiple services inside you phero.ts file. Each service would be a “microservice” with their own middlewares. You can even have multiple phero.ts files if that makes more sense. This helps dividing your services in separate directories. All these services will run in the same process.

hope this helps!