Skip to content

Commit

Permalink
Merge branch 'TraLeeee-patch-1'
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Oct 17, 2024
2 parents a89b34c + 73cf9c7 commit e85f227
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion content/techniques/mvc.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@ async function bootstrap() {
bootstrap();
```

The Fastify API is slightly different but the end result of those methods calls remains the same. One difference to notice with Fastify is that the template name passed into the `@Render()` decorator must include a file extension.
The Fastify API has a few differences, but the end result of these method calls is the same. One notable difference is that when using Fastify, the template name you pass into the `@Render()` decorator must include the file extension.

Here’s how you can set it up:

```typescript
@@filename(app.controller)
Expand All @@ -198,6 +200,18 @@ export class AppController {
}
```

Alternatively, you can use the `@Res()` decorator to directly inject the response and specify the view you want to render, as shown below:

```typescript
import { Res } from '@nestjs/common';
import { FastifyReply } from 'fastify';

@Get()
root(@Res() res: FastifyReply) {
return res.view('index.hbs', { title: 'Hello world!' });
}
```

While the application is running, open your browser and navigate to `http://localhost:3000`. You should see the `Hello world!` message.

#### Example
Expand Down

0 comments on commit e85f227

Please sign in to comment.