Suppose a student collection in mongoDB have some data that we want to export in a CSV file from a Mongoose, Node, and Express app. For simplicity, let us 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]
Validate Uploaded CSV Data in Node Express
Confirm existence and data type of all columns within each row.
Continuing from earlier post Node Express Endpoint to Upload and Process CSV File, in this post we will add validation to the uploaded CSV data.
With the same index.js file and settings as the earlier post, we only need to add moment library for date validation.
[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 2)
Detailed Example Of Express Mongoose Update API
This is part 2 on the topic of Expressjs controller unit testing. Previously, I added unit tests for 5 basic CRUD APIs for vehicle. In this post I will show one more example, where controller logic gets a little longer.
[Read More]Unit Testing Expressjs Controller (Part 1)
Stepwise Test Driven Development of Express Mongoose CRUD APIs
So far, I have not 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.
[Read More]Node Express Endpoint to Upload and Process CSV File
It is quite common in Node Express backend development to come across a requirement of parsing and processing CSV files. Usually, it is to store the content in the database after processing.
In this post, we will upload a CSV file, store it temporarily in the server directory to fetch all rows in JSON form, push all rows in an array, and remove the temporary file.
[Read More]
When you purchase through links on techighness.com, I may earn an affiliate commission.