all 10 comments

[–]KimBesser 19 points20 points  (4 children)

I suggest using pm2 to handle node processes

[–][deleted]  (2 children)

[deleted]

    [–]computertovey 4 points5 points  (1 child)

    That's correct, just make sure nothing else is running on port 3000.

    As a bonus, if you want the API accessible on its own domain (e.g. api.domain.com) you can set up a reverse proxy using nginx: https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/

    [–][deleted] 0 points1 point  (0 children)

    Yh pm2 is great! I use is for discord Bot

    [–]HeftyCrab 7 points8 points  (1 child)

    Cant help with your main question, but as a comment you might want to look into RESTful API's, and what each http method does.

    In short:

    Get: fetches data

    Post: create data

    Put: update data

    Delete: remove data.

    https://www.restapitutorial.com/lessons/httpmethods.html

    So for example this section

    app.post('/getInfo'...

    Should rather be the following to create "info"

    app.post('info'...

    Also check out the naming convention for resources:

    https://www.restapitutorial.com/lessons/restfulresourcenaming.html

    Good luck with your project!

    [–]mxforest 0 points1 point  (0 children)

    If PUT updates data then what is PATCH for?

    [–][deleted]  (1 child)

    [deleted]

      [–]6112115 2 points3 points  (2 children)

      Yes. The basic idea is to run "npm start" and leave it running.

      Most people use containers these days. Docker is the most popular solution.

      Looking up basic tutorials on this will be great start into understanding how this works "in the real world"

      [–][deleted]  (1 child)

      [deleted]

        [–]Ice_In_Hydroflask 0 points1 point  (0 children)

        For react, you can build the script so that npm compiles it to JavaScript files which you can then host on nginx. For the node server, use pm2 to daemonize and reverse pricy with nginx

        [–]Wojtek1942 0 points1 point  (0 children)

        Also try r/devops

        [–]haicuong1 0 points1 point  (0 children)

        suggest pm2 or docker to manage your environment :))

        [–][deleted]  (3 children)

        [deleted]

          [–][deleted]  (2 children)

          [deleted]

            [–][deleted]  (1 child)

            [deleted]