Generating a MongoDB Connection URL
To set up the Beacon backend, you need a MongoDB connection URL. Follow these steps to generate it using MongoDB Atlas:
Step 1: Create a MongoDB Atlas Account
- Visit MongoDB Atlas and sign up or log in.
- Click on Create a New Project and give it a name.
- Click Next and then Create Project.
Step 2: Set Up a Cluster
- In your project dashboard, click on Build a Database.
- Choose Shared (Free) for a free-tier cluster.
- Select a cloud provider (AWS, GCP, or Azure) and region.
- Click Create Cluster.
Step 3: Configure Database Access
- Once the cluster is created, go to Database Access in the left sidebar.
- Click Add New Database User.
- Set a username and password (you'll use these in your
.env
file). - Choose Read and Write Access and click Add User.
Step 4: Allow Network Access
- Go to Network Access in the left sidebar.
- Click Add IP Address.
- Select Allow Access from Anywhere or add your IP manually.
- Click Confirm.
Step 5: Get the Connection URL
- Go to Database Deployments and click Connect on your cluster.
- Select Connect your application.
- Copy the provided Connection String.
- Replace
<username>
and<password>
with the credentials from Step 3.
Step 6: Add the URL to Your .env
File
Paste the connection string into your .env
file:
DB=mongodb+srv://<username>:<password>@<cluster-url>/test?retryWrites=true&w=majority
Note: Replace
<username>
,<password>
, and<cluster-url>
with your actual values.
Your MongoDB database is now ready to use!