paint-brush
Node.js Streams in Actionby@danstenger
2,044 reads
2,044 reads

Node.js Streams in Action

by Daniel6mApril 14th, 2020
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Node.js uses streams to reduce memory usage on the server when processing large files. Instead of reading whole file into memory we stream it in chunks to whoever requested it and apply transformations to that stream if needed. I'll build simple API with 2 endpoints. Both will be returning large amount of records from Postgres DB. One endpoint will stream data to the client and another will read whole data into memory and return in one chunk. The error handling middleware has to be first in Koa app in order to capture exceptions.

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - Node.js Streams in Action
Daniel HackerNoon profile picture
Daniel

Daniel

@danstenger

GO and functional programming enthusiast

About @danstenger
LEARN MORE ABOUT @DANSTENGER'S
EXPERTISE AND PLACE ON THE INTERNET.
L O A D I N G
. . . comments & more!

About Author

Daniel HackerNoon profile picture
Daniel@danstenger
GO and functional programming enthusiast

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite
Aiois
Co
Coffee-web
Freesion