From 295ff660525d977f80aa7391f80a37e7e13a16d3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kamil=20My=C5=9Bliwiec?= Components
The controllers should only handle HTTP requests and delegate more complex tasks to the components.
The components are a plain TypeScript classes with @Component()
decorator.
+Hint Since Nest enables the possibility to design, organize the dependencies in more OO-way, we strongly recommend to follow the SOLID principles.@@ -50,7 +50,7 @@Dependency Injection
Nest is built around the strong design pattern, which is commonly known as a Dependency Injection. There's a great article about this concept in the official Angular documentation. -+Hint Learn more about the Dependency Injection in Nest here.diff --git a/src/app/homepage/pages/controllers/controllers.component.html b/src/app/homepage/pages/controllers/controllers.component.html index a79d1defc8..8873eb5018 100644 --- a/src/app/homepage/pages/controllers/controllers.component.html +++ b/src/app/homepage/pages/controllers/controllers.component.html @@ -59,7 +59,7 @@
Request object
In fact, Nest is using express request object. We can force Nest to inject the request object into handler using@Req()
decorator. -+Hint There's a@@ -144,7 +144,7 @@@types/express
package and we strongly recommend to use it (Request
has its own typings).Async / await
We love modern JavaScript, and we know that the data extraction is mostly asynchronous. That's why Nest supportsasync
functions, and works pretty well with them. -+Hint Learn more aboutasync / await
here!diff --git a/src/app/homepage/pages/exception-filters/exception-filters.component.html b/src/app/homepage/pages/exception-filters/exception-filters.component.html index a2b76739ba..717da34be6 100644 --- a/src/app/homepage/pages/exception-filters/exception-filters.component.html +++ b/src/app/homepage/pages/exception-filters/exception-filters.component.html @@ -24,8 +24,8 @@
HttpException
{{ createMethod }}
-{{ createMethodJs }}
- Notice I've used theHttpStatus
here. It's just a helper enum imported from the@nestjs/common
package. ++ Warning I have used theHttpStatus
here. It's a helper enum imported from the@nestjs/common
package.Now when the client will call this endpoint, the response would looks like below: @@ -103,7 +103,7 @@
Exception Filters
The
-response
is a native express response object. Theexception
is a currently processed exception.+Hint Every exception filter should implement theExceptionFilter
interface. It forces to provide thecatch()
method with the proper signature.@@ -119,8 +119,8 @@
Exception Filters
{{ forbiddenCreateMethodWithFilter }}
-{{ forbiddenCreateMethodWithFilterJs }}
- Hint The@UseFilters()
decorator is imported from the@nestjs/common
package. ++ Warning The@UseFilters()
decorator is imported from the@nestjs/common
package.We've used the
@UseFilters()
decorator here. Same as@Catch()
, it takes infinite count of parameters. diff --git a/src/app/homepage/pages/middlewares/middlewares.component.html b/src/app/homepage/pages/middlewares/middlewares.component.html index c79b2aa990..96a260ffe3 100644 --- a/src/app/homepage/pages/middlewares/middlewares.component.html +++ b/src/app/homepage/pages/middlewares/middlewares.component.html @@ -51,7 +51,7 @@Where to put the middlewares?
{{ applicationModule }}
-{{ applicationModuleJs }}
+Hint We could pass here (insideforRoutes()
) the single object and just useRequestMethod.ALL
.@@ -69,7 +69,7 @@
Where to put the middlewares?
{{ applicationModuleByControllers }}
-{{ applicationModuleByControllersJs }}
+Hint Theapply()
method can take single middleware or an array of middlewares.Pass arguments to the middleware
@@ -128,7 +128,7 @@Functional Middlewares
{{ applyFunctionalMiddleware }}
-{{ applyFunctionalMiddlewareJs }}
+Hint Let's consider to use functional middlewares everytime when your middleware doesn't have any dependencies.\ No newline at end of file diff --git a/src/styles.scss b/src/styles.scss index ace3f05262..32017a2542 100644 --- a/src/styles.scss +++ b/src/styles.scss @@ -62,6 +62,12 @@ blockquote { &::before { background: #ed8529; } strong, a { color: #ed8529; } } + + &.info { + background: rgba(8, 148, 226, 0.038); + &::before { background: #0894e2; } + strong, a { color: #0894e2 } + } } figure {