WEBVTT

00:03.760 --> 00:05.270
Hey, did everyone that they share?

00:05.290 --> 00:10.050
So we have talked quite a lot on this application and now it's time that we put it into the production.

00:10.060 --> 00:13.150
The big question is, is this application ready to go in the production?

00:13.150 --> 00:14.110
The answer is no.

00:14.110 --> 00:19.180
No application is ever ready to go in the production because there is so much of more refinement and

00:19.180 --> 00:22.420
improvement that you can do in the application that it will never see the daylight.

00:22.420 --> 00:23.590
But please don't do this.

00:23.590 --> 00:26.290
Whatever the project you have created, it needs to go out in the public.

00:26.290 --> 00:27.370
It needs to go out.

00:27.370 --> 00:30.490
Surely we can work a lot on these models and the routes.

00:30.490 --> 00:31.990
We can define more structure on that.

00:31.990 --> 00:37.480
We can handle a lot of our errors more decisively, a little bit, handling them and failing with style,

00:37.480 --> 00:38.620
something called us.

00:38.830 --> 00:42.790
So there is a lot that we can do, but we're going to stop it right now and we're going to just push

00:42.790 --> 00:44.410
the things onto the production itself.

00:44.410 --> 00:48.220
So first, the problem in front of ourself is the MongoDB.

00:48.220 --> 00:51.730
Right now the MongoDB is in our local storage or local database itself.

00:51.730 --> 00:56.650
Let's go ahead and use something like MongoDB Atlas or in case you are seasoned developer, you can

00:56.650 --> 01:02.290
actually use eight of those or other resources to host MongoDB on our own virtual machine or instance

01:02.290 --> 01:03.490
or whatever you call that.

01:03.490 --> 01:07.780
In this case, we are going to use simply the MongoDB from our from the Atlas.

01:07.780 --> 01:09.970
It provides you the free resource on that.

01:10.000 --> 01:14.080
Now, in one of the previous video I have already walked you through in detail guide of how to set up

01:14.080 --> 01:14.680
this database.

01:14.680 --> 01:15.460
It's really simple.

01:15.460 --> 01:20.080
You simply click on create database and it allows you to choose between the serverless or the free.

01:20.080 --> 01:22.600
We are going to use the shared one because simply it's free.

01:22.600 --> 01:24.460
So that's why we are going to use that one.

01:24.460 --> 01:25.840
So let's go ahead and move back.

01:25.840 --> 01:26.860
I've already created one.

01:26.860 --> 01:27.970
I'll be using that.

01:28.090 --> 01:32.740
Apart from that again, reminding this again, I have already talked you through that we need to have

01:32.740 --> 01:36.430
a database access of anywhere so this database can be accessed from anywhere.

01:36.430 --> 01:40.300
And I have got the network access so it can be accessed from anywhere.

01:40.300 --> 01:44.350
And this is the user AE, which is the user who can access the database.

01:44.350 --> 01:46.330
These are important things you need to have them.

01:46.600 --> 01:51.670
So once I have this database, I can click on Connect and it will show you that I want to connect my

01:51.670 --> 01:52.180
application.

01:52.180 --> 01:57.730
So this will give you a URL and all you have to do is simply copy this URL, go back into your code

01:57.730 --> 02:02.050
and just exactly the place where we were sending this, this one we can actually replace this one.

02:02.050 --> 02:04.180
And now database will be talking to online Internet.

02:04.180 --> 02:05.800
That's the power of Dot and V.

02:06.010 --> 02:11.650
Now let's go ahead and push this entirety of the code onto the Heroku Digital Ocean, whatever you are

02:11.650 --> 02:16.930
using or you can line it up or kind of a chain this up into a secede mode of the GitHub as well.

02:17.080 --> 02:18.700
Let's go ahead and create a new project.

02:18.700 --> 02:21.670
Yes, I tested this out before actually recording this video.

02:21.700 --> 02:22.870
Everything was working fine.

02:22.870 --> 02:29.470
So let's go ahead and create a new app and I'm going to call this one as simply ae a t shirt store.

02:29.500 --> 02:30.160
There we go.

02:31.000 --> 02:32.620
And it's already being taken.

02:32.620 --> 02:34.420
Oh, no name should be all lowercase.

02:34.420 --> 02:36.010
So let's go ahead and try this again.

02:36.010 --> 02:38.920
I'll see you t shirt.

02:40.340 --> 02:41.250
Store.

02:41.300 --> 02:41.900
Yeah, that's.

02:41.990 --> 02:42.650
That sounds good.

02:42.660 --> 02:44.090
LTO T-shirt store is available.

02:44.090 --> 02:45.500
Let's go ahead and create this app.

02:45.500 --> 02:48.770
We can add a pipeline for moving it to testing or moving all of that.

02:48.770 --> 02:50.360
We won't be going that much in detail.

02:50.420 --> 02:54.020
This is not a DevOps course, so let's go ahead and create that.

02:54.350 --> 02:57.710
Now, the first thing that you have to do is obviously follow these instructions.

02:57.710 --> 03:02.480
But first let's go into the settings and we have already seen that this is where all the configuration

03:02.480 --> 03:03.230
actually goes in.

03:03.230 --> 03:05.960
So let's go ahead and consult with our this guy.

03:05.960 --> 03:10.370
So this says, hey, you need to go ahead and use this DB URL because this is the essential.

03:10.370 --> 03:11.930
Otherwise our application will fail.

03:11.930 --> 03:17.450
In case you notice the workflow for application, we have this index of JS and as soon as we open this

03:17.450 --> 03:20.420
up we require the store tab if it is available.

03:20.420 --> 03:21.590
If it is not, that's fine.

03:21.590 --> 03:23.330
But we actually connect with the database.

03:23.330 --> 03:27.590
We haven't given any protection that if the connection fails or anything, what to do next or something.

03:27.590 --> 03:31.430
And in fact that application should not be working if the database connection actually fail.

03:31.430 --> 03:33.140
So that is kind of a good for us.

03:33.440 --> 03:36.830
So we have this database URL, we have already inserted that.

03:36.830 --> 03:41.210
Now let's go up here and copy this and paste it up here.

03:41.210 --> 03:42.830
So not here.

03:43.160 --> 03:43.870
Where does it go?

03:43.910 --> 03:44.630
Here it does.

03:44.630 --> 03:46.250
So we need to paste this one up here.

03:46.280 --> 03:48.140
Now, make sure you also change this one here.

03:48.140 --> 03:52.730
So this password, all the angular brackets or the diamond brackets, some people call it, you have

03:52.730 --> 03:54.470
to replace it with your original password.

03:54.470 --> 03:56.630
So I'm going to go ahead and enter my password.

03:56.630 --> 04:00.200
And obviously by the time you'll be watching this video, I'll be deleting everything up here.

04:00.200 --> 04:04.640
All the database connection and all the keys and everything will be gone or will be at least refreshed.

04:04.940 --> 04:07.100
So let's go ahead and add this one.

04:07.790 --> 04:08.390
So there we go.

04:08.420 --> 04:10.490
This database is now added at least this one.

04:10.490 --> 04:15.440
And by the way, one by one, we have to come here and we have to pass on all these things.

04:15.440 --> 04:17.600
Not port except port except port.

04:17.600 --> 04:24.260
Everything like JWT Secret expiry cookie time cloud native SMTP host In case your SMTP host is not,

04:24.260 --> 04:27.710
this mail trap might be using something like send in blue a w s.

04:27.710 --> 04:29.300
You have to provide these details.

04:29.300 --> 04:31.760
Stripe API, key, razor pic.

04:31.790 --> 04:33.800
Everything needs to go there now.

04:33.800 --> 04:37.460
Once this is all done now we can follow the instruction that is mentioned up here.

04:37.610 --> 04:45.320
So let's go into ae t shirt store and right now it says hey, there is nothing, so this is good, but

04:45.320 --> 04:47.390
I need to see the instruction to deploy.

04:47.420 --> 04:48.140
There we go.

04:48.380 --> 04:51.080
So it says, hey, first go ahead and do a Heroku login.

04:51.080 --> 04:53.990
I am already logged in into the system, but yours might be saying so.

04:53.990 --> 04:58.100
I'm going to go ahead and say Heroku Heroku login.

04:58.100 --> 05:03.710
And by the way, in case your Heroku CLI is not installed, that means you are skipping the videos.

05:03.710 --> 05:04.700
Please don't do that.

05:04.700 --> 05:09.140
I have already discussed this part in one of the previous sections, so Heroku login is going to go

05:09.140 --> 05:11.690
ahead and give you an answer that hey, you are already logged in.

05:11.840 --> 05:14.030
Now it's going to ask me to log in again.

05:14.430 --> 05:15.980
Shouldn't be happening this way.

05:15.980 --> 05:20.660
But anyways, let's go ahead and say yeah, login please.

05:21.750 --> 05:23.160
And this should be all logged in.

05:23.160 --> 05:27.960
So now I'm logged in with my dummy email or rather email for the tutorial purposes.

05:28.320 --> 05:29.820
Okay, let's go ahead and clean this up.

05:30.180 --> 05:32.210
Now we need to set a remote repository.

05:32.220 --> 05:36.180
So just like you said, a remote repository on GitHub, you have to set this one.

05:36.180 --> 05:38.310
We have already done this, get in it part and all of that.

05:38.310 --> 05:42.690
Now we have to set a remote repository and you can set multiple remote repository for a single project.

05:42.990 --> 05:44.550
We're going to go ahead and use this one.

05:44.550 --> 05:45.810
So let's copy this one.

05:46.230 --> 05:49.800
And this is my remote repository, so let's go ahead and add this one.

05:50.070 --> 05:51.270
So it says.

05:52.220 --> 05:52.550
Okay.

05:52.550 --> 05:54.980
So a remote repository is all added up here.

05:55.070 --> 05:58.880
Now, let's go ahead and just copy, commit and add all part we have done.

05:58.880 --> 06:02.780
In case you have added something more into that, just go ahead and push a comment on that.

06:02.780 --> 06:06.380
And now we're going to go ahead and simply say, get push Heroku master.

06:06.380 --> 06:11.780
So on this particular repository, we'll be making this one, this push here.

06:11.960 --> 06:17.330
So let's go ahead and simply go ahead and say, hey, let's go ahead and push this, get push Heroku

06:17.330 --> 06:17.900
master.

06:17.900 --> 06:22.190
And it's going to just send everything onto this one and we can actually even check the logs rightly

06:22.190 --> 06:23.390
in in this one.

06:23.510 --> 06:28.400
And again, there are chances that although we have written our code carefully, but production is production,

06:28.400 --> 06:32.330
it can go always wrong no matter how you expect that or not.

06:32.330 --> 06:35.210
But in this case, we are going to go ahead and work on with that.

06:35.750 --> 06:39.050
So it's pruning all the dev dependencies and everything looks good.

06:39.050 --> 06:44.330
But I'll succeed because I tested it out earlier and that's why it is super comfortable that it's going

06:44.330 --> 06:45.440
to get succeed here.

06:45.770 --> 06:50.540
But again, even if it wouldn't have, I probably would have done some more tweaking and stuff.

06:50.540 --> 06:52.610
So let's see, check the overview of that.

06:53.120 --> 06:53.870
And there we go.

06:53.870 --> 06:56.210
It says, deployed, deployed, succeed.

06:56.210 --> 06:56.870
Is it?

06:57.590 --> 06:58.820
Yep, verifying, deployed.

06:58.820 --> 06:59.840
And it's available up here.

06:59.840 --> 07:01.550
Let's go ahead and open this URL.

07:01.790 --> 07:05.480
And obviously there is nothing that says method is not allowed.

07:06.470 --> 07:06.780
Okay.

07:06.890 --> 07:09.080
No, this is not what I want to open up.

07:10.040 --> 07:12.470
I want to open up this one Heroku T-shirt.

07:12.500 --> 07:13.220
There we go.

07:13.460 --> 07:14.060
Nice.

07:14.330 --> 07:18.800
Now, obviously, we are going to get an error here because we didn't set up any route up here.

07:18.800 --> 07:26.240
We can actually go ahead and do this our all of our root our slash API slash V one and then I guess

07:26.240 --> 07:27.350
we have a home root.

07:27.350 --> 07:29.540
Yeah, we have a home root which says success true.

07:29.540 --> 07:34.520
And greeting from Hello API and we can also go ahead and use this dummy root.

07:35.120 --> 07:37.700
In fact, we do have something to see here as well.

07:37.700 --> 07:41.120
I guess if I remember correctly, we haven't removed that root.

07:41.390 --> 07:48.080
So yep, there is a sign up test here as well and I can go that and this is not on slash API slash dummy

07:48.080 --> 07:48.650
just like that.

07:48.650 --> 07:50.000
This is directly available.

07:50.000 --> 07:54.170
So all of your application in case you are working with the views that is all up here now.

07:54.170 --> 07:58.810
Also, please don't get surprised when I go ahead and see this products.

07:58.820 --> 08:03.020
You might be expecting all products to list out, but this is not going to list it because right now

08:03.020 --> 08:04.340
this is a fresh database.

08:04.340 --> 08:06.380
So database has been plumbed.

08:06.380 --> 08:08.180
So there is nothing inside that one.

08:08.330 --> 08:14.300
Now, again, just reminding you one more time we haven't set up things for the JWT secret expired in

08:14.300 --> 08:14.660
all of that.

08:14.660 --> 08:18.110
So in case you try to run the user, it's not going to work, at least as of now.

08:18.110 --> 08:19.430
I just wanted to show you that.

08:19.430 --> 08:24.920
Yeah, it is pretty easy to push the code on to production, whether it's Heroku, a tableau s maybe

08:24.920 --> 08:28.970
you're using digital ocean or something like that, but this is all good and that's all what we have

08:28.970 --> 08:29.480
to do.

08:29.480 --> 08:30.200
So there you go.

08:30.200 --> 08:32.450
Finally, you have pushed the course to the production as well.

08:32.480 --> 08:33.050
Go ahead.

08:33.050 --> 08:38.180
Keep on adding more features to this project, refine it a little bit more, handle the error more gracefully.

08:38.180 --> 08:39.320
And that's pretty much it.

08:39.320 --> 08:41.690
That's how you become a pro backend developer.
