Use import aliases in Rollup module bundler

Introduction

Sometimes, when working with JavaScript and module bundlers, it’s useful to create aliases in order to import or require some modules more easily. In Webpack for example you can use the resolve.alias directive inside the configuration file.

module.exports = {
  //...
  resolve: {
    alias: {
      'applicationRoot': path.resolve(__dirname, 'src/')
    }
  }
};

A common use case for aliases is to abstract the application root, so instead of using relative …

Read More
Effective pagination in AdonisJS

Introduction

Notice: I already did an introduction on AdonisJs, a Laravel-inspired web framework for NodeJS. You can read that post first if you don’t know what AdonisJS is.

In the latest months I tried to get more comfortable with AdonisJS by building a concrete side-project. My impressions so far have been really positive, even though the work required to achieve some basic functionalities is higher and less intuitive compared to the effort required in Laravel. Pagination is a …

Read More
How to use presenters in AdonisJs Edge templating engine

Introduction

Being a very passionate Laravel fan, I decided to step up and finally try properly AdonisJs. I already tried some small bits of it a couple of years ago, but the generator syntax did not really appeal to me. Finally with async/await we have a battle-tested MVC framework (the current version is 4.1) with modern syntax that brings Rails/Laravel concepts to NodeJs.

The value proposition of the framework is the same that fuels modern MVC frameworks: reduce the time required to be …

Read More
Configure an infrared remote control with Linux

Introduction

Recently I bought a shiny new Intel NUC8i7HNK, equipped with 16 GB of RAM and a 500 GB SSD and I installed Ubuntu 18.04 LTS. I have to say that it works smoothly and my overall experience with it is really positive this far. I don’t really miss the MAC or Windows at all.

The Intel NUC8i7HNK comes with many different expansion options and among these, there is a front consumer infrared (CIR) sensor, so I asked myself if it was possible to control the NUC with a standard TV …

Read More
Get the full path of a File using the Storage facade on Laravel

Introduction

This post is just a reference for the various ways of retrieving the full path of a file using the Storage facade in Laravel.

Under the hood the Storage facade it uses the Flysystem PHP Package by Frank de Jonge, allowing the developer to use the same API with different filesystem drivers (Local, SFTP, Amazon S3, Rackspace and so on).

In this post I’m interested in getting the full path of a file. I will use the local driver, whose methods are relative to the root …

Read More
Nullable objects using JavaScript proxies

Introduction

JavaScript proxies are an ES6 (aka ES2015) feature that lets you wrap an existing object and intercept any access to its attributes or methods, even if they do not exist.

var proxy = new Proxy({ name: "John Doe" }, {
    get: function(target, property) {
        if (property in target) {
            return target[property];
        } else {
            return "Nope!";
        }
    }
});

console.log(proxy.age);         // "Nope!"
console.log(proxy.name); …
Read More