Web Hosting With Nodejs and MongoDB
Nodejs and MongoDB To begin our web hosting with Nodejs and MongoDB project, the easiest way to get started is with MongoDB Atlas – a fully managed database-as-a-service. Simply visit the Create Web App + Database page, select your hosting plan (we used free one), Azure region and name (for example msdocs-expressjs-mongodb-tutorial). Select MongoDB as a Database engine in Database engine list before using your automatically generated database URI (such as msdocs-expressjs-expressjs-mongodb-app-name>XYZ). Finally use automatically generated database URI as DATABASE_URL variable when setting your DATABASE_URL variable value.
Click the Create button, wait a few moments, and Rancher will create your service. You can check its status by navigating to Infrastructure > Hosts; an application-labeled host with loadbalancer should appear here. Additionally, as we’re creating a database service here, let’s also give the host some additional privileges by creating a user. Click User button and create one – this will allow containers accessing it directly via its database connection.
If everything works as intended, you’ll be able to view data in the collection you just created (with an URI like /databasename>/users). To test your database connection, navigate the MongoDB Atlas UI collections button for your project cluster and locate its collections tab; there should be an instance with an URI like databasename>/users that provides an indication of data that can be accessed using client-side JavaScript requests.