Communication with Springboot server and javascript

I’ve build a couple scrappers using puppeteer lately, and im working on creating statistics based on the output of the scrappers using java. I was using java run time and processes to parse the scrapper’s output in java, but i wanted to try and learn a bit of springboot.

i’ve built a Controller file in js to manage the posts and call a bot depending on the input the post gets.

For all of this to work, i had to setup a port for js, and send the http post to that port. The thing is i didnt want to manually start the js Controller, so i use processbuilder in java, only for it to practically start the “js server”.

The code in java side looks like this:

ProcessBuilder processBuilder = new ProcessBuilder();
      processBuilder.command("node", "./lib/webs/BotController.js");
        processBuilder.inheritIO();

        Process p =   processBuilder.start();
        long pid=p.pid();
        System.out.println(pid);
        
        Thread.sleep(5000);
        
        
        ConfigurableApplicationContext context = SpringApplication.run(DemoApplication.class);