You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is particularly helpful in identifying changes that may have gone unnoticed during code reviews. For instance, let's say someone has changed the scope of a **deeply nested provider**. This change might not be immediately obvious to the reviewer, but with Devtools, we can easily spot such changes and make sure that they're intentional. Or if we remove a guard from a specific endpoint, it will show up as affected in the report. Now if we didn't have integration or e2e tests for that route, we might not notice that it's no longer protected, and by the time we do, it could be too late.
55
+
56
+
Similarly, if we're working on a **large codebase** and we modify a module to be global, we'll see how many edges were added to the graph, and this - in most cases - is a sign that we're doing something wrong.
57
+
54
58
#### Build preview
55
59
56
60
For every published graph we can go back in time and preview how it looked before by clicking at the **Preview** button. Furthermore, if the report was generated, we should see the differences higlighted on our graph:
The ability to go back in time lets you investigate and troubleshoot the issue by comparing the current graph with the previous one. Depending on how you set things up, every pull request (or even every commit) will have a corresponding snapshot in the registry, so you can easily go back in time and see what changed. Think of Devtools as a Git but with an understanding of how Nest constructs your application graph, and with the ability to **visualize** it.
71
+
66
72
#### Integrations: Github Actions
67
73
68
74
First let's start from creating a new Github workflow in the `.github/workflows` directory in our project and call it, for example, `publish-graph.yml`. Inside this file, let's use the following definition:
> info **Hint** As you can see on the screenshot above, every module connect to the `InternalCoreModule`. `InternalCoreModule` is a global module that is always imported into the root module. Since it's registered as a global node, Nest automatically creates edges between all of the modules and the `InternalCoreModule` node. Now, if you want to hide global modules from the graph, you can use the "Hide global modules" checkbox (in the sidebar).
48
+
47
49
So as we can see, `DevtoolsModule` makes your application expose an additional HTTP server (on port 8000) that the Devtools application will use to introspect your app.
48
50
49
51
Just to double-check that everything works as expected, change the graph view to "Classes". You should see the following screen:
@@ -56,10 +58,14 @@ To focus on a specific node, click on the rectangle and the graph will show a po
> info **Hint** To export a graph as an image, click on the **Export as PNG** button in the right corner of the graph.
62
+
59
63
Using the form controls located in the sidebar (on the left), you can control edges proximity to, for example, visualize a specific application sub-tree:
This can be particularly useful when you have **new developers** on your team and you want to show them how your application is structured. You can also use this feature to visualize a specific module (e.g. `TasksModule`) and all of its dependencies, which can come in handy when you're breaking down a large application into smaller modules (for example, individual micro-services).
68
+
63
69
#### Investigating the "Cannot resolve dependency" error
64
70
65
71
> info **Note** This feature is supported for `@nestjs/core` >= `v9.3.10`.
@@ -106,24 +112,46 @@ When you navigate to the **Routes explorer** page, you should see all of the reg
> info **Hint** This page shows not only HTTP routes, but also all of the other entrypoints (e.g. WebSockets, gRPC, GraphQL resolvers etc.).
116
+
117
+
Entrypoints are grouped by their host controllers. You can also use the search bar to find a specific entrypoint.
118
+
119
+
If you click on a specific entrypoint, **a flow graph** will be displayed. This graph shows the execution flow of the entrypoint (e.g. guards, interceptors, pipes, etc. bound to this route). This is particularly useful when you want to understand how the request/response cycle looks for a specific route, or when troubleshooting why a specific guard/interceptor/pipe is not being executed.
120
+
109
121
#### Sandbox
110
122
111
123
To execute JavaScript code on the fly & interact with your application in real-time, navigate to the **Sandbox** page:
The playground can be used to test and debug API endpoints in **real-time**, allowing developers to quickly identify and fix issues without using, for example, an HTTP client. We can also bypass the authentication layer, and so we no longer need that extra step of logging in, or even a special user account for testing purposes. For event-driven applications, we can also trigger events directly from the playground, and see how the application reacts to them.
128
+
129
+
Anything that gets logged down is streamlined to the playground's console, so we can easily see what's going on.
130
+
131
+
Just execute the code **on the fly** and see the results instantly, without having to rebuild the application and restart the server.
> info **Hint** To pretty display an array of objects, use the `console.table()` (or just `table()`) function.
136
+
115
137
#### Bootstrap performance analyzer
116
138
117
139
To see a list of all class nodes (controllers, providers, enhancers, etc.) and their corresponding instantiation times, navigate to the **Bootstrap performance** page:
This page is particularly useful when you want to identify the slowest parts of your application's bootstrap process (e.g. when you want to optimize the application's startup time which is crucial for, for example, serverless environments).
144
+
121
145
#### Audit
122
146
123
147
To see the auto-generated audit - errors/warnings/hints that the application came up with while analyzing your serialized graph, navigate to the **Audit** page:
0 commit comments