1

I have in mind a custom schematic that I will use in coordination with "ng serve" that would automatically launch a helper microservice written in Node at the same time. Is this possible to do within a schematic, or do I need to launch it manually first, then serve the Angular app?

For context, this is going to be a tool used during the development of an Angular app, so both the Node microservice and the Angular app will be hosted on the same server, just with different port numbers.

I've tried searching Google and S/O, but all the docs I've read on custom schematics seem to focus on the directory and file writing capabilities.

  • 1
    This is quite an open question. The thing is Angular is all client side stuff running on a browser and node is server side. If you go into production your microservice will probably be online somewhere whilst your angular application will be running on a client's computer, so it's not clear exactly what you're trying to achieve... One thing I will say, though, is for this kind of thing Docker and particularly docker-compose are your friends. – Michael Beeson Jul 04 '19 at 21:15
  • Thanks, the purpose of the schematic is to be part of a package used during development, so the microservice will also be local to the developer. – starkraving Jul 04 '19 at 22:52

1 Answers1

1

At this moment you can't do this. Although you can add this command to your package.json into scripts section, like that:

"scripts": {
    "ng": "ng",
    "start": "ng serve",
    "start-with-service": "node ../path/to/microservice/microservice.js && ng serve"
}

If you want this script to be generated automatically when the app is being generated, you may want to add it in the custom schematics you use.

grreeenn
  • 2,287
  • 1
  • 20
  • 27