1 00:00:00,720 --> 00:00:04,930 The last video we did a little bit of tricky debugging and we realized that our air handler that we 2 00:00:04,930 --> 00:00:09,970 had defined inside of our common module wasn't really giving us enough information back if there's ever 3 00:00:09,970 --> 00:00:12,740 some kind of error that we weren't really expecting to see. 4 00:00:12,760 --> 00:00:18,140 We should really console log it or do something with it so that you and I can review our logs at some 5 00:00:18,130 --> 00:00:22,430 point the future and say oh look something's going wrong that we weren't really expecting. 6 00:00:22,540 --> 00:00:28,450 So I'm inside my coming module I'm in the middle where's directory air handler to us if we get past 7 00:00:28,450 --> 00:00:29,740 this if statement right here. 8 00:00:29,860 --> 00:00:31,180 Let's log this error. 9 00:00:31,330 --> 00:00:39,680 So I going to do a console dot air and log out the air that just occurred I'll then save this file. 10 00:00:39,800 --> 00:00:45,840 So we just made a change to our common module to get that update over to our tickets project. 11 00:00:45,920 --> 00:00:49,150 We have to rebuild and republish the common module. 12 00:00:49,160 --> 00:00:53,650 We then have to do an update to the module version inside of our tickets project. 13 00:00:53,750 --> 00:00:55,800 So it is a little bit of a laborious process. 14 00:00:55,820 --> 00:00:58,620 But remember we set up that little script to help us out. 15 00:00:58,680 --> 00:01:01,490 I'm going to close the error handler. 16 00:01:01,540 --> 00:01:02,820 I'm gonna go back over to my terminal. 17 00:01:02,830 --> 00:01:12,330 I'm going to stop my tests with a control C and then go back up change into my common directory and 18 00:01:12,330 --> 00:01:18,190 I'll run that NPM run up so remember that's going to increment our version number clean up the bill 19 00:01:18,190 --> 00:01:23,410 directory rebuild do the get commit all that kind of stuff and then eventually publish it off to NPM 20 00:01:24,760 --> 00:01:25,620 OK there we go. 21 00:01:25,680 --> 00:01:27,950 About Version 1.0 1 2. 22 00:01:27,970 --> 00:01:30,720 Now at this point you might be only at like 1.0 for something. 23 00:01:30,730 --> 00:01:34,630 Again every now and then I make a mistake after we record a video. 24 00:01:34,630 --> 00:01:40,240 And so I just happen to be at this version now that I'm going to go now back over to my tickets directory 25 00:01:41,570 --> 00:01:44,980 and instead of tickets we now need to update that package. 26 00:01:45,080 --> 00:01:51,160 Remember the package we can find cyber packages out Jason File inside of tickets for me I need to update 27 00:01:51,460 --> 00:01:52,400 SMG tickets. 28 00:01:52,480 --> 00:01:59,830 Common you're gonna find whatever your organization name was instead will do inside of tickets NPM update 29 00:02:00,860 --> 00:02:11,640 your organization name flash common it's all run that and I should see the updated version printed out 30 00:02:11,670 --> 00:02:13,240 once it does the install. 31 00:02:13,240 --> 00:02:13,760 There we go. 32 00:02:13,770 --> 00:02:14,190 Very good. 33 00:02:15,260 --> 00:02:20,240 Now we can start artist suite back up and hopefully we're going to end up seeing a better error message 34 00:02:20,240 --> 00:02:25,430 or some error message for that matter around getting that invalid I.D. so I'm going to do an MP and 35 00:02:25,430 --> 00:02:26,030 run test 36 00:02:30,110 --> 00:02:32,830 and after a brief warm up period there we go. 37 00:02:32,840 --> 00:02:38,420 So it's way more information we probably want but at least it is an area that we are seeing now if anything 38 00:02:38,420 --> 00:02:39,220 goes wrong. 39 00:02:39,350 --> 00:02:44,050 We will see it even if we do not have some custom air built to deal with it. 40 00:02:45,640 --> 00:02:49,660 So now it would be a lot easier for us if we had this originally to take a look at this and say Oh okay 41 00:02:49,960 --> 00:02:56,870 yeah we put in some invalid I.D. we've got some it looks like that we need a normal real I.D. That's 42 00:02:57,080 --> 00:02:58,510 how we can fix this. 43 00:02:58,540 --> 00:03:04,190 Well let's go back over to our test file but here is show test done to yes. 44 00:03:04,240 --> 00:03:06,340 I've still got a console log right here of response body. 45 00:03:06,350 --> 00:03:08,110 I'm going to clean that up. 46 00:03:08,260 --> 00:03:10,160 I don't need to get access to the response anymore. 47 00:03:10,170 --> 00:03:15,720 I'm gonna clean that up and I'm going to restore at the very end of that chain. 48 00:03:15,720 --> 00:03:17,020 The expect or. 49 00:03:17,030 --> 00:03:24,090 Oh for and then going to find this get right here and we're going to put a real I.D. inside there. 50 00:03:24,310 --> 00:03:30,130 We can either try to write out a real I.D. manually or alternatively we could try to generate one for 51 00:03:30,130 --> 00:03:31,240 ourselves. 52 00:03:31,280 --> 00:03:35,830 I think I'd be a lot better to use some built in function to generate this idea for us because to be 53 00:03:35,830 --> 00:03:41,020 honest with you kind of easy for us to not get the like twelve or twenty four character whatever it 54 00:03:41,020 --> 00:03:41,360 was. 55 00:03:41,360 --> 00:03:43,000 I.D. correct. 56 00:03:43,000 --> 00:03:47,890 So I'm going to turn this string into a template string by putting in the tactics I can remove that 57 00:03:47,890 --> 00:03:53,860 hardcoded one right there and replace it with some interpolation to generate this I.D. We're going to 58 00:03:53,890 --> 00:03:55,480 import Mongoose 59 00:04:00,250 --> 00:04:04,160 then inside of the function body I'm going to create a new variable called I.D.. 60 00:04:04,360 --> 00:04:09,180 So we're going to use a function that is built into muggers to generate a normal or a realistic valid 61 00:04:09,180 --> 00:04:17,170 ID looking out for us to say new Mongoose types dot object I.D. We're going to invoke that and they're 62 00:04:17,170 --> 00:04:19,600 going to call to hex string 63 00:04:22,750 --> 00:04:27,650 like so and then we'll pass them the I.D. right there. 64 00:04:27,680 --> 00:04:32,300 So as you guessed this is a function to generate a valid object I.D. We're then going to toss it into 65 00:04:32,300 --> 00:04:35,710 that string and no longer shall we get some air coming out of mongoose. 66 00:04:35,780 --> 00:04:41,090 When we tried to make that query and fetch the ticket by I.D. So let's say this and see if our tests 67 00:04:41,090 --> 00:04:46,620 are now passing a flip back over and there we go. 68 00:04:46,710 --> 00:04:47,930 I'll set. 69 00:04:48,130 --> 00:04:52,900 Well I think you can agree with me that generating the idea with this long and right here is not super 70 00:04:52,900 --> 00:04:57,430 ideal if you want to you could certainly make some kind of helper function and tuck it away inside of 71 00:04:57,430 --> 00:05:00,180 some utilize or helper file inside that test directory. 72 00:05:00,310 --> 00:05:02,470 But I will leave that up to you. 73 00:05:02,470 --> 00:05:02,740 All right. 74 00:05:02,830 --> 00:05:05,920 Well I think that our show stuff is now pretty much working. 75 00:05:05,920 --> 00:05:08,140 This is looking pretty reasonable to me at this point. 76 00:05:08,200 --> 00:05:09,520 So let's take a pause right here. 77 00:05:09,520 --> 00:05:10,440 Continue in just a moment.