Hey, did everyone.
They share?
And I know this video is getting too long.
In fact, this entire situation is getting too long.
But I wanted to give you a different aspect of the things.
And don't worry, after this particular controller, we won't be spending this much of time in handling
these kinds of issues.
We'll have a better plan and strategy.
But right now, the important thing is we want to test out that whether our images are getting uploaded
or not.
So for this, let me just fire up my sublime text.
So I'm going to go ahead and open up my sublime text.
Where is it?
There we go.
So this is my sublime text again.
Feel free to open up any of the code data and I'll just drag and drop this forms and images.
The one which we have worked already in the past.
In case you noticed, we have this aegis installed in this one.
So what we're going to do is we're going to install edges onto this one as well.
So NPM install aegis in case you know about that, which you should be that EEGs will help us to actually
work on with the things.
So we're going to go ahead and say NPM, run dev here and let's borrow in some of the code.
From the views of the Aegis, especially the post form, we're going to go ahead and copy entirety of
the things.
Again, we'll be doing the same things up here that onto the home root of this one.
Let me close all of these routes, all of these folders.
And in here we're going to go ahead and create views.
And inside these views, we are going to go ahead and create a new file.
We're going to call this one assign up test dot G's, of course.
And there we go.
Now we have this template.
All good up and running and my bad.
It's not sign up test or geez, it should be HTML.
So let me go ahead and rename this.
And there we go.
It is HTML.
There we go.
So now it is all good and okay.
Now a couple of things.
Very interestingly, this is a post form, so make sure the method is post.
Since we have copied this, the encryption type is multipart form data.
This is also important and we have this sample file up here.
So this needs to be changed as well.
A little bit more of the configuration needs to be changed in case you remember in the index or JS.
We now need to set this as edges.
So we're going to go ahead and copy this that now the view engine that we are having is the edges.
That's all it takes.
So let's go up into JS and this is basically just a temp check.
So we're going to go ahead and mention that this is just a temp check and we are having this IGs up
and running now.
We need to create a new route which actually can serve this set signup test.
So we're going to go into the into the route and we have this home route and let's go ahead and get
a simple get route, which will be handled by all of that.
But you know what?
This is too much.
This is just a simple test.
So I'm going to go ahead and write a test up here.
So after the middleware, I'm going to go ahead and simply write a simple get here, since this is any
way is just a test route.
So we're going to call this one as sign up test.
And again, this needs to go inside the code just like that.
And after that, we need to have a simple request.
Request response.
And there we go.
And here we're going to say rez, dot, render.
Come on.
Dot render.
And inside that we're going to say that, hey, what we want to render is simply this sign up test.
Dot HTML.
Okay.
Let's go ahead and quickly verify that all of the things are just exactly same as we have worked on.
So this is all and let me go ahead, scroll there.
And again, this is all.
And again, we don't need to write the HTML.
My bad.
It automatically picks that up.
So sign up test is all what we got.
So if I go ahead and now visit the sign up test route, I should be in theory be able to get this form.
So let's go ahead and move on to the local host, 4000 slash sign up test and it says, hey, failed
to render the sign of test in views directory.
So it looks like some of the render method is not working out.
After spending a lot of time with the screen, I realized that this is not even XHTML.
Come on, what am I doing?
Looks like it's too late.
It's just 1:00 in the night.
But again, it looks like I need to figure it out.
Come on.
So it is eggs, and now it should be all working.
Finally, let's go ahead and hit a reload up here.
And there we go.
We are able to load this get form.
At least it's taking a little while to actually load all of this.
I don't know why, what's the reason for that?
But at least now we are getting the sign up test request and the form is actually loading up nicely.
Okay.
A couple of things now we need to do is the first thing is now we need to go ahead and worry about where
this request is going in.
So let's go ahead and open this up.
Previously we were able to see that this is our form and the request was going on to directly on slash
my post.
Now the localhost column 4000 will be added up, but not the slash API slash v one.
So this we need to add and then the post that we are going to go up is sign up.
So this is the basic route that we need to go there.
So the name is going up as first name, so we don't want that input.
So I'll just have this one a little bit bigger.
There we go.
So this one is actually just the name and we can actually remove this part.
So that I can actually place this one.
So this is just basically the name that is going in.
I'll copy this one up here.
So copy this part.
Paste that again.
This is for email.
This is actually for name.
All the way all.
So this is name.
Copy that.
Paste this one.
As for name and this one.
We don't need this diva or anything, so we're going to just go ahead and remove that part.
We don't need this.
Dave So yes, again, just the basic HTML and playing around with that, I'll copy this email.
This name is going for email and this one is email also.
This one is also email.
So we have name, email and another compulsory field is password.
So we're going to be working with that.
So let's go ahead and say pass word and this is copy password.
This is for password field.
This should be a type password as well.
ID should be password.
Now importantly, this is for the file.
So we need to check out or we need to ask our frontend, our backend engineer that what you are actually
calling this one.
So this is going to say that hey, I'm expecting a file which should name as a photo, so we need to
make that as photo.
So let's go into the IGs and call this one s photo.
So this is for photo and we need to copy this.
This is a type file name is photo.
Name is the most important thing.
Rest, you can just keep it whatever you like.
But this name is the most important property and this should be all up and running and all.
Good.
Now let's go ahead and save this one.
Go back up here, hit a quick reload.
And now hopefully this is going to allow us to test at least our route that how this is going on further
down.
I would like to bring up my MongoDB campus, hit a refresh on this that this is all what we got.
One is already being injected, but now we want to inject the two as well.
So the first name is to email is to add the rate ae dev and the email is this is password.
So actually one, two, three, four, five, six and let's go ahead and choose a file.
I'm going to go ahead and choose the same CP file.
Copy that.
And let's go ahead and hit the submit.
And now it says the path must be a type string received an instance of an object.
So notice here we did the same classic mistake that we talked about in here that, hey, we were actually
let me just show you that at the time of posting the data, we were uploading just the file, which
is not a correct thing.
So we need to give this STEM file path as well.
So this is exactly why testing is necessary.
Let's go back up onto the code editor and this user controller.
So this time we are saying a file dot and we will be saying temp a file path.
So this is all good.
Now let's go ahead and save this.
They should restart the things and let's go back up here.
Back up here.
Hit a reload.
There we go.
No, please don't save anything.
Let's go ahead and try it one more time too.
And this should be to add the rate ae dev and the password is one, two, three, four, five, six.
Let's again choose the file and let's use the classic go.
It's a meanwhile let's go ahead and hit the submit and now this time it's going so cloud.
It takes time.
Our front end engineer can actually work on showing a logo or some kind of a something like that.
So notice here everything is token and everything is coming back nicely.
In fact, our user interestingly, let's go ahead and check out the database now that if I go ahead
and refresh the database, now we have the photo, which is an object.
So notice we are getting the ID, we are getting the URL, we are getting the password.
And this is all going nicely.
Again, we did all of this to make sure that we are properly testing because to be honest, this temp
file path was completely out.
I didn't expected this to be an error.
But again, quickly realize because we have done this in the past, so experience always counts and
also there is no way of testing these things in the postman.
Yes.
There are some some ways of testing this with the postman, but they are really, really tricky.
So we won't be testing it this much.
In fact, I will be kind of a rewriting this.
It makes sense.
I won't be doing it, but it obviously makes sense if I rewrite or refactor this code a little bit that
instead of checking the files directly, I would be checking the files and giving the error message
that if the requests are filed, that photo is not there.
This is your error message.
Please give me the photo as well.
Otherwise, just go ahead and use this one again.
You get the idea of what I'm trying to say.
Again, the code refactoring depends on you and how much time you have.
The whole goal for me in this video was to show you that, yes, there are other ways of testing the
application as well.
In fact, this is not the only way.
There is a way of handling these things in the documentation as well.
Remember the swagger that is also one of the way.
But again, this is all working fine and we'll be just shutting down this entire method just right here.
Let's go ahead and move on further down the road because it's being too much.
Let's go ahead and catch up in the next video.