1
00:00:00,440 --> 00:00:05,900
All right, and once we're familiar with the setup now, let's kick things into gear and of course,

2
00:00:05,900 --> 00:00:13,100
let's start working on a project and the first thing we need to do is install all dependencies and we'll

3
00:00:13,100 --> 00:00:15,000
do that by navigating through the star.

4
00:00:15,230 --> 00:00:24,020
So, again, big picture, we're looking for fourth project, so zero four story API and learn more

5
00:00:24,020 --> 00:00:25,700
specifically the star.

6
00:00:26,120 --> 00:00:32,720
And I think the fastest way is just typing speed and then take the folder drag and drop.

7
00:00:32,790 --> 00:00:38,380
And of course we're sitting in the folder and then we're on NPM install.

8
00:00:39,080 --> 00:00:45,170
And while the project dependencies are being installed, let me just mention that in this project we

9
00:00:45,170 --> 00:00:50,390
will set up everything from the scratch, just like we did in the previous project, just so we can

10
00:00:50,390 --> 00:00:54,020
keep on practicing, on getting our project off the ground.

11
00:00:54,380 --> 00:01:01,170
But starting with the next project, some of the boilerplate code, the one that will type in this and

12
00:01:01,170 --> 00:01:04,290
few of the following videos will be already prepared for you.

13
00:01:04,580 --> 00:01:10,540
So that way we can write a way, cut to the chase and don't waste our time on stuff we already covered.

14
00:01:10,940 --> 00:01:16,430
And once the dependencies are there, then, of course, I just need to check the back of Jason and

15
00:01:16,430 --> 00:01:20,030
I can clearly see that the command is and start.

16
00:01:20,270 --> 00:01:27,530
And of course, we just open up the OR so we'll go here with ampm start and we are in a good place now,

17
00:01:27,530 --> 00:01:28,100
of course.

18
00:01:28,130 --> 00:01:32,600
Let me navigate through the objets and here let's start adding the code.

19
00:01:33,020 --> 00:01:39,530
And the first thing that I want to do is get that package, the DOT, and we so have access to environmental

20
00:01:39,530 --> 00:01:45,350
variables because of course, again, we'll connect to our database and we simply do that by typing

21
00:01:45,350 --> 00:01:49,160
require then we're looking for data and not packaging em.

22
00:01:49,370 --> 00:01:52,460
And if you remember, we invoke config.

23
00:01:52,850 --> 00:01:57,680
Now, of course, we haven't set up the data and yet the file in the root of our project.

24
00:01:58,080 --> 00:02:02,570
But we definitely need to use the data entry if we want to access the variables.

25
00:02:02,810 --> 00:02:08,330
And of course, we'll work on data entry once we actually start connecting to the database.

26
00:02:08,660 --> 00:02:15,590
Then I'll add a comment of a sink Hirsch and you'll see why I do that in your videos.

27
00:02:15,950 --> 00:02:17,990
And then of course, we want to open up the Express.

28
00:02:18,210 --> 00:02:23,430
So we go here with Consed and Express is equal to express, of course.

29
00:02:23,780 --> 00:02:30,470
So I go here with Require Online Express and then once I have the package, then of course we want to

30
00:02:30,470 --> 00:02:36,410
open up the app so we goes up is equal to express and then of course we invoke it.

31
00:02:36,800 --> 00:02:39,710
Now start listening for the server later.

32
00:02:40,250 --> 00:02:46,100
Now I just want to import your middleware functions that we set up in the previous project and those

33
00:02:46,100 --> 00:02:46,960
are our handler.

34
00:02:47,360 --> 00:02:53,660
So this one over here more essentially we just catch all the errors and then we decide what is going

35
00:02:53,660 --> 00:02:54,500
to be our response.

36
00:02:54,740 --> 00:02:59,900
And then the second one is not found because this is going to be the case where I don't want to repeat

37
00:02:59,900 --> 00:03:03,340
the same stuff we already covered in the previous project.

38
00:03:04,100 --> 00:03:06,140
So that's the code that I already prepared for you.

39
00:03:06,530 --> 00:03:11,420
And now we simply need to import both of them and come up with some meaningful names.

40
00:03:11,930 --> 00:03:18,220
In this case, I'm going to go with not found and middleware, and that is equal to require.

41
00:03:18,470 --> 00:03:24,920
And of course, I'm looking in the middle of a folder and then more specifically, we're looking for

42
00:03:24,920 --> 00:03:31,400
that, not from one will copy and paste and then just change the name where instead of not found, we're

43
00:03:31,400 --> 00:03:32,240
going to go with error.

44
00:03:32,780 --> 00:03:36,080
And of course, the father we're looking for is also different.

45
00:03:36,260 --> 00:03:37,850
And I called it error handler.

46
00:03:38,150 --> 00:03:44,690
And once we have both of these imports in place now, of course, we can set up the ExpressJet on middleware

47
00:03:44,690 --> 00:03:46,310
as well while we're at it.

48
00:03:46,610 --> 00:03:50,330
And you're not in here, let me just add a comment.

49
00:03:50,480 --> 00:03:58,100
And then, like I said, we're going to go about that years and then we'll pass in the Express and we're

50
00:03:58,100 --> 00:04:02,870
invoking Jason Vanimo, set up our one lonely route for the time being.

51
00:04:03,200 --> 00:04:05,180
And essentially this is just for testing.

52
00:04:05,460 --> 00:04:10,730
So let me add here roots eventually, of course, and set up the router and all that.

53
00:04:10,730 --> 00:04:16,370
But for the time being, we're just going to go and get we're going to be looking for on page, meaning

54
00:04:16,370 --> 00:04:20,019
the fourth and final set up András.

55
00:04:20,360 --> 00:04:22,100
So, of course, our callback function.

56
00:04:22,340 --> 00:04:24,590
And here, let's say András.

57
00:04:24,950 --> 00:04:28,550
And as far as the response, I'm actually going to be cheating a little bit more.

58
00:04:28,550 --> 00:04:36,560
I'm going to go across that sand and then since I can pass and so them all, I'll also hitting one name

59
00:04:36,560 --> 00:04:38,420
of the project Store API.

60
00:04:39,320 --> 00:04:47,450
And of course, now I want to close my one and also I want to set up a link that will navigate to the

61
00:04:47,450 --> 00:04:50,000
product page, the one that we haven't set up yet.

62
00:04:50,510 --> 00:04:56,960
And here, let's just go with H.F. And I guess more correctly, the products are out because technically

63
00:04:56,960 --> 00:04:58,070
we'll be sending Jason.

64
00:04:58,400 --> 00:04:59,300
It's not going to be a page.

65
00:04:59,600 --> 00:05:04,400
And and here we go with forward slash API and then version one product.

66
00:05:05,860 --> 00:05:11,520
And I'm purposely keeping this open version one, just because we already have the global variable in

67
00:05:11,530 --> 00:05:20,290
a postman, um, as far as the text, let me just close it here and then close the actual tags and then

68
00:05:20,440 --> 00:05:22,930
say products are out that way.

69
00:05:22,930 --> 00:05:28,460
If we ever need to, we can just quickly navigate from the browser as well.

70
00:05:28,780 --> 00:05:31,660
So let's say this one and let's keep it going.

71
00:05:32,020 --> 00:05:39,430
And in here, I'll add a comment for products that will set up in the upcoming videos.

72
00:05:39,640 --> 00:05:43,660
And then I want to use both of these Menelaus so we have not found an error.

73
00:05:43,780 --> 00:05:51,050
And Laura and I simply want to use Abdah used, but make sure you do that right after the abduction.

74
00:05:51,430 --> 00:05:53,380
So say here, abduct, use.

75
00:05:53,380 --> 00:05:58,960
And first, let's just look for not found one and then we'll do the same thing with the other one as

76
00:05:58,960 --> 00:05:59,250
well.

77
00:05:59,530 --> 00:06:06,010
So past here, Urmila, then I want to set up my start function, but initially I'm not going to use

78
00:06:06,010 --> 00:06:07,060
that connect DB.

79
00:06:07,390 --> 00:06:09,820
So simply just go with that.

80
00:06:09,820 --> 00:06:14,980
Listen, but we'll place it in a start because of course eventually we will connect to the database.

81
00:06:15,190 --> 00:06:21,180
So we'll just start over here, start and it's going to be I think online as far as the functionality,

82
00:06:21,190 --> 00:06:29,050
let's just go try to catch um and eventually will connect DB Connect DB part for the time being.

83
00:06:29,050 --> 00:06:33,160
We just simply want to go with that, listen and learn what is the port.

84
00:06:33,160 --> 00:06:35,260
Well we need to create that port variable.

85
00:06:35,740 --> 00:06:41,170
And if you remember, the end of the previous project effectively will set this up dynamic where it

86
00:06:41,170 --> 00:06:47,380
will go with const port is equal to process data entry and then port.

87
00:06:47,740 --> 00:06:51,280
If it is undefined, then of course we can hardcourt this value.

88
00:06:51,760 --> 00:06:55,950
And I believe that in my final one I have five thousand.

89
00:06:56,260 --> 00:07:02,740
So keep this one at three thousand on line will pass in that variable here, the port one.

90
00:07:03,010 --> 00:07:06,490
And then of course let's set up the console lock just so we can see that everything works.

91
00:07:06,910 --> 00:07:14,800
And here I will just say server is listening to the port and then whatever is the port variable.

92
00:07:15,280 --> 00:07:16,510
So let's say you're here.

93
00:07:17,520 --> 00:07:22,870
Port and allowed those three dots, and then if there is an error, of course, we'll go with council

94
00:07:22,890 --> 00:07:27,630
log and the error and now finally we can just invoke start.

95
00:07:28,050 --> 00:07:34,800
And if you can see in a council server is listening on Port three thousand, then of course we are in

96
00:07:34,800 --> 00:07:35,270
good shape.

97
00:07:35,520 --> 00:07:41,190
And if you want to test it out in the browser, just navigate there, look for localhost three thousand.

98
00:07:41,610 --> 00:07:43,670
And of course, this is what you should see.

99
00:07:43,980 --> 00:07:45,810
We had one as well.

100
00:07:46,260 --> 00:07:50,370
Now we don't have the route for API version one product.

101
00:07:51,000 --> 00:07:57,270
We can actually test our four or four since we can see the route does not exist text.

102
00:07:57,600 --> 00:08:02,570
And if we have all of this in place now, of course, we can move on to our next topic.

