Skip to content

Commit ecfa3eb

Browse files
docs(serverless): minor tweaks
1 parent dc01534 commit ecfa3eb

File tree

2 files changed

+29
-13
lines changed

2 files changed

+29
-13
lines changed

content/faq/serverless.md

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -264,20 +264,38 @@ Once the application is running, open your browser and navigate to `http://local
264264

265265
In the sections above, we've shown that using `webpack` and bundling your app can have significant impact on the overall bootstrap time.
266266
However, to make it work with our example, there are a few additional configurations you must add in your `webpack.config.js` file. Generally,
267-
to make sure our `handler` function will be picked up, we must change the `output.libraryTarget` property to `commonjs2`. It's also recommended to install the `terser-webpack-plugin` package and override its configuration to keep classnames intact when minifying your production build. Not doing so can result in incorrect behavior when using `class-validator` within your application.
267+
to make sure our `handler` function will be picked up, we must change the `output.libraryTarget` property to `commonjs2`.
268268

269269
```javascript
270-
const TerserPlugin = require("terser-webpack-plugin");
270+
return {
271+
...options,
272+
externals: [],
273+
output: {
274+
...options.output,
275+
libraryTarget: 'commonjs2',
276+
},
277+
// ... the rest of the configuration
278+
};
279+
```
280+
281+
With this in place, you can now use `$ nest build --webpack` to compile your function's code (and then `$ npx serverless offline` to test it).
282+
283+
It's also recommended (but **not required** as it will slow down your build process) to install the `terser-webpack-plugin` package and override its configuration to keep classnames intact when minifying your production build. Not doing so can result in incorrect behavior when using `class-validator` within your application.
284+
285+
```javascript
286+
const TerserPlugin = require('terser-webpack-plugin');
271287
272288
return {
273289
...options,
274290
externals: [],
275291
optimization: {
276-
minimizer: [new TerserPlugin({
277-
terserOptions: {
278-
keep_classnames: true
279-
}
280-
})]
292+
minimizer: [
293+
new TerserPlugin({
294+
terserOptions: {
295+
keep_classnames: true,
296+
},
297+
}),
298+
],
281299
},
282300
output: {
283301
...options.output,
@@ -287,8 +305,6 @@ return {
287305
};
288306
```
289307

290-
With this in place, you can now use `$ nest build --webpack` to compile your function's code (and then `$ npx serverless offline` to test it).
291-
292308
#### Using standalone application feature
293309

294310
Alternatively, if you want to keep your function very lightweight and you don't need any HTTP-related features (routing, but also guards, interceptors, pipes, etc.),

src/app/homepage/pages/microservices/custom-transport/custom-transport.component.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,8 @@ <h4 appAnchor id="message-serialization"><span>Message serialization</span></h4>
197197
<p>If you need to add some custom logic around the serialization of responses on the client side, you can use a custom class that extends the <code>ClientProxy</code> class or one of its child classes. For modifying successful requests you can override the <code>serializeResponse</code> method, and for modifying any errors that go through this client you can override the <code>serializeError</code> method. To make use of this custom class, you can pass the class itself to the <code>ClientsModule.register()</code> method using the <code>customClass</code> property. Below is an example of a custom <code>ClientProxy</code> that serializes each error into an <code>RpcException</code>.</p>
198198

199199
<span class="filename">
200-
{{ 'error-handling.proxy' | extension: app36509a7a69ae46c59205b90a4a5155e70e440781.isJsActive }}
201-
<app-tabs #app36509a7a69ae46c59205b90a4a5155e70e440781></app-tabs>
200+
{{ 'error-handling.proxy' | extension: app630c344fa86197723c3999961ed4f597aecb22ee.isJsActive }}
201+
<app-tabs #app630c344fa86197723c3999961ed4f597aecb22ee></app-tabs>
202202
</span><pre><code class="language-typescript">
203203
import &#123; ClientTcp, RpcException &#125; from &#39;@nestjs/microservices&#39;;
204204

@@ -210,8 +210,8 @@ <h4 appAnchor id="message-serialization"><span>Message serialization</span></h4>
210210
</code></pre><p>and then use it in the <code>ClientsModule</code> like so:</p>
211211

212212
<span class="filename">
213-
{{ 'app.module' | extension: app830418197b35c62d70431550a1f060c5a80864fa.isJsActive }}
214-
<app-tabs #app830418197b35c62d70431550a1f060c5a80864fa></app-tabs>
213+
{{ 'app.module' | extension: app8d31e231893684261e1aeae0662becdd6b838a8f.isJsActive }}
214+
<app-tabs #app8d31e231893684261e1aeae0662becdd6b838a8f></app-tabs>
215215
</span><pre><code class="language-typescript">
216216
@Module(&#123;
217217
imports: [

0 commit comments

Comments
 (0)