I am doing a COVID-19 dashboard for my university assignment and recently my country decided to open COVID data to the public. I am fortunate to come across a NodeJS self-hosted RESTful API server endpoint that provides the API for use. Here's the link to this amazing guy's work: https://github.com/leeliwei930/moh-my-covid-express-api
I followed the instructions on how to setup the server locally and it works. However, I have no idea how to use it in my assignment project. I have experience in using APIs in my previous projects where I just need to include the link to use it. I don't think it works the same in this case since I would have to open the folder containing the files of this API server and manually type in some commands in the terminal each time I want to host the API server locally.
So is there any way to make the API server always online so that I can use it in my COVID project? I have no knowledge in Node.js and just started learning JS but am willing to learn it my project requires me to do so.
First :
use pm2 for service handler of you express application bind it locally
then put nginx or apache2 in top of your code and config your express application as upstream server in nginx or apache2
if you want to be your service always online , run your express code on two different server and config upstream server in nginx and apache2 as two server to redirect request to both of your express service or use master slave strategy to route request to one of your express when service failed route to another express service
If you dockerize the node application (Docker container) it will always be online and restart always without the need for PM2 or other process manager on the Linux level. All you need to have in your docker-compose file is restart: always. Highly recommended solution.