hapi — Become a Better Developer in 2018

We as Node.js developers are constantly feeling the hype around the next shiny new library. It seems every other day there’s a new one picking up steam. Well, our mind tells us to look at it and integrate into projects.

Ignore all the hype for a second and think about getting work done. This shiny new library in version 0.3 won’t help you get your work done. Keep focus, make progress and look what’s out there that might help you become a better developer.

hapi Series Overview

Jump on async/await: Upgrade to hapi v17

Node.js 8.x transitioned to LTS on October 31, 2017, and most of the Node.js community waited for this date: a stable and mature Node.js release including the newest hotness, async/await.

Eran Hammer (hapi’s lead maintainer) put a lot of time and effort into upgrading hapi to the latest Node.js features, including the move to async/await.

In 2018, you’ll update your project’s to hapi v17. If you need a helping hand, check our hapi v17 upgrade guide that walks you through all the changes.

We’ve updated our hapi plugins and the Futureflix Starter Kit (check the code on GitHub 😉) to be compatible with v17 and we love hapi’s changes. The move to both new async and await operators increases your code’s readability and removes callback and promise hell.

Use New ECMAScript Features

This tip could be part of every year’s prediction because we as developers need to remind it 😌 New Node.js releases come with new language features. The Node.js platform evolves fast and grows up.

If you’re an avid lodash user, this tip might be for you! For example, do you often check if an object or array includes a specific value? Node.js 8.x comes with .includes() natively. No more utilities needed in this case.

Node.js is 99% compatible with ES2015. Use default function parameter values, destructuring, object and array spread, and ES classes. Let them become a part of your daily development!

Auto-Format Code (with Prettier)

In last year’s post on becoming a better developer in 2017 we recommended to use a coding style, like hapi’s coding conventions or JavaScript Standard. In combination with ESLint your editor or IDE highlights related issues to the coding style.

2018 is the year of auto-formatting the code! No more whining about the missing space, empty line, semicolon, double quotes. Don’t worry about tests failing due to ESLint’s whining.

Use Prettier and the integrations in your favorite editor to auto-format code on save. Prettier is a code formatter, not only a linter. It integrates well with ESLint and if you’re already linting your code, you’re only a single step away from freedom. No more time wasted on going through your code to fix missing spaces 💪

Adopt a Client-Side Framework

Websites become powerful these days. You don’t need to reload the whole page when using asynchronous requests in the background. Well, there’s a trend towards client-side frameworks, like Vue.js.

Being a backend developer has the freedom of freely adding packages and using them in your project. Adding a package in the frontend may increase load times and reduce performance.

Put yourself in the hot seat of a frontend developer. Get to know their tooling, how they use your backend and API.

You’ll respond differently to the angry emails from your frontend developer once you feel their pain. Well, you could switch roles with them so they feel your backend problems, too. It’s a great learning!

GraphQL

There’s a hype around GraphQL and it’s for a reason. While most of us backend developers still think in REST, there’s a movement towards a lighter approach of sending data to clients.

GraphQL is a query language and runtime to respond to these queries. The benefit in comparison to REST is that GraphQL allows a client to exactly specify what data they need. REST has the problem of transferring all the data to clients, even though it’s not needed.

GraphQL overview

Expand your knowledge around GraphQL in 2018 and watch this platform. Graphcool and Apollo seem to be the go-to projects these days when starting out in GraphQL. They provide server and client repositories to get started 🚀

Contribute to a hapi Plugin and Open Source

The release of hapi v17 in the end of 2017 came with breaking changes. All hapi plugins need code updates to be compatible with the new major version.

This is your chance to contribute in the hapi ecosystem. Head over to the hapi contribution page on hapi’s website. Pick an issue for new contributors or check the help wanted section for specific plugin contributions.

At this point, there are a lot plugins seeking for v17 updates or new maintainers. Pick a repository of your choice, fork it and submit a pull request with updates. All maintainers are friendly and helpful, they’ll point and guide you through improvements you might have missed.

Actually, I did it the same way: picked catbox-mongodb and submitted a pull request to update the library to hapi v17.

After hints, tricks, tips, and help from other maintainers, they merged my PR. I learned a lot about async/await and hapi’s changes in the new major version. Also, putting your head around serious testing is eye-opening!

And now I’m the maintainer of catbox-mongodb 😃

Take your chance!

Become a Better hapi Developer in 2018

It’s still early in 2018, the best time to reflect and plan for the year. Set goals and hold yourself accountable throughout the year. Make a plan for the first quarter of 2018 and put in the work.

To remind you of possible actions to take:

  • Upgrade to hapi v17 and async/await
  • Use new ECMAScript features
  • Auto-format code with Prettier
  • Adopt a client-side framework
  • Put an eye on GraphQL
  • Contribute to open source

Give yourself accountability by sharing your actions in the comments below or tweet us @futurestud_io. Do you have further aspects and tools for 2018 where you what you want to improve? Please share it with us :)

Make 2018 rock!


Mentioned Resources

Explore the Library

Find interesting tutorials and solutions for your problems.