Node.js Streams in Action

Written by danstenger | Published 2020/04/14
Tech Story Tags: nodejs | koajs | knex | postgres | stream-processing | streaming | programming | javascript

TLDR 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.via the TL;DR App

no story

Written by danstenger | GO and functional programming enthusiast
Published by HackerNoon on 2020/04/14