Using async method and `ParseIntPipe` for generated resources controllers and services[restful] .
See original GitHub issueIs there an existing issue that is already proposing this?
- I have searched the existing issues
Is your feature request related to a problem? Please describe it
For now, nest g mo cat [restful]
will generated controllers like this:
@Get(':id')
findOne(@Param('id') id: string) {
return this.catService.findOne(+id);
}
There is two problems I think:
- use
+
to convert string to number - the method is sync, but usually we will get resources from db which be async
Describe the solution you’d like
It would better to solve problem one using ParseIntPipe
and make methods async.
@Get(':id')
async findOne(@Param('id', ParseIntPipe) id: number) {
return await this.catService.findOne(id);
}
Teachability, documentation, adoption, migration strategy
No response
What is the motivation / use case for changing the behavior?
as related to a problem
part say.
Issue Analytics
- State:
- Created a year ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Issues · nestjs/schematics - GitHub
When converting project to a monorepo configure all E2E tests to be run needs triage. #1167 opened ; Using async method and ParseIntPipe...
Read more >Task asynchronous programming model - Microsoft Learn
Learn when and how to use Task-based async programming, a simplified approach to asynchronous programming in C#.
Read more >Pipes | NestJS - A progressive Node.js framework
In our ParseIntPipe example, we want to associate the pipe with a particular route ... schema for a given controller method using the...
Read more >Introduction to RESTful APIs with NestJS - This Dot Labs
The installation of NestJS comes with a sample API endpoint that we can test by making a request to it. If we open...
Read more >Long Story Short: Async/Await Best Practices in .NET - Medium
NET programming — any C# developer worth his/her salt should be using it to improve application performance, overall responsiveness, and code ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
got you
I’d leave those
+id
thensorry for late, I’d like to do~