Jump-start your node backend

sroehrl

neoan

Posted on December 22, 2020

Jump-start your node backend

For the impatient readers

After setting up backends with JWT authentication middleware and basic structure too many times, I wanted something that is clean enough to be used as a boilerplate, and abstracted enough that I can develop rapidly. Here is the result:

clone & start

What we are aiming for

The first step is looking at dependability and scalability and therefore looking at testing & CI is the basis.
Jest & supertest seem to be good candidates for writing tests while travis-ci and codeclimate have been my go-to for coverage reports and continuous integration. We also want type save development so typescript is the obvious choice.
As most developers are familiar with express, we are not going to make any esoteric choices regarding the server. Other than that, we want to limit boxing us in as far as possible.

The database

I decided on MySQL but wanted to make sure we can migrate easily in case we maintain active projects. Rather than choosing an orm, I decided to write my own SQL wrapper for common CRUD operations that can be easily abstracted in order to save myself (and others) from repeating business logic. The result is a model system that uses an abstracted resolver for creating, finding getting and updating model entities.

Authentication

JWT seems to be the most versatile way of authentication and providing middleware, a user model and signup & login routes seemed a logical step as I would else have to write this in every project. Instead, simple changes to the user model depending on my needs seems reasonable.

The result

I soon noticed that the result was more solid than originally anticipated and adding a license to throw it at the public seemed logical. However, you are the judge of that so I would be happy if you gave it a spin and provided some feedback. Have fun!

repo

💖 💪 🙅 🚩
sroehrl
neoan

Posted on December 22, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related