WEBVTT

1
00:00:00.000 --> 00:00:04.000
All right, so in this lecture, I want to walk you through some course updates that we have

2
00:00:04.000 --> 00:00:09.520
now that we're on the latest versions of all of our dependencies at the time of this recording.

3
00:00:09.520 --> 00:00:14.079
Of course, I'm going to keep this course up to date and publish more updates in the future.

4
00:00:14.079 --> 00:00:19.200
So let's go over the latest breaking changes we have to our application with the latest

5
00:00:19.200 --> 00:00:26.319
dependencies. So our first step is going to be to head back into our abstract repository.

6
00:00:26.319 --> 00:00:32.240
So if we head into our libs common database abstract repository, so here on the latest

7
00:00:32.240 --> 00:00:38.799
versions of mongoose, we can see that our types have actually changed for filter query. So if

8
00:00:38.799 --> 00:00:44.240
you're coming from the previous lecture, our project used to use the filter query type for

9
00:00:44.240 --> 00:00:50.080
all of these filter queries that we passed in to find one and more. But now this is simply

10
00:00:50.080 --> 00:00:55.759
changed to be query filter instead. So everywhere that you're passing filter query, this should

11
00:00:55.759 --> 00:01:02.639
simply just be query filter, they just swapped the order of this type. So this one is very simple

12
00:01:02.639 --> 00:01:07.760
to update. So this is really the only code changes we need to support the latest dependencies.

13
00:01:07.760 --> 00:01:14.000
However, on the latest package versions and infrastructure, I want to introduce a new concept

14
00:01:14.000 --> 00:01:22.639
to our project, which is a pnpm workspace. So recall, in our application, we have our separate

15
00:01:22.639 --> 00:01:29.120
apps that have their own individual package JSON files. Now the advantage of this or the advantage

16
00:01:29.120 --> 00:01:34.879
we're supposed to be getting is that each app here can define dependencies that are specific

17
00:01:34.879 --> 00:01:40.959
just for this particular application, right? We don't need passport and be crypt these auth

18
00:01:40.959 --> 00:01:46.319
related dependencies inside of the other applications inside of their final production

19
00:01:46.319 --> 00:01:51.440
build that we create with a Docker file. So it's really just about a performance optimization and

20
00:01:51.440 --> 00:01:59.120
trying to keep the final image for each app as lean as possible. Now in order to properly support

21
00:01:59.120 --> 00:02:05.199
this, we should be using pnpm workspaces, which is also going to simplify how we install dependencies

22
00:02:05.199 --> 00:02:12.880
inside of our monorepo here. So to support this, I've added a new file to the root of the repo

23
00:02:12.880 --> 00:02:20.559
called pnpm dash workspace dot yaml. And what this does is it defines a configuration for pnpm

24
00:02:20.559 --> 00:02:27.360
workspaces. Now pnpm workspaces is essentially a feature of pnpm. They have it for other package

25
00:02:27.360 --> 00:02:34.639
managers like npm and yarn as well, where you can have multiple package JSONs inside of your folders.

26
00:02:34.639 --> 00:02:41.279
And the package manager in this case, pnpm will scan every package JSON use install all the

27
00:02:41.279 --> 00:02:46.800
dependencies listed for the entire repository. And that's exactly what we want. So here for

28
00:02:46.800 --> 00:02:53.520
packages, we define that our workspace is the apps directory. So any package JSON that pnpm

29
00:02:53.520 --> 00:02:59.600
finds in apps will automatically pick up and install these dependencies we define, which is

30
00:02:59.600 --> 00:03:03.919
what we want when we run locally, right, we want all the dependencies installed. And I'm even going

31
00:03:03.919 --> 00:03:09.600
to show you how to apply this to our Docker setup to keep things optimized. So that's all to say,

32
00:03:09.600 --> 00:03:14.880
make sure you have this pnpm workspace dot yaml created in the root of your project,

33
00:03:14.880 --> 00:03:20.479
we define this packages array, which is the list of directories where we have supported package

34
00:03:20.479 --> 00:03:26.479
JSONs. So in our case, that's just the apps folder. And we also have only built dependencies,

35
00:03:26.479 --> 00:03:35.119
which are auto generated by pnpm. So if we go back to the root of the repository, and you should be

36
00:03:35.119 --> 00:03:41.759
able to rerun pnpm install, this will now detect for workspace projects, which is great, it

37
00:03:41.759 --> 00:03:47.839
corresponds to our four package JSONs that it finds. So each of these is its own package with

38
00:03:47.839 --> 00:03:53.199
its own set of dependencies that pnpm will now install from the root with a simple command.

39
00:03:53.199 --> 00:03:57.679
Alright, so now that we have this pnpm workspace configured, I want to show you the corresponding

40
00:03:57.679 --> 00:04:04.639
changes we've made to the Docker file. So open up off Docker file, for example, you can notice a few

41
00:04:04.639 --> 00:04:11.279
changes here. So on line seven, we added pnpm workspace copy command. So we want to copy over

42
00:04:11.279 --> 00:04:18.160
the workspace file. So we've added this copy command. And we've also added a copy command

43
00:04:18.160 --> 00:04:24.320
to actually retrieve the package JSON for off so that we have the off specific dependencies.

44
00:04:25.040 --> 00:04:32.239
Now importantly, we've also removed a line here. So previously, after copy libs,

45
00:04:32.239 --> 00:04:40.720
we used to have this line where we ran CD apps off and pnpm install. So we've actually gotten

46
00:04:40.720 --> 00:04:46.239
rid of this now because we have pnpm workspace that can handle this for us, we don't have to

47
00:04:46.880 --> 00:04:54.399
install inside of off directly. So remove this. But now, inside of line 30, make sure we copy

48
00:04:54.399 --> 00:04:59.359
the pnpm workspace again, so we still have it. So we're going to copy this in both stages.

49
00:04:59.359 --> 00:05:04.959
Now notice previously, we run a pnpm install on our first stage, we know this, but now when we

50
00:05:04.959 --> 00:05:12.000
run this pnpm install, we are going to have the package JSON for off and the root package JSON.

51
00:05:12.000 --> 00:05:17.760
And since we set up a pnpm workspace to point to the package JSON in apps, this means we're

52
00:05:17.760 --> 00:05:23.519
going to install dependencies for both. And that's exactly the advantage of the pnpm workspace here.

53
00:05:24.480 --> 00:05:28.000
So this is great, we don't need to install directly inside of our apps anymore.

54
00:05:28.880 --> 00:05:35.920
And we also down here, added both package JSON. And down here, we added the workspace config

55
00:05:36.559 --> 00:05:42.399
and the auth specific package JSON. So we also install the prod dependencies for both.

56
00:05:42.399 --> 00:05:46.399
So the pnpm workspace really helps us to make sure we have all the dependencies we need for

57
00:05:46.399 --> 00:05:52.239
every package inside of our project, which is just what we want. Now we've applied this same

58
00:05:53.119 --> 00:05:57.839
exact change to all the Docker files. So I'll leave the commit down below. So you

59
00:05:57.839 --> 00:06:03.119
can analyze every change from this latest update. But these include all of them.

