Export Mongodb Collection Data In CSV From Node Express Mongoose Application

Suppose a student collection in mongodb have some data that we want to export in a csv file from a Mongoose and Node/Express app. For simplicity, let’s assume only two fields in Mongoose schema: lastName and firstName. To export a CSV file, install moment, json2csv, and mongo-date-query (optional) npm packages: [Read More]

Integrate Polling Based API In Node/Express Js

At times we need to integrate in our Node/Express application third party APIs that have implemented polling mechanism i.e. they only send back results once available; the client must keep on attempting until the service has put together all the results to return. [Read More]

Unit Testing Expressjs Controller (Part 1)

Stepwise Test Driven Development of Express Mongoose CRUD APIs

So far, I haven’t found a real workable example of unit testing Express controller/route for API. Most I saw either label integration test as unit test or offer little meaningful in right direction. To be clear what I’m talking about, see the controller code below: [Read More]

Node Express Endpoint to Upload and Process CSV File

It’s very common in Node/Express backend development to come across a requirement of parsing and processing CSV file. Perhaps storing the content in database after processing. This post will do just that. We’ll upload a CSV file, store it temporarily in server’s directory to fetch all rows in JSON form, push all rows in an array, and remove the temporary file. [Read More]