Convert HTML to PDF in Nodejs

Without Puppeteer, phantomjs or any other headless browser.

To convert an HTML to PDF in the backend, you usually need a headless browser like Puppeteer or phantomjs. The downside of headless browsers is that they are resource intensive. If you need to convert an HTML in Nodejs, is there a way to do so without them? The answer is yes but with a caveat: The HTML should be relatively simple, and you will only have a few options to style the document.

[Read More]
nodejs  script  pdf 

Nodejs Script to Add Rows in CSV File Through Terminal

Filling out a CSV file through Office Excel or LibreOffice Calc is easy enough, but you may find it quicker to type in fields on a terminal, particularly when you want to process the data before entry, use defaults, or keep the entry process totally mouse-free. [Read More]
csv  script 

How to Run Nightmare JS On Remote Linux Server

Nightmare JS is a browser automation tool. It works perfectly on local machine and even has an option to view the browser in action by passing { show: true } option when initializing Nightmare. On remote linux machine, however, it will not work without installing and including an extra package xvfb. [Read More]

How to Deal With Nightmare JS Zombie Electron Processes

Nightmare JS leaves in its wake zombie electron processes and memory leaks

Nightmare JS is a great browser automation library, especially effective for scrapping websites. It has two faults though: memory leaks and zombie electron processes. But with a duct-tape hacks we can easily overcome both. For memory leak, which is minor but builds up over time, daily restart of the node script or app is pretty effective and avoids solutions that are overkill. [Read More]

Restart Pm2 Process Every Day Using A Node Script

A brute force yet effective way to restart scripts that need it

To run NodeJS scripts and apps constantly, we usually use pm2 (some prefer forever). However, some scripts require a brute force restart from time to time as they do not fare better in uninterrupted longer runs. Mostly, the reason is memory leaks of packages you are bound to use but have no control over. [Read More]
nodejs  pm2  script 

Trace Redirect Urls NPM Request

With NPM request module it is quite easy to observe and trace all the intermediate urls before the final url is reached. We can do that using followRedirect option, which takes either true or false, or a function that should return a boolean value. [Read More]

Clean Up MongoDB Of Old Inactive Users And Their Data With Node Js Script

Reduce Expensive Database Space By Pruning Never-To-Be-Used-Again Data

Databases are not cheap, especially when your application is just taking off and you are low on budget. It is then that freeing up retrievable and precious space from the database is a good way to save some dollars for a while. [Read More]

Build Queue For Processing Webhooks With Node Js And MongoDB

Manage The Flood Of Webhooks With A Database Queue

Many of the third party services we integrate in our applications use webhooks to communicate events to us. Responding to the incoming webhook with success response (status 200) is all that is required to acknowledge the receipt of the webhook. To process that webhook immediately upon receiving or entering it in a queue to be processed later is up to you.

[Read More]
When you purchase through links on techighness.com, I may earn an affiliate commission.