In this tutorial, I'll talk about how I set up Kafka to provide website analytics and event tracking for a web application. For my use case, I wanted to store and process raw...
Update (Mar.29, 2018): I now recommend using NextJS to build server-rendered React applications. Read more about it here. This tutorial will explain the simplest way I have found...
This is how fast your coverage numbers will go up. I was recently working on an application at work which was stable but had no automated test coverage. As it got bigger, I grew...
Every web application in the world that maintains user data has to deal with sessions. As developers, we need to know what they are and how to use them. This post explains how sessions work in Express.
Six quick tips which will help you build more maintainable APIs.
Today, I’ll talk about my process for building and deploying static websites using Metalsmith, a static site generator for NodeJS. A static website is appropriate for a...
Everyone agrees that web application security is very important but few take it seriously. Here's a 13-step security checklist that you should follow before deploying your next web application.
If you have used Bedrock, you have probably set up user authentication for your web application. If you haven’t, check out how to do that in this post. However, you may have...
If you’ve used Prettier before, you may have gone with a version that is integrated into your editor of choice. I’m normally using VS Code, so I have Prettier run every time I save a file.
That’s great when I’m the only developer working on the project, but what if you have multiple developers? Sometimes, my personal Prettier options (4 spaces, double quotes for commas, etc.) are different from my colleague’s.
For these cases, we’ve made Prettier and Git work together. Prettier runs on a pre-commit git hook via the precommit script.
To do this, first install Prettier, lint-staged and husky as dev dependencies for the project.
npm install prettier lint-staged husky --save-dev
Next, add the following to your application’s package.json.
"./node_modules/prettier/bin/prettier.js --tab-width 4 --write",
This says that whenever a git commit is triggered, Prettier will run with the provided options on all *.js files, and these files will then be added to the commit.
This is how it’ll look when you commit your code next time.
❯ git commit -m 'change date formatting'
husky > npm run -s precommit (node v8.4.0)
✔ Running tasks for *.js
[my-test-branch 57a53ea6] change date formatting
1 file changed, 1 insertion(+), 1 deletion(-)
It’s important to note that no additional commits are created. Your existing commit is modified by running Prettier on any JS files that you committed. If you wanted to create a separate commit, you would use a postcommit hook.
Get future articles sent directly to your inbox.
I only send emails when I write something new.