Hey, did everyone that they share?
So we have talked quite a lot on this application and now it's time that we put it into the production.
The big question is, is this application ready to go in the production?
The answer is no.
No application is ever ready to go in the production because there is so much of more refinement and
improvement that you can do in the application that it will never see the daylight.
But please don't do this.
Whatever the project you have created, it needs to go out in the public.
It needs to go out.
Surely we can work a lot on these models and the routes.
We can define more structure on that.
We can handle a lot of our errors more decisively, a little bit, handling them and failing with style,
something called us.
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
the things onto the production itself.
So first, the problem in front of ourself is the MongoDB.
Right now the MongoDB is in our local storage or local database itself.
Let's go ahead and use something like MongoDB Atlas or in case you are seasoned developer, you can
actually use eight of those or other resources to host MongoDB on our own virtual machine or instance
or whatever you call that.
In this case, we are going to use simply the MongoDB from our from the Atlas.
It provides you the free resource on that.
Now, in one of the previous video I have already walked you through in detail guide of how to set up
this database.
It's really simple.
You simply click on create database and it allows you to choose between the serverless or the free.
We are going to use the shared one because simply it's free.
So that's why we are going to use that one.
So let's go ahead and move back.
I've already created one.
I'll be using that.
Apart from that again, reminding this again, I have already talked you through that we need to have
a database access of anywhere so this database can be accessed from anywhere.
And I have got the network access so it can be accessed from anywhere.
And this is the user AE, which is the user who can access the database.
These are important things you need to have them.
So once I have this database, I can click on Connect and it will show you that I want to connect my
application.
So this will give you a URL and all you have to do is simply copy this URL, go back into your code
and just exactly the place where we were sending this, this one we can actually replace this one.
And now database will be talking to online Internet.
That's the power of Dot and V.
Now let's go ahead and push this entirety of the code onto the Heroku Digital Ocean, whatever you are
using or you can line it up or kind of a chain this up into a secede mode of the GitHub as well.
Let's go ahead and create a new project.
Yes, I tested this out before actually recording this video.
Everything was working fine.
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.
There we go.
And it's already being taken.
Oh, no name should be all lowercase.
So let's go ahead and try this again.
I'll see you t shirt.
Store.
Yeah, that's.
That sounds good.
LTO T-shirt store is available.
Let's go ahead and create this app.
We can add a pipeline for moving it to testing or moving all of that.
We won't be going that much in detail.
This is not a DevOps course, so let's go ahead and create that.
Now, the first thing that you have to do is obviously follow these instructions.
But first let's go into the settings and we have already seen that this is where all the configuration
actually goes in.
So let's go ahead and consult with our this guy.
So this says, hey, you need to go ahead and use this DB URL because this is the essential.
Otherwise our application will fail.
In case you notice the workflow for application, we have this index of JS and as soon as we open this
up we require the store tab if it is available.
If it is not, that's fine.
But we actually connect with the database.
We haven't given any protection that if the connection fails or anything, what to do next or something.
And in fact that application should not be working if the database connection actually fail.
So that is kind of a good for us.
So we have this database URL, we have already inserted that.
Now let's go up here and copy this and paste it up here.
So not here.
Where does it go?
Here it does.
So we need to paste this one up here.
Now, make sure you also change this one here.
So this password, all the angular brackets or the diamond brackets, some people call it, you have
to replace it with your original password.
So I'm going to go ahead and enter my password.
And obviously by the time you'll be watching this video, I'll be deleting everything up here.
All the database connection and all the keys and everything will be gone or will be at least refreshed.
So let's go ahead and add this one.
So there we go.
This database is now added at least this one.
And by the way, one by one, we have to come here and we have to pass on all these things.
Not port except port except port.
Everything like JWT Secret expiry cookie time cloud native SMTP host In case your SMTP host is not,
this mail trap might be using something like send in blue a w s.
You have to provide these details.
Stripe API, key, razor pic.
Everything needs to go there now.
Once this is all done now we can follow the instruction that is mentioned up here.
So let's go into ae t shirt store and right now it says hey, there is nothing, so this is good, but
I need to see the instruction to deploy.
There we go.
So it says, hey, first go ahead and do a Heroku login.
I am already logged in into the system, but yours might be saying so.
I'm going to go ahead and say Heroku Heroku login.
And by the way, in case your Heroku CLI is not installed, that means you are skipping the videos.
Please don't do that.
I have already discussed this part in one of the previous sections, so Heroku login is going to go
ahead and give you an answer that hey, you are already logged in.
Now it's going to ask me to log in again.
Shouldn't be happening this way.
But anyways, let's go ahead and say yeah, login please.
And this should be all logged in.
So now I'm logged in with my dummy email or rather email for the tutorial purposes.
Okay, let's go ahead and clean this up.
Now we need to set a remote repository.
So just like you said, a remote repository on GitHub, you have to set this one.
We have already done this, get in it part and all of that.
Now we have to set a remote repository and you can set multiple remote repository for a single project.
We're going to go ahead and use this one.
So let's copy this one.
And this is my remote repository, so let's go ahead and add this one.
So it says.
Okay.
So a remote repository is all added up here.
Now, let's go ahead and just copy, commit and add all part we have done.
In case you have added something more into that, just go ahead and push a comment on that.
And now we're going to go ahead and simply say, get push Heroku master.
So on this particular repository, we'll be making this one, this push here.
So let's go ahead and simply go ahead and say, hey, let's go ahead and push this, get push Heroku
master.
And it's going to just send everything onto this one and we can actually even check the logs rightly
in in this one.
And again, there are chances that although we have written our code carefully, but production is production,
it can go always wrong no matter how you expect that or not.
But in this case, we are going to go ahead and work on with that.
So it's pruning all the dev dependencies and everything looks good.
But I'll succeed because I tested it out earlier and that's why it is super comfortable that it's going
to get succeed here.
But again, even if it wouldn't have, I probably would have done some more tweaking and stuff.
So let's see, check the overview of that.
And there we go.
It says, deployed, deployed, succeed.
Is it?
Yep, verifying, deployed.
And it's available up here.
Let's go ahead and open this URL.
And obviously there is nothing that says method is not allowed.
Okay.
No, this is not what I want to open up.
I want to open up this one Heroku T-shirt.
There we go.
Nice.
Now, obviously, we are going to get an error here because we didn't set up any route up here.
We can actually go ahead and do this our all of our root our slash API slash V one and then I guess
we have a home root.
Yeah, we have a home root which says success true.
And greeting from Hello API and we can also go ahead and use this dummy root.
In fact, we do have something to see here as well.
I guess if I remember correctly, we haven't removed that root.
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
just like that.
This is directly available.
So all of your application in case you are working with the views that is all up here now.
Also, please don't get surprised when I go ahead and see this products.
You might be expecting all products to list out, but this is not going to list it because right now
this is a fresh database.
So database has been plumbed.
So there is nothing inside that one.
Now, again, just reminding you one more time we haven't set up things for the JWT secret expired in
all of that.
So in case you try to run the user, it's not going to work, at least as of now.
I just wanted to show you that.
Yeah, it is pretty easy to push the code on to production, whether it's Heroku, a tableau s maybe
you're using digital ocean or something like that, but this is all good and that's all what we have
to do.
So there you go.
Finally, you have pushed the course to the production as well.
Go ahead.
Keep on adding more features to this project, refine it a little bit more, handle the error more gracefully.
And that's pretty much it.
That's how you become a pro backend developer.