1 00:00:01,140 --> 00:00:02,170 All right my friends. 2 00:00:02,190 --> 00:00:03,290 Let's do this refactor. 3 00:00:03,330 --> 00:00:04,990 So we're gonna create new file called Abdul. 4 00:00:05,040 --> 00:00:10,020 US that is gonna be responsible for creating the Express app wiring together all the middleware root 5 00:00:10,020 --> 00:00:11,470 handlers and so on. 6 00:00:11,470 --> 00:00:15,420 We're thinking make sure we import that into index not J.S. which is where we're going to actually start 7 00:00:15,480 --> 00:00:20,700 up the app along with all the other associated things that need a connection such as Mongoose and so 8 00:00:20,700 --> 00:00:21,690 on. 9 00:00:21,690 --> 00:00:28,730 So back inside my editor I'm gonna find my s our C directory and inside there I'm going to make a new 10 00:00:28,730 --> 00:00:31,560 file called app. 11 00:00:31,690 --> 00:00:34,690 J.S. is not app jazz app to us. 12 00:00:34,850 --> 00:00:36,310 We are writing typescript. 13 00:00:36,310 --> 00:00:38,410 That's right. 14 00:00:38,440 --> 00:00:39,490 So here is apt. 15 00:00:39,490 --> 00:00:40,580 Yes right here. 16 00:00:40,840 --> 00:00:42,470 And then going to go back over to index. 17 00:00:42,490 --> 00:00:46,530 Yes we're going to do a big copy paste. 18 00:00:46,530 --> 00:00:56,260 So I'm going to take everything from the very top all the way down to that start function to write about 19 00:00:56,260 --> 00:00:57,370 the start function. 20 00:00:57,450 --> 00:01:01,660 So where we currently have app dot use going to take everything I'm going to cut all of it. 21 00:01:01,910 --> 00:01:02,740 Move it over to app. 22 00:01:02,780 --> 00:01:03,300 Yes. 23 00:01:03,320 --> 00:01:07,760 And paste. 24 00:01:07,840 --> 00:01:11,750 Now if we go back over to index out yes we'll immediately see an air around Mongoose. 25 00:01:11,770 --> 00:01:14,990 So I did pull over one import statement that we should have not pulled. 26 00:01:15,010 --> 00:01:16,360 That is the import from Mongoose. 27 00:01:16,810 --> 00:01:17,810 So back inside of APT. 28 00:01:17,830 --> 00:01:19,150 Yes the new file we just created. 29 00:01:19,150 --> 00:01:20,890 I'm going to find that import for mongoose. 30 00:01:20,890 --> 00:01:28,880 I'm going to cut it go backward indexed yes and paste gets Alex Good. 31 00:01:29,000 --> 00:01:32,700 So now we need to make sure that we export the app from the app. 32 00:01:32,720 --> 00:01:35,070 Yes file and import it into index. 33 00:01:35,090 --> 00:01:36,290 Yes. 34 00:01:36,320 --> 00:01:38,100 So we'll go back over to Apple. 35 00:01:38,120 --> 00:01:48,320 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 36 00:01:51,250 --> 00:01:54,820 just you know these curly braces are required because we are doing a named export right here. 37 00:01:54,820 --> 00:01:58,900 We cannot just do just export app by itself. 38 00:01:58,900 --> 00:02:01,720 We have to add in those curly braces. 39 00:02:01,900 --> 00:02:06,290 Now we can go back over to index and at the very top we will import the app 40 00:02:11,980 --> 00:02:17,330 and that should be at I don't see any other errors inside this file. 41 00:02:17,330 --> 00:02:21,670 And I do not see any errors inside of app either looking to save what these files. 42 00:02:21,890 --> 00:02:25,640 And then I'll go back over to scaffold running on my terminal and just make sure that everything started 43 00:02:25,640 --> 00:02:26,970 up correctly. 44 00:02:27,140 --> 00:02:28,040 Yep looks good 45 00:02:31,640 --> 00:02:34,130 so we've now got these two separate files. 46 00:02:34,130 --> 00:02:39,940 We've got our app file that does not start up the Express application it just configure sets. 47 00:02:39,980 --> 00:02:42,450 Now we've got this initial refactor put together. 48 00:02:42,440 --> 00:02:43,280 Rick Paul's right here. 49 00:02:43,280 --> 00:02:51,980 We're going to start to install super tests this Mongo DB in memory copy thing against I'll just wire 50 00:02:51,980 --> 00:02:53,660 up all this stuff starting in the next video.