All right, so in this lecture, I want to walk you through some course updates that we have
now that we're on the latest versions of all of our dependencies at the time of this recording.
Of course, I'm going to keep this course up to date and publish more updates in the future.
So let's go over the latest breaking changes we have to our application with the latest
dependencies. So our first step is going to be to head back into our abstract repository.
So if we head into our libs common database abstract repository, so here on the latest
versions of mongoose, we can see that our types have actually changed for filter query. So if
you're coming from the previous lecture, our project used to use the filter query type for
all of these filter queries that we passed in to find one and more. But now this is simply
changed to be query filter instead. So everywhere that you're passing filter query, this should
simply just be query filter, they just swapped the order of this type. So this one is very simple
to update. So this is really the only code changes we need to support the latest dependencies.
However, on the latest package versions and infrastructure, I want to introduce a new concept
to our project, which is a pnpm workspace. So recall, in our application, we have our separate
apps that have their own individual package JSON files. Now the advantage of this or the advantage
we're supposed to be getting is that each app here can define dependencies that are specific
just for this particular application, right? We don't need passport and be crypt these auth
related dependencies inside of the other applications inside of their final production
build that we create with a Docker file. So it's really just about a performance optimization and
trying to keep the final image for each app as lean as possible. Now in order to properly support
this, we should be using pnpm workspaces, which is also going to simplify how we install dependencies
inside of our monorepo here. So to support this, I've added a new file to the root of the repo
called pnpm dash workspace dot yaml. And what this does is it defines a configuration for pnpm
workspaces. Now pnpm workspaces is essentially a feature of pnpm. They have it for other package
managers like npm and yarn as well, where you can have multiple package JSONs inside of your folders.
And the package manager in this case, pnpm will scan every package JSON use install all the
dependencies listed for the entire repository. And that's exactly what we want. So here for
packages, we define that our workspace is the apps directory. So any package JSON that pnpm
finds in apps will automatically pick up and install these dependencies we define, which is
what we want when we run locally, right, we want all the dependencies installed. And I'm even going
to show you how to apply this to our Docker setup to keep things optimized. So that's all to say,
make sure you have this pnpm workspace dot yaml created in the root of your project,
we define this packages array, which is the list of directories where we have supported package
JSONs. So in our case, that's just the apps folder. And we also have only built dependencies,
which are auto generated by pnpm. So if we go back to the root of the repository, and you should be
able to rerun pnpm install, this will now detect for workspace projects, which is great, it
corresponds to our four package JSONs that it finds. So each of these is its own package with
its own set of dependencies that pnpm will now install from the root with a simple command.
Alright, so now that we have this pnpm workspace configured, I want to show you the corresponding
changes we've made to the Docker file. So open up off Docker file, for example, you can notice a few
changes here. So on line seven, we added pnpm workspace copy command. So we want to copy over
the workspace file. So we've added this copy command. And we've also added a copy command
to actually retrieve the package JSON for off so that we have the off specific dependencies.
Now importantly, we've also removed a line here. So previously, after copy libs,
we used to have this line where we ran CD apps off and pnpm install. So we've actually gotten
rid of this now because we have pnpm workspace that can handle this for us, we don't have to
install inside of off directly. So remove this. But now, inside of line 30, make sure we copy
the pnpm workspace again, so we still have it. So we're going to copy this in both stages.
Now notice previously, we run a pnpm install on our first stage, we know this, but now when we
run this pnpm install, we are going to have the package JSON for off and the root package JSON.
And since we set up a pnpm workspace to point to the package JSON in apps, this means we're
going to install dependencies for both. And that's exactly the advantage of the pnpm workspace here.
So this is great, we don't need to install directly inside of our apps anymore.
And we also down here, added both package JSON. And down here, we added the workspace config
and the auth specific package JSON. So we also install the prod dependencies for both.
So the pnpm workspace really helps us to make sure we have all the dependencies we need for
every package inside of our project, which is just what we want. Now we've applied this same
exact change to all the Docker files. So I'll leave the commit down below. So you
can analyze every change from this latest update. But these include all of them.