All right my friends.
Let's do this refactor.
So we're gonna create new file called Abdul.
US that is gonna be responsible for creating the Express app wiring together all the middleware root
handlers and so on.
We're thinking make sure we import that into index not J.S. which is where we're going to actually start
up the app along with all the other associated things that need a connection such as Mongoose and so
on.
So back inside my editor I'm gonna find my s our C directory and inside there I'm going to make a new
file called app.
J.S. is not app jazz app to us.
We are writing typescript.
That's right.
So here is apt.
Yes right here.
And then going to go back over to index.
Yes we're going to do a big copy paste.
So I'm going to take everything from the very top all the way down to that start function to write about
the start function.
So where we currently have app dot use going to take everything I'm going to cut all of it.
Move it over to app.
Yes.
And paste.
Now if we go back over to index out yes we'll immediately see an air around Mongoose.
So I did pull over one import statement that we should have not pulled.
That is the import from Mongoose.
So back inside of APT.
Yes the new file we just created.
I'm going to find that import for mongoose.
I'm going to cut it go backward indexed yes and paste gets Alex Good.
So now we need to make sure that we export the app from the app.
Yes file and import it into index.
Yes.
So we'll go back over to Apple.
Yes I'll go down to the very bottom and I'll add in an export or our app will say export app like some
just you know these curly braces are required because we are doing a named export right here.
We cannot just do just export app by itself.
We have to add in those curly braces.
Now we can go back over to index and at the very top we will import the app
and that should be at I don't see any other errors inside this file.
And I do not see any errors inside of app either looking to save what these files.
And then I'll go back over to scaffold running on my terminal and just make sure that everything started
up correctly.
Yep looks good
so we've now got these two separate files.
We've got our app file that does not start up the Express application it just configure sets.
Now we've got this initial refactor put together.
Rick Paul's right here.
We're going to start to install super tests this Mongo DB in memory copy thing against I'll just wire
up all this stuff starting in the next video.