净化

已被 leekafai 抢先认领啦

8 Tips to Build Better Node.js Apps in 2018 | @RisingStack

原文链接: blog.risingstack.com

RisingStack


Subscribe for the newsletter

Hire us

Node.js Development 24/7 Node.js Support On-site Node Trainings

Choose your path

Beginner Node.js Tutorials
Advanced Node.js Tutorials
Node.js & Microservices

Blog > Node.js Tutorials for Beginners

6 days ago January 9th, 2018

8 Tips to Build Better Node.js Apps in 2018

Bertalan Miklos's Picture by Bertalan Miklos(@solkimicreb), Full-Stack Developer at RisingStack

In the previous two years we covered best practices for writing and operating Node.js applications (read the 2016 edition & 2017 edition). Another year has passed, so it’s time to revisit the topic of becoming a better developer!

In this article, we collected a few tips that we think Node.js developers should follow in 2018. Feel free to pick some development related New Year's resolutions!

Tip #1: Use async - await

Async - await landed in Node.js 8 with a boom. It changed how we handle async events and simplified previously mind-boggling code bases. If you are not yet using async - await read our introductory blog post.

Refreshing your knowledge about old school async programming and Promises may also help.

Tip #2: Get acquainted with import and import()

ES modules are already widely used with transpilers or the @std/esm library. They are natively supported since Node.js 8.5 behind the --experimental-modules flag, but there is still a long way until they become production ready.

We suggest you to learn the foundations now and follow the progress in 2018. You can find a simple ES modules tutorial with Node.js here.

Tip #3: Get familiar with HTTP/2

HTTP/2 is available since Node.js 8.8 without a flag. It has server push and multiplexing, which paves the way for efficient native module loading in browsers. Some frameworks - like Koa and Hapi - partially support it. Others - like Express and Meteor - are working on the support.

HTTP/2 is still experimental in Node.js, but we expect 2018 to bring wide adoption with a lot of new libraries. You can learn more about the topic in our HTTP/2 blog post.

Tip #4: Get rid of code style controversies

Prettier was a big hit in 2017. It is an opinionated code formatter, which formats your code instead of simple code style warnings. There are still code quality errors - such as no-unused-vars and no-implicit-globals - that can not be automatically reformatted.

The bottom line is, that you should use Prettier together with your good old fashioned linter in your upcoming projects. It helps a lot, especially if you have people with dyslexia in your team.

Tip #5: Secure your Node.js applications

There are big security breaches and newly found vulnerabilities every year, and 2017 was no exception. Security is a rapidly changing topic, which can not be ignored. To get started with Node.js security, read our Node.js Security Checklist.

If you think your application is already secure, you can use Snyk and the Node Security Platform to find sneaky vulnerabilities.

Tip #6: Embrace microservices

If you have deployment issues or upcoming large-scale projects, it may be time to embrace the microservices architecture. Learn these two techs to stay up to date in 2018's microservices scene.

Docker is a software technology providing containers, which wrap up a piece of software in a complete filesystem that contains everything it needs to run: code, runtime, system tools and system libraries.

Kubernetes is an open-source system for automating deployment, scaling, and management of containerized applications.

Before getting too deep into containers and orchestration, you can warm up by improving your existing code. Follow the 12-factor app methodology, and you will have a much easier time containerizing and deploying your services.

Tip #7: Monitor your services

Fix issues before your users even notice them. Monitoring and alerting is a crucial part of production deployment, but taming a complex microservice system is no easy feat. Luckily this is a rapidly evolving field, with ever-improving tools. Check out what the future of monitoring holds or learn about the recent OpenTracing standard.

If you are a more practical person our Prometheus tutorial gives a nice intro to the world of monitoring.

Tip #8: Contribute to open-source projects

Do you have some favorite Node.js projects? Chances are that they could use your help to become even better. Just find an issue that matches your interest and jump into coding.

If you don't know how to get started, run through these quick tips or watch this course about open-source contribution on GitHub. Doing is the best way of learning, especially for programmers.

What's your Node.js Development advice?

What else would you recommend to your fellow Node.js developers to get right in 2018? Leave your opinion in the comments section!

We hope that you will have an awesome 2018. Happy coding!

Follow @RisingStack

TAGS:

Node.js Tutorials for Beginners The Node.js Community

Read more from us:

Get early access to our posts

/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE / var disqus_shortname = 'risingstackblog'; / DON'T EDIT BELOW THIS LINE */ (function() { var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); })();

Please enable JavaScript to view the comments powered by Disqus.

comments powered by Disqus

Blog

Best articles Node Hero Tutorials Node.js at Scale Tutorials

Resources

Node.js Maturity Checklist Trace by RisingStack - Node.js Monitoring Node.js is Enterprise Ready RisingStack Community Node.js Daily

Connect

RisingStack.com Twitter Github Facebook

We ♥ Node.js © RisingStack, Inc. 2017 | RisingStack® and Trace by RisingStack® are registered trademarks of RisingStack, Inc.

console.log("__ _ _ _ _ _ \n| _ \() () / _|| | | | \n| |_/ / _ _ _ _ _ \\ `--. | |_ _ _ | | \n| / | |/ || || '_ \\ / _|--. \| | / ` | / || |/ /\n| |\\ \\ | |\\ \| || | | || (| |/\_/ /| | | (| || (__ | < \n\\| \_||_||_/|_||| || \\, |\__/ \\| \__,_| \_|||\\\\\n / | \n |___/ \n"); console.log("You like to look under the hood? Why not join us? https://risingstack.workable.com") var _dcq = _dcq || []; var _dcs = _dcs || {}; _dcs.account = '3044742'; (function() { var dc = document.createElement('script'); dc.type = 'text/javascript'; dc.async = true; dc.src = '//resources.risingstack.com/js/drip.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(dc, s); })();

<iframe src="//www.googletagmanager.com/ns.html?id=GTM-KV8B2T" height="0" width="0" style="display:none;visibility:hidden"></iframe>

(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= '//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-KV8B2T'); var loadDeferredStyles = function() { var addStylesNode = document.getElementById("deferred-styles"); var replacement = document.createElement("div"); replacement.innerHTML = addStylesNode.textContent; document.body.appendChild(replacement) addStylesNode.parentElement.removeChild(addStylesNode); }; var raf = requestAnimationFrame || mozRequestAnimationFrame || webkitRequestAnimationFrame || msRequestAnimationFrame; if (raf) raf(function() { window.setTimeout(loadDeferredStyles, 0); }); else window.addEventListener('load', loadDeferredStyles);