Installing TypeScript Choose one of these This will allow you to run tsc command. To test whether a TypeScript file compiles you create one: and then run tsc index.ts. You end up with an error: The reason is that name property is already defined on the window object (global scope), so you either have to […]

This article will demonstrate how to test JavaScript files in NodeJS using the libraries Sinon, Mocha and Chai. Sinon is often installed together with Mocha and Chai, but it is not required.

There are many strategies to scale your application: Cloning Decomposing Splitting The cluster module helps you to scale your code on one system that has many CPU cores. The idea is: You have one master process and clone your code by forking as many worker processes as you have CPU cores in your system. This […]

Streams are collections of data that might not be available all at once and don’t have to fit in memory all at once. For example if you want to serve a file that is 1GB over HTTP you would create a stream instead of reading the file using readFileSync. A Stream can be piped directly […]

Check if a file exists Here are a couple of sync and async ways to check if a file exists via NodeJS. Reading files within a directory Watching files

What you can achieve are things like: Create a server Work with streamed data Make API calls Creating an HTTP server We create an HTTP server on port 8080 and respond to any request with a ‘Hello there!’: IncomingMessage extends two interfaces EventEmitter and ReadableStream which allow us to listen to events and process streams, […]