Convert XML to JSON in Node

Here’s a quick demo of how you can convert XML to JSON in NodeJS. Problem You are given a slew of XML files and you have to convert them to JSON. But why JSON? It takes lesser space Faster and easier to work with What are we dealing with here? Convert this input - <?xml version="1.0" encoding="UTF-8"?> <root> <string name="msg">Message</string> <string name="hello">Hello</string> </root> .. to something that we can relate to in JSON - ...

Fastode Server Framework

Fastode is an experimental boilerplate / framework based on Fastify. Why another boilerplate? Well, I just wanted to experiment with technologies to create MVP products. Although I have used NestJS, AdonisJS and friends before, those frameworks, while being great, bring their structure and overhead to any project. I wanted to check how difficult or easy it is to just start with a bunch of basic features and leave everything else to the project. ...

Use Packages Locally Without Publishing Them

How can you use packages being developed locally in other projects - without publishing them to npm repository? NPM Packages Make Life Exciting NPM makes it really easy to create packages and reuse them across projects. I am not even talking about big, useful libraries like Vue, Loadash etc. - just the routine problems across our projects. For example - I use a module to validate a bunch of things and start user subscription for an app I use similar starter theme for sites across projects It is easier to create NPM packages and reuse them instead of copying the code everywhere and starting the great struggle for its maintenance. ...

Refer Project Folder from NPM Package

You can refer to other files/folders using a simple require or using basic node libraries. But, how can you do that with npm packages? The Problem When creating a bunch of Javascript files, here’s what you can do to refer other files - const awe = require("../plugins/awesome.js"); This fetches awesome.js from the plugins folder in the parent. You can do a more robust solution with - const awe = require(path.join(__dirname, "../", "plugins")); __dirname fetches the current directory, and you just join that with the path to reach to the file or folder. ...

Fastify and its plugins are great

I had been meaning to use more of Fastify for work, but only made that a reality recently. So far I have had a great experience on the server framework. What is Fastify? Fastify is a low-overhead server framework built on top of NodeJS. Fastify was started in late 2016 and jumped to v1.0 in Q1,2018. So - it’s a comparatively younger framework. But that has not stopped it from having great ambitions. ...

Email for NodeJS app using separate server on CPanel

Configure email server on a third party host using CPanel, while continuing your app server on your favourite VPS. Background Typically I configure email server to be on the same server as my NodeJS / PHP app. Bad practice? Sure. But, it works just fine for the kind of applications that I write. I can see how horribly this can go wrong though - Your app server goes down and you have no way to send communication to your users Mail servers simply get more spam, more probes - this keeps the server busy for no reason. This means your main app can suffer There are simply better ways to design, without breaking the bank or introducing any complexity - we can just shift mail handling to an external party. ...

Server-side technology options and my hosting solutions

Last year I started focusing on web and application development to a greater extent than what I have done in the past. After having done my time with large enterprises, I now work primarily in a super cost-conscious market. All those things speak poorly about my budgeting and planning skills as far as server hosts are concerned. tldr; Use Digital Ocean* Use Hetzner Cloud Problem I build applications that need a backend. I need that backend to be inexpensive but reliable. ...

Package Managers in Javascript

Since this blog existed and for many centuries before that, we had - “package managers”. These utilities have been quenching the thirst to build better applications and even better applications while standing on the shoulders of giants that grow ever bigger. Yes, they do all that despite their drab name. Package managers address a single function - package code and manage dependencies so that they could be used as a whole. ...

Installing Node on Linux

I recently ended up with a low-end box with CentOS 7. After a long, long time, I got to try out skills on anything other than a managed Ubuntu / RHEL / Windows server/client. The fact that the box depended on me to get the app running was exciting but scary. After some fidgeting around, I got down to business with getting the basic OS configured. It was time to install NodeJS. ...

The Right WSL Setup for using Node

A few node packages have been causing me pain lately. Who knew that my Windows 10 addiction can get me into trouble with node? There are, of course, multiple ways to solve the node problem on Windows. Do not use the offending package :). If there is no support for Windows, your great program does not get written using the specific package. Hell, yeah. Use NVM to juggle between node versions and check whether the problem goes away. I did something similar when using strapi-js. I could not get it to work on Node 10 or 11. ...