You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 16, 2023. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+22-15
Original file line number
Diff line number
Diff line change
@@ -91,29 +91,36 @@ The Azure free tier gives you plenty of resources to play around with including
91
91
-**Create a cloud database** -
92
92
For local development, running MongoDB on localhost is fine, however once we deploy we need a database with high availability.
93
93
The easiest way to achieve this is by using a managed cloud database.
94
-
There are many different providers, but the easiest one to get started with is [MongoLab](#Create a managed MongoDB with MongoLab).
94
+
There are many different providers, but the easiest one to get started with is [MongoDB Atlas](#create-a-managed-mongodb-with-atlas).
95
95
-**SendGrid Account** -
96
-
If you don't have one, you can sign up for free, we will need it to send emails. There are many different providers that Nodemailer supports ([Well-known services](https://nodemailer.com/smtp/well-known/)), we'll be using [SendGrid](#SendGrid Account).
97
-
98
-
### Create a managed MongoDB with MongoLab
99
-
1. Navigate to [MongoLab's Website](https://mlab.com/), sign up for a free account, and then log in.
100
-
2. In the **MongoDB Deployments** section, click the **Create New** button.
101
-
3. Select any provider (I recommend **Microsoft Azure** as it provides an easier path to upgrading to globally distributed instances later).
102
-
4. Select **Sandbox** to keep it free unless you know what you're doing, and hit **Continue**.
103
-
5. Select a region (I recommend the region geographically closest to your app's users).
104
-
6. Add a name, click **Continue** again, and finally **Submit Order**.
105
-
7. Once your new database is created, select it from the **MongoDB Deployments** section.
106
-
8. Create a user by selecting the **User** tab, clicking the **Add database user** button, adding a username and password, and then clicking **Create**.
96
+
If you don't have one, you can sign up for free, we will need it to send emails. There are many different providers that Nodemailer supports ([Well-known services](https://nodemailer.com/smtp/well-known/)), we'll be using [SendGrid](#sendgrid-account).
97
+
98
+
### Create a managed MongoDB with Atlas
99
+
1. Navigate to [MongoDB's website](https://www.mongodb.com/cloud/atlas), sign up for a free account, and then log in.
100
+
2. After creating the account, enter the organization name, project name, and select your preferred language (JavaScript).
101
+
3. Select the **Shared Cluster** to get a free version with up to 512 MB storage which is great for development purposes.
102
+
4. On the "Create a Starter Cluster" page you can select cloud provider, region, region, cluster tier, and
103
+
MongoDB settings, like version and backup frequency (Note: there is no option to create backups in the free tier).
104
+
5. If you already know to which cloud provider and region you want to deploy later, you should select the same here for best performance. Otherwise select a region close to the location where you plan to deploy the application later.
105
+
6. Select **M0 Sandbox** as the Cluster Tier, give your cluster a name, and then click the "Create Cluster" button.
106
+
7. It will now take a couple of minutes to create the cluster and you will be redirected to the MongoDB Atlas Admin interface.
107
+
8. Now you must configure access and security before you can use the database.
108
+
9. To whitelist an IP address, go to the **Network Access** section and click the "Add IP Address" button. For local development you can select your current IP address.
109
+
10. Create a user by selecting the **Add New Database User** in Database Access, adding a username and password (Password Authentication method) and give him read and write access to any database within the cluster.
107
110
A user account is required to connect to the database, so remember these values because you will need them as part of your connection string.
108
-
9. Copy the connection string from the top of the page, it should look like this: `mongodb://<dbuser>:<dbpassword>@ds036069.mlab.com:36069/test-asdf`
109
-
and replace `<dbUser>` and `<dbpassword>` with the credentials you just created.
111
+
11. Within the Clusters section, click the **Connect** button in your cluster to connect to the database.
112
+
12. You could now connect to the cluster using [MongoDB Compass](https://www.mongodb.com/products/compass), which is a graphical interface (GUI) to interact with the database.
113
+
13. But we need to select **Connect your application** to get the connection string, it should look like this: `mongodb+srv://<username>:<password>@your-cluster.12abc.mongodb.net/your-database?retryWrites=true&w=majority`
114
+
and replace `<username>` and `<password>` with the credentials you just created.
110
115
Back in your project, open your `.env` file and update `MONGODB_URI` with your new connection string.
111
116
> NOTE! - If you don't have an `.env` file yet, rename `.env.example` to `.env` and follow the comments to update the values in that file.
112
-
10.**Success!**
117
+
14.**Success!**
113
118
You can test that it works locally by updating `MONGODB_URI_LOCAL` to the same connection string you just updated in `MONGO_URI`.
114
119
After rebuilding/serving, the app should work, but users that were previously created in local testing will not exist in the new database!
115
120
Don't forget to return the `MONGO_URI_LOCAL` to your local test database (if you so desire).
116
121
122
+
You can find **more information** about how to get started with Atlas [here](https://docs.atlas.mongodb.com/getting-started/).
123
+
117
124
### SendGrid Account
118
125
1. Navigate to [SendGrid's Website](https://sendgrid.com/), sign up for a free account, and complete the verification process.
119
126
2. Open your `.env` file and update `SENDGRID_USERNAME` and `SENDGRID_PASSWORD` with your SendGrid username and password respectively.
0 commit comments