Async, Await, and Promises in Express for Node.js

preview_player
Показать описание
Here's how you can easily work with async/await and Promises in express, right now!
Express 5.0 promised native support for async/await and Promises - and it even delivered, but then was never officially published. It's still stuck in alpha.
There are many 3rd party modules that add promise support to express, but most of them are just plain terrible.
Thankfully I express-promisify-router, which behaves exactly as any sane, rational person who has used express would expect it to behave. That said, since it doesn't seem to be actively maintained, I added the ability to use error handler functions and republished it as @root/async-router.

Beyond Code:
(Learn to Code in 15 Minutes a Day)

AJ's Live Streams:

Health, Wealth, Commitment
(My Morning Shower Thoughts as a Daily Lifestyle Vlog)

#softwaredevelopment #softwareengineer #webdevelopment #webdeveloper
Рекомендации по теме
Комментарии
Автор

Hey man !
Nice video, very helpful to get a good grasp on these damn promises :)
Quick question : why is do you use "return users" instead of "return user" ?

nassermassadimi
Автор

Quick question on how this applies to me:

My project uses new express.Router() in separate router files that are imported into my main server file and applied to base routes with app.use('/someroute', router)

Would I use this library in each of my router files and use express().use('/someroute', asyncRouter) or would I create an "app" in the main server file and attach these other routers.
app.use('/someroute', asyncRouter) then apply this app to the express server? Or can I skip using the library in my router files and just use the app in the main server file?

Thanks for any feedback you can give

snowstud
Автор

is not preferable to use Rxjs library?

nuni
Автор

7:36 can I please introduce you to my friend 'const'

ColinRichardson
Автор

There would be so much more room to show your work if you didn't love yourself so much that you can't stand removing your face ! mugshot video !

spacecorp