#sequelize #node #git #cli #JavaScript

Progress and roadblocks: a journey into open-source

Enhancing generators for ES6 in the Sequelize CLI This is the story of my discovery of ES6-class style model definitions with Sequelize (see Using ES6 classes for Sequelize 4 models). The realisation that the current Sequelize CLI model generator didn’t support it (as is expected since it’s not the most common way of doing it). Finally, the impetus to just implement it myself. In other words, I started using a style of Sequelize models that the Sequelize CLI didn’t support. ...

  • Hugo Di Francesco
    Author
6 min read
#JavaScript #Node #ES6 #architecture

Simple, but not too simple: how using Zeit’s `micro` improves your Node applications

Leave the Express comfort zone to expand how you think about Node application architecture. tl;dr using a function composition model for building HTTP servers is awesome Functions as a Service are great but have some drawbacks micro has a similar, simple API to FaaS but doesn’t have a compilation step micro’s minimalism affects how you solve problems Functions as a composition model for JavaScript Functions as a Service pain points ...

  • Hugo Di Francesco
    Author
7 min read
#deployment #Node #JavaScript #tooling

Deployment options: Netlify + Dokku on DigitalOcean vs now.sh, GitHub Pages, Heroku and AWS

Settling on a Netlify + Dokku on DigitalOcean deployment stack for JavaScript and Node. Over the last few years I’ve never quite settled on a goto deployment strategy for my apps and projects. Technology-wise it has settled towards Vue or static site generators for the frontend with Node on the backend, whether that’s for API servers or handling rendering through handlebars. What I’ve finally settled on is Netlify + Dokku on DigitalOcean. ...

  • Hugo Di Francesco
    Author
5 min read
#JavaScript #Sequelize #testing #Node

Unit Testing Sequelize 4 ES6 class models

In “Using ES6 classes for Sequelize 4 models” we explored how to define Sequelize models using ES6 classes. One of the benefits of such an approach is that it allows easy unit testing, it allows you to instantiate the model without the baggage of all of Sequelize (and/or a database). The examples will use Jest module auto-mocking but should be portable to other module mocking libraries (eg. Proxyquire) with some modifications. ...

  • Hugo Di Francesco
    Author
2 min read
#JavaScript #Node #tooling #deployment

Build and deploy a Vue/React/Vanilla JS app with Parcel and GitHub pages

Parcel allows us to bundle frontend applications with no configuration and GitHub pages affords us a way to deploy them for free. Here’s how to use these two tools together to deploy a JavaScript application. Full example of a repo deployed like this: https://github.com/HugoDF/js-graphql-client-example, and see https://codewithhugo.com/js-graphql-client-example/. Or the repo with the demos: https://github.com/HugoDF/parcel-gh-pages-deploy and see https://codewithhugo.com/parcel-gh-pages-deploy/. ...

  • Hugo Di Francesco
    Author
2 min read
#JavaScript #Node #Docker #redis

Bring Redux to your queue logic: an Express setup with ES6 and bull queue

There always comes a point in a web application’s life where an operation is best served in the background, this is where queues come in. There are a few queuing solutions in Node. None of them are ridiculously dominant, eg. Kue, RSMQ, Bee Queue, bull. The issue with Kue, RSMQ and Bee Queue was its use of a done callback as the recommended API. Bull https://github.com/OptimalBits/bull is a premium Queue package for handling jobs and messages in NodeJS. It’s backed by Redis and is pretty feature-rich. Most of all, it leverages a Promise-based processing API which means async/await. We’ll walk through an application that sends webhooks with a given payload to a set of URLs. ...

  • Hugo Di Francesco
    Author
11 min read
#JavaScript #Node

ES6 by example: a module/CLI to wait for Postgres in docker-compose

When using docker-compose, it’s good practice to make anything that relies on Postgres wait for it to be up before launching. This avoids connection issues inside the app. This post walks through how to deliver this functionality both as a CLI and a module that works both as a CommonJS module (require) and ES modules, without transpilation. “A fast, production ready, zero-dependency ES module loader for Node 6+!” is esm’s promise. From this sample project, it’s worked. ...

  • Hugo Di Francesco
    Author
9 min read