Node.js Streams in Actionby@danstenger
1,741 reads

Node.js Streams in Action

April 14th 2020
6 min
by @danstenger 1,741 reads
tldt arrow
Read on Terminal Reader🖨️

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

@danstenger

Daniel

About @danstenger
LEARN MORE ABOUT @DANSTENGER'S EXPERTISE AND PLACE ON THE INTERNET.
react to story with heart

RELATED STORIES

L O A D I N G
. . . comments & more!
Hackernoon hq - po box 2206, edwards, colorado 81632, usa