Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Docs #216

Merged
merged 2 commits into from
Feb 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/app/homepage/pages/components/components.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ <h4>Services</h4>
<p>
The <code>CatsService</code> is injected through the class constructor. Don't be afraid of the <code>private readonly</code>
shortened
syntax. It means that we've created and initialized the <code>catsService</code> member immedietely in the same
syntax. It means that we've created and initialized the <code>catsService</code> member immediately in the same
location.
</p>
<h4>Dependency injection</h4>
Expand Down Expand Up @@ -97,7 +97,7 @@ <h4>Property-based injection</h4>
<p>
In some very specific cases, a property-based injection might be useful. For instance, if your top-level class
depends on either one or multiple providers, passing them all the way up by calling <code>super()</code>
in sub-classes from the constructor can be very annonying. Thus, in order to avoid it, you can use <code>@Inject()</code>
in sub-classes from the constructor can be very annoying. Thus, in order to avoid it, you can use <code>@Inject()</code>
decorator on
a property level.
</p>
Expand Down Expand Up @@ -145,4 +145,4 @@ <h4>Provider registration</h4>
<div class="item">main.ts</div>
</div>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ <h3>Exception filters</h3>
<img src="/assets/Filter_1.png" />
</figure>
<p>
Each ocurred exception is handled by the global exception filter, and when it's
Each occurred exception is handled by the global exception filter, and when it's
<strong>unrecognized</strong> (is neither
<code>HttpException</code> nor a class that inherits from
<code>HttpException</code>), a user receives the below JSON response:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ <h4>Stream overriding</h4>
Here's a <code>CacheInterceptor</code> with a hardcoded <code>isCached</code> variable and the hardcoded response <code>[]</code> as
well. We returned a new stream here, created through the <code>of</code> operator, therefore the route handler <strong>won't
be called</strong> at all. When someone calls endpoint that makes use of <code>CacheInterceptor</code>, the response
(a hardcoded, empty array) will be returned immedietely. In order to create a generic solution, you can take advantage
(a hardcoded, empty array) will be returned immediately. In order to create a generic solution, you can take advantage
of <code>Reflector</code> and create a custom decorator. The <code>Reflector</code> is well described in the <a routerLink="/guards">guards</a>
chapter.
</p>
Expand All @@ -222,4 +222,4 @@ <h4>Stream overriding</h4>
<p>
After 5 seconds the request processing will be canceled.
</p>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h4>Overview</h4>
<p>
In general, Nest supports a bunch of built-in transporters. They are based on <strong>request-response</strong> paradigm
and a whole communication logic is hidden behind an abstraction layer. Thanks to that you can easily switch between transporters
without changing any line of your code. We don't support streaming platforms with log based persistance, such as <a href="https://docs.confluent.io/3.0.0/streams/"
without changing any line of your code. We don't support streaming platforms with log based persistence, such as <a href="https://docs.confluent.io/3.0.0/streams/"
target="blank">Kafka</a> or <a href="https://github.com/nats-io/node-nats-streaming" target="blank">NATS streaming</a>
because they have been created to solve a different range of issues. However, you can still use them with Nest by making
use of <a routerLink="/execution-context">execution context</a> feature.
Expand Down Expand Up @@ -122,7 +122,7 @@ <h4>Client</h4>
<pre><code class="language-typescript">{{ clientProxy }}</code></pre>
<p>
The <code>ClientProxy</code> is <strong>lazy</strong>. It doesn't initiate a connection immediately. Instead, it will
be established before the first microservice's call, and then reused across each subsequent call. However, if you want
be established before the first microservice call, and then reused across each subsequent call. However, if you want
to delay an application's bootstrapping process and manually initialize a connection, you can use a <code>connect()</code> method
inside the <code>OnModuleInit</code> lifecycle hook.
</p>
Expand All @@ -144,4 +144,4 @@ <h4>Client</h4>
to be equal to this one defined in the <code>@MessagePattern()</code> decorator, while <code>payload</code> is a message
that we want to transmit to another microservice.
</p>
</div>
</div>
17 changes: 8 additions & 9 deletions src/app/homepage/pages/middlewares/middlewares.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -141,20 +141,19 @@ <h4>Asynchronous middleware</h4>
<p>
There are no contraindications that would prevent us from returning the <code>async</code> function within the <code>resolve()</code> method.
Also, it's possible to make the <code>resolve()</code> method <code>async</code> as well. This common pattern is called
<strong>deffered middleware</strong>.
<strong>deferred middleware</strong>.
</p>
<span class="filename">
{{ 'logger.middleware' | extension: defferedMiddlewareT.isJsActive }}
<app-tabs #defferedMiddlewareT></app-tabs>
{{ 'logger.middleware' | extension: deferredMiddlewareT.isJsActive }}
<app-tabs #deferredMiddlewareT></app-tabs>
</span>
<pre [class.hide]="defferedMiddlewareT.isJsActive"><code class="language-typescript">{{ defferedMiddleware }}</code></pre>
<pre [class.hide]="!defferedMiddlewareT.isJsActive"><code class="language-typescript">{{ defferedMiddlewareJs }}</code></pre>
<pre [class.hide]="deferredMiddlewareT.isJsActive"><code class="language-typescript">{{ deferredMiddleware }}</code></pre>
<pre [class.hide]="!deferredMiddlewareT.isJsActive"><code class="language-typescript">{{ deferredMiddlewareJs }}</code></pre>
<h4>Functional middleware</h4>
<p>
The <code>LoggerMiddleware</code> is quite short. It has no members, no additional methods, no dependencies. Why can't
we just use a simple function? It's a good question, cause in fact - we can. This type of the middleware is called <strong>functional
middleware
</strong>. Let's transform the logger into a function.
we just use a simple function? It's a good question, cause in fact - we can. This type of the middleware is called
<strong>functional middleware</strong>. Let's transform the logger into a function.
</p>
<span class="filename">
{{ 'logger.middleware' | extension: functionalMiddlewareT.isJsActive }}
Expand Down Expand Up @@ -194,4 +193,4 @@ <h4>Global middleware</h4>
app.use(logger);
await app.listen(3000);</code></pre>

</div>
</div>
4 changes: 2 additions & 2 deletions src/app/homepage/pages/middlewares/middlewares.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ export class LoggerMiddleware {
}`;
}

get defferedMiddleware() {
get deferredMiddleware() {
return `
import { Injectable, NestMiddleware, MiddlewareFunction } from '@nestjs/common';

Expand All @@ -281,7 +281,7 @@ export class LoggerMiddleware implements NestMiddleware {
}`;
}

get defferedMiddlewareJs() {
get deferredMiddlewareJs() {
return `
import { Injectable } from '@nestjs/common';

Expand Down
4 changes: 2 additions & 2 deletions src/app/homepage/pages/migration/migration.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ <h4>Node.js</h4>
<p>
We follow the Node.js release schedule which recently moved to <code>8.x</code> as an active <strong>LTS</strong> version.
Therefore, Nest 5 supports >= <code>8.9.0</code> as the lowest version now.
This shift gaves us sustainable performance boosts thanks to the <code>es2017</code> target of the TypeScript compilation.
This shift gave us sustainable performance boosts thanks to the <code>es2017</code> target of the TypeScript compilation.
</p>
<h4>External libraries</h4>
<p>
Nest 5 doesn't support <a href="https://github.com/ReactiveX/rxjs">rxjs</a> < 6.0.0. Keep in mind to upgrade this package as well.
</p>
</div>
</div>
6 changes: 3 additions & 3 deletions src/app/homepage/pages/modules/modules.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ <h4>Modules re-exporting</h4>
The modules can export their internal providers. Moreover, they can re-export modules imported by themselves.
</p>
<span class="filename">
<app-tabs #reExportExamleT></app-tabs>
<app-tabs #reExportExampleT></app-tabs>
</span>
<pre><code class="language-typescript">{{ reExportExamle }}</code></pre>
<pre><code class="language-typescript">{{ reExportExample }}</code></pre>
<h4>Dependency injection</h4>
<p>
A module class can <strong>inject</strong> providers as well (e.g. for configuration purposes):
Expand Down Expand Up @@ -180,4 +180,4 @@ <h4>Dynamic modules</h4>
decorator, which makes that Nest will always create the new instance of the module when it's imported by another one.
</p>
<pre><code class="language-typescript">{{ singleScope }}</code></pre>-->
</div>
</div>
2 changes: 1 addition & 1 deletion src/app/homepage/pages/modules/modules.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export class CatsModule {
}`;
}

get reExportExamle() {
get reExportExample() {
return `
@Module({
imports: [CommonModule],
Expand Down
4 changes: 2 additions & 2 deletions src/app/homepage/pages/pipes/pipes.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ <h5>This section applies only to TypeScript.</h5>
</blockquote>
<p>
The instance of
<code>ValidationPipe</code> has been created immedietely in-place. Another available way is to pass the class (not instance),
<code>ValidationPipe</code> has been created immediately in-place. Another available way is to pass the class (not instance),
leaving framework the instantiation responsibility and enabling
<strong>dependency injection</strong>.
</p>
Expand Down Expand Up @@ -361,4 +361,4 @@ <h4>A built-in ValidationPipe</h4>
<blockquote>
<strong>Notice</strong> You may find more information about the <code>class-validator</code> package in its <a href="https://github.com/typestack/class-validator">repository</a>.
</blockquote>
</div>
</div>
4 changes: 2 additions & 2 deletions src/app/homepage/pages/recipes/prisma/prisma.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ <h4>Integration</h4>
<span class="filename">prisma.service</span>
<pre><code class="language-typescript">{{ prismaService }}</code></pre>
<p>
Once <code>PrismaService</code> is ready, we need to create a correspoding module.
Once <code>PrismaService</code> is ready, we need to create a corresponding module.
</p>
<span class="filename">prisma.module</span>
<pre><code class="language-typescript">{{ prismaModule }}</code></pre>
Expand All @@ -94,4 +94,4 @@ <h4>Example</h4>
A slightly modified example is available
<a href="https://github.com/nestjs/nest/tree/master/sample/22-graphql-prisma" target="blank">here</a>.
</p>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ <h4>Repository pattern</h4>
The <a href="https://github.com/typeorm/typeorm" target="blank">TypeORM</a> supports the repository design pattern, thus each entity has its own Repository. These repositories can be obtained from the database connection.
</p>
<p>
But firstly, we need at least one entity. We are going to reuse the <code>Photo</code> entity from the offical documentation.
But firstly, we need at least one entity. We are going to reuse the <code>Photo</code> entity from the official documentation.
</p>
<span class="filename">photo/photo.entity.ts</span>
<pre><code class="language-typescript">{{ photoEntity }}</code></pre>
Expand Down Expand Up @@ -68,4 +68,4 @@ <h4>Repository pattern</h4>
<blockquote class="warning">
<strong>Hint</strong> Don't forget to import the <code>PhotoModule</code> into the root <code>ApplicationModule</code>.
</blockquote>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ <h4>Bootstrap</h4>
The <code>SwaggerModule</code> automatically reflects all of your endpoints.
In the background, it's making use of <code>swagger-ui-express</code> and creates a live documentation.
</p>
<blockquote class="info">
<strong>Hint</strong> If you want to download the corresponding `Swagger JSON` file, you can simply call
<code>http://localhost:3000/api-json</code> in your browser (if your Swagger documentation is published under
<code>http://localhost:3000/api</code>).
</blockquote>
<h4>Body, query, path parameters</h4>
<p>
During the examination of the defined controllers, the <code>SwaggerModule</code> is looking for all used <code>@Body()</code>,
Expand Down Expand Up @@ -122,7 +127,7 @@ <h4>Multiple specifications</h4>
<code>setup()</code>
before you can start working on a second <strong>SwaggerOptions</strong> for a second Swagger Specification. This
specific order is to
prevent Swagger configurations being overriden by different options.
prevent Swagger configurations being overridden by different options.
</blockquote>
<h4>Working with enums</h4>
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ <h4>Installation</h4>
<pre><code class="language-bash">$ npm install --save cache-manager</code></pre>
<h4>In-memory cache</h4>
<p>
Nest provides a unified API for various cache storages. The built-in one is an in-memory data store. However, you can easily
switch to a more comprehensive solution, like Redis. In order to enable caching, firstly import <code>CacheModule</code> and
Nest provides a unified API for various cache storage providers. The built-in one is an in-memory data store. However, you can easily
switch to a more comprehensive solution, like Redis. In order to enable caching, firstly import <code>CacheModule</code> and
call its <code>register()</code> method.
</p>
<pre><code class="language-typescript">{{ inMemoryCache }}</code></pre>
Expand Down Expand Up @@ -55,7 +55,7 @@ <h4>Different stores</h4>
We take advantage of <a href="https://github.com/BryanDonovan/node-cache-manager" target="blank">cache-manager</a> under
the hood. This package supports a wide-range of useful stores, for example, <a href="https://github.com/dabroek/node-cache-manager-redis-store"
target="blank">Redis</a> store (full list <a href="https://github.com/BryanDonovan/node-cache-manager#store-engines"
target="blank">here</a>). To set up the Redis store, simple pass the package together with correspoding options to the
target="blank">here</a>). To set up the Redis store, simple pass the package together with corresponding options to the
<code>register()</code> method.
</p>
<pre><code class="language-typescript">{{ redisStore }}</code></pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ <h4>Installation</h4>
app.use(compression());</code></pre>
<blockquote class="info">
<strong>Hint</strong>
If you work wtih <code>FastifyAdapter</code>, consider using <a href="https://github.com/fastify/fastify-compress" target="blank">fastify-compress</a>
If you work with <code>FastifyAdapter</code>, consider using <a href="https://github.com/fastify/fastify-compress" target="blank">fastify-compress</a>
instead.
</blockquote>
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ <h4>Using the ConfigService</h4>
<span class="filename">app.service.ts</span>
<pre><code class="language-typescript">{{ configServiceInjection }}</code></pre>
<blockquote class="info">
Instead of importing <code>ConfigModule</code> repeatingly in all your modules, you can also declare <code>ConfigModule</code> as
Instead of importing <code>ConfigModule</code> in all your modules, you can also declare <code>ConfigModule</code> as
a global module.
</blockquote>
<h4>Advanced configuration</h4>
Expand All @@ -79,7 +79,7 @@ <h4>Advanced configuration</h4>
a lack of <strong>validation</strong> of the provided <code>.env</code> file
</li>
<li>
the env file provides booleans as string (<code>'true'</code>), and thus have to cast them to a <code>boolean</code> every
the env file provides booleans as string (<code>'true'</code>), and thus have to cast them to a <code>boolean</code> every
time
</li>
</ul>
Expand Down Expand Up @@ -120,4 +120,4 @@ <h4>Usage example</h4>
</p>
<span class="filename">app.service.ts</span>
<pre><code class="language-typescript">{{ advancedConfigServiceSample }}</code></pre>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ <h4>Array of files</h4>
we use <code>@UploadedFiles()</code> decorator
</p>
<span class="filename">
<app-tabs #multiplteFilesT></app-tabs>
<app-tabs #multipleFilesT></app-tabs>
</span>
<pre [class.hide]="multiplteFilesT.isJsActive"><code class="language-typescript">{{ multipleFiles }}</code></pre>
<pre [class.hide]="!multiplteFilesT.isJsActive"><code class="language-typescript">{{ multipleFilesJs }}</code></pre>
<pre [class.hide]="multipleFilesT.isJsActive"><code class="language-typescript">{{ multipleFiles }}</code></pre>
<pre [class.hide]="!multipleFilesT.isJsActive"><code class="language-typescript">{{ multipleFilesJs }}</code></pre>
<blockquote class="info">
<strong>Hint</strong> Both <code>FilesInterceptor()</code> and <code>@UploadedFiles()</code> decorator are exposed from
<code>@nestjs/common</code> package.
Expand Down Expand Up @@ -94,4 +94,4 @@ <h4>Async configuration</h4>
It works the same as <code>useClass</code> with one critical difference - <code>MulterModule</code> will lookup imported
modules to reuse already created <code>ConfigService</code>, instead of instantiating it on its own.
</p>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ <h4>Dependency injection</h4>
<pre><code class="language-typescript">{{ loggerModule }}</code></pre>
<p>
Once <code>LoggerModule</code> is imported anywhere, the framework will take charge of creating an instance of your logger.
Now, to use the same instance of a logger across the whole app, including bootstraping and error handling stuff, use
Now, to use the same instance of a logger across the whole app, including bootstrapping and error handling stuff, use
following construction:
</p>
<pre><code class="language-typescript">{{ useLoggerDi }}</code></pre>
<p>
The only downside of this solution is that your first initialization messages won't be handled by your logger instance, though,
it shouldn't really matter at this point.
</p>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ <h4>Rate limiting</h4>
{{ expressRateLimit }}</code></pre>
<blockquote class="info">
<strong>Hint</strong>
If you work wtih <code>FastifyAdapter</code>, consider using <a href="https://github.com/fastify/fastify-rate-limit"
If you work with <code>FastifyAdapter</code>, consider using <a href="https://github.com/fastify/fastify-rate-limit"
target="blank">fastify-rate-limit</a> instead.
</blockquote>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ <h3>Serialization</h3>
For instance, sensitive data like user's password should be always excluded from the eventual response. Furthermore,
certain properties might require additional transformation, let's say, we don't want to send the whole database entity.
Instead, we would like to pick only <code>id</code> and <code>name</code>. The rest should be automatically stripped.
Unluckily, manually mapping all entities may bring a lot of confusedness.
Unluckily, manually mapping all entities may bring a lot of confusion.
</p>
<h4>Overview</h4>
<p>
Expand Down Expand Up @@ -53,15 +53,15 @@ <h4>Pass options</h4>
The <code>@SerializeOptions()</code> decorator is imported from <code>@nestjs/common</code> package.
</blockquote>
<p>
These opions will be passed as a second argument of the <code>classToPlain()</code> function.
These options will be passed as a second argument of the <code>classToPlain()</code> function.
</p>
<h4>Websockets & Microservices</h4>
<p>
All these guidelines cornern both WebSockets as well as microservices, regardless of transport method that is being used.
All these guidelines concern both WebSockets as well as microservices, regardless of transport method that is being used.
</p>
<h4>Learn more</h4>
<p>
In order to read more about available decorators, options, visit this <a href="https://github.com/typestack/class-transformer"
target="blank">page</a>.
</p>
</div>
</div>
Loading