How to Deploy NodeJS Application
Below is the screenshot of our sample REST API code generated using the Auto code generator platform. And the tech stack is MongoDB, Express, and NodeJs. Our App server does not support the local MongoDB database, so ensure cloud DB is used.
In the above example, if the get request is made to the root of the URL, then it responds with the message, letscode.xyz is running.Port to Listen to
In the above example, we are listening to port number 3000, and this port number should be the same as the one mentioned in the server block file.No Node Modules
On the left side if you look at the file structure of the project there is no node modules folder, and this is the expected file structure to zip and upload to our App server platform.Upload the Project File
Once we zip the project folder and select it by choosing the Choose file button, the UPLOAD button will appear. Once the UPLOAD button is clicked upon successful uploading of our project file to our central server, the DEPLOY button will appear.Deploying the Project File
Once the file upload is successful, the DEPLOY button will appear and upon clicking the deploy button a Modal window will open asking for the tech stack to deploy, select MongoDB-Express-Node tech stack and click on deploy.
If the project folder is in right strucutre and if there is no local dependency, then it may take 1 to 2 minutes for successful deployment.
If you had selected the wrong tech stack for the deployment, sometimes even if it shows it is successful, you will see a bad gateway error upon querying the URL.
Upon successful deployment of the project folder, domain name, and server block file, when we ping the URL it shows us the intended message.