1
00:00:00,210 --> 00:00:05,730
All right, and once we have covered general info about these security packages now or simply want to

2
00:00:05,730 --> 00:00:09,060
go to objets, we want to import them one by one.

3
00:00:09,510 --> 00:00:11,880
And of course, we just want to invoke them.

4
00:00:12,330 --> 00:00:17,640
And in my case, I'm going to do it over here where we have expressed that Jason and I'm going to start

5
00:00:17,640 --> 00:00:19,530
by providing comment extra.

6
00:00:20,040 --> 00:00:23,130
And let's say, security packages.

7
00:00:23,640 --> 00:00:25,650
And then we're looking for helmet first.

8
00:00:26,070 --> 00:00:31,950
And of course, equal to the package helmet, then the same for cause.

9
00:00:32,070 --> 00:00:38,250
So this is the course package and we have one for cross-site scripting, so require.

10
00:00:38,710 --> 00:00:42,270
And the package name here is x clean.

11
00:00:42,600 --> 00:00:44,850
And the last one is expressed right limit.

12
00:00:45,240 --> 00:00:50,580
And I'm purposely setting this one up last just because there's going to be a little bit of configuration

13
00:00:50,580 --> 00:00:51,180
there as well.

14
00:00:51,570 --> 00:00:54,630
So let's go with the choir and express, right?

15
00:00:54,740 --> 00:00:56,850
Limit one, let's say.

16
00:00:56,880 --> 00:00:59,220
Keep scrolling where we have the Jason.

17
00:00:59,650 --> 00:01:01,140
Let's start with our helmet.

18
00:01:01,440 --> 00:01:02,730
So I have that years.

19
00:01:03,180 --> 00:01:07,680
And like I said, we just invoke the helmet the same for us of them.

20
00:01:08,010 --> 00:01:14,940
So that years and of course, in here I'm looking for cause I can just copy and paste that I want to

21
00:01:14,940 --> 00:01:17,400
go for cross-site scripting one.

22
00:01:17,730 --> 00:01:26,190
So access and again, we invoke it and then we have to limit to once again have that use that right

23
00:01:26,430 --> 00:01:26,970
limit.

24
00:01:27,360 --> 00:01:30,000
And you not think I'm going to change the name here?

25
00:01:30,330 --> 00:01:32,400
I'm going to go right limiter.

26
00:01:32,760 --> 00:01:35,430
Not a big deal, but just my preference.

27
00:01:35,850 --> 00:01:38,250
And if we take a look at the package docs.

28
00:01:39,290 --> 00:01:46,310
Effectively, what we want to set up is the time, so in how long and how many requests.

29
00:01:46,820 --> 00:01:53,690
And as you can see here, they provide an object and properties are window milliseconds.

30
00:01:54,050 --> 00:01:57,710
So effectively we get this in milliseconds and we're just set time.

31
00:01:58,040 --> 00:02:02,540
And as you can see, this is example for 15 minutes and then how many requests?

32
00:02:02,990 --> 00:02:07,250
And also, if you keep on scrolling, you'll notice their responses.

33
00:02:07,670 --> 00:02:13,520
So by default, the message is going to be too many requests and the error response is going to be four

34
00:02:13,520 --> 00:02:13,880
twenty.

35
00:02:14,510 --> 00:02:17,960
And once we're clear on set up, let's implement it in our own up.

36
00:02:18,470 --> 00:02:25,580
So first, what I want to do is move this rate limiter up, so I want to set it up as our first middleware.

37
00:02:26,150 --> 00:02:32,540
And then in order to speed this up, we'll just grab the object here with those milliseconds as well

38
00:02:32,540 --> 00:02:39,560
as the Mac's request will invoke it here, copy and paste and our limiter is in place.

39
00:02:39,980 --> 00:02:45,920
Lastly, according to their docs, if our application is behind reverse proxy, which is going to be

40
00:02:46,100 --> 00:02:51,590
case since we'll push this up to her uncle, we also want to implement this app.

41
00:02:51,590 --> 00:02:53,420
That's that trust proxy.

42
00:02:53,720 --> 00:02:55,130
So let's just take this code.

43
00:02:56,010 --> 00:02:58,860
And place it before, do you rate limiter?

44
00:02:59,280 --> 00:03:02,430
And with this in place, we have our security packages.

45
00:03:02,670 --> 00:03:04,550
So now we're going to move on to our next step.

