Recently, I published an article on my new project, Matterhorn ?, a Node.js API server boilerplate. It provides a set of opinionated configuration files and some basic example code. These help developers get up and running faster with Node.js and TypeScript.
Matterhorn is inspired by projects like Create React App and Gatsby CLI. The project's goal is to eliminate the barrier of entry required to use programming tools such as type systems, testing and linting frameworks, and even basic continuous integration.
This blog post will review each of the core aspects in Matterhorn. I will discuss details and the opinionated decision behind the framework of choice.
Runtime & Type System
Node.js is driven by a non-blocking event loop which makes it a great choice for building scalable network applications. For more information on Node.js check out their website.
While it is possible to write an HTTP API using just Node.js, if a developer wants to achieve ecosystem maintainability, security, and scalability, they should use an API framework. When it comes to Node.js API frameworks, there are many to chose from such as Express, Koa, and Hapi. But there is one framework faster and more resilient than all the rest: Fastify.
Fastify is a fast and low overhead web framework, for Node.js. It is inspired by Hapi and Express and operates on a plugin based architecture. It has a very healthy open source community, and over 90 public plugins from authentication to database bindings and everything in between. Additionally, Fastify maintains its own set of TypeScript bindings that are shipped with the module directly from NPM.
Test Runner and Linter
inject method; it is very useful for testing your routes behavior.
In addition to running tests, Jest is also configured to output code coverage documents. While code coverage is not the most important metric to consider when writing unit tests, it is valuable and can assist you in verifying you’re at least covering as much of your code base as possible.
In the open source community, code linters are a popular choice for enforcing a certain style of programming. They negate the need for stylistic code reviews. They can help developers catch errors in their code before they run it.
The final aspect of Matterhorn is the inclusion of a fully configured continuous integration pipeline. For many developers, especially those learning or just tinkering, this feature may not have much use. However, for those trying to develop a complete application and want the stability of enterprise development, this CI is for them.
The pipeline is built on Azure DevOps (previously named Visual Studio Team Services). Azure DevOps is free for public repositories, and the pipeline utilities are extensive. It can be configured programmatically (Matterhorn) or through a visual editor (in a browser). You can check out Matterhorn’s CI pipeline here. It automatically builds for pull request updates and any new commits on master.
Thank you for taking the time to read about the various aspects of Matterhorn. A lot went into consideration when picking services and utility modules for this project. The project is open source, and there is plenty of room for improvement so if you’d like to contribute check it out below.
An API boilerplate project built on Node.js and TypeScript ? - Ethan-Arrowood/matterhorngithub.com