Mastering Express Web Application Development will introduce the tools and libraries you need to take your Express development career to the next level. By learning how to use tools to make your life easier, you can do more in less time.
To start, we'll create a new Express application, learn how to configure it and increase application visibility by using logs. We will explore Express itself, along with various libraries that will help improve your development experience. We'll be building on the previous section's work each time. As we move on we'll take a look at technologies such as SSL and Nginx, and work through deploying your application to production in a secure and scalable way. Furthermore, we will study various existing Express projects that are open source, and a review of how they are structured to help you to organize your own applications in a systematic way.
By the end of the course, you will be an expert in using a wide range of new tools and libraries which will help you deliver the best value to your customers.
About the Author
Michael Heap is a polyglot developer who spends most of his time working with high volume real-time systems. He's an established conference speaker, and is passionate about sharing what he's learned during his career so far.
He holds a first class computing degree from Leeds Metropolitan University, and has been programming for just over 10 years. On a daily basis you'll find him writing NodeJS, PHP or Go (with a little Python/Scala thrown in to keep it interesting).
When we want to change some options in our application, we need to redeploy it for any small change. If we make things configuration-driven, we can change things simply by restarting the application.
By default, we have no idea how our application is working. Adding Winston logs throughout our application means that we can see what happens and when.
Express comes with a lot of defaults that people don't know they can change. Using Nunjucks shows that there are options out there that people can use.
We need dynamic content for our app. We'll show popular images from Instagram.
We have the Instagram data, but no way of showing it. We'll render the images using Nunjucks so that we can see them.
Our app is now slow, as we have to make a request to Instagram every time. We'll cache the results from Instagram so that the response is quicker.
So far, we have no guarantees that our application is working as expected. Installing Mocha is the first step toward solving this problem.
Our API calls are very tightly coupled to our application, which means that we can't test them. To make the code easier to test, we need to refactor the code into an externam module.
When writing tests for code that hits an external service, you can never guarantee what it will send back. Mocking this method gives you a known set of return data that you can use in your tests.
When implementing things such as caches, there's no way to prove that we actually try and fetch the data from the cache before hitting an external service. Using Sinon, we can spy on methods to make sure that they're actually called.
We've installed Socket.io, but it doesn't do anything yet. Let's add a real-time commenting system to our app.
Sometimes, we want to perform an action on every request, for example, authentication. Middleware allows us to run functions on every request.
Until now, each time we refresh, our data disappeared. Using MySQL, we can save our data so that it's still there when we come back later.
By default, NodeJS has a single event loop. If it gets blocked, no more requests can be handled. NodeJS cluster allows us to run multiple instances of our application, which means we have multiple event loops.
As NodeJS cluster is still experimental, we need a more reliable way to run multiple instances of our application. Thankfully, Nginx supports receiving requests and forwarding them on to another process, in this case, our application.
We've built a small application, but how does it measure up against other Express projects? Let's take a look at Ghost and see how they've structured things.
We've built a small application, but how does it measure up against other Express projects? Let's take a look at Balloons and see how they've structured things.
Packt has been committed to developer learning since 2004. A lot has changed in software since then - but Packt has remained responsive to these changes, continuing to look forward at the trends and tools defining the way we work and live. And how to put them to work.
With an extensive library of content - more than 4000 books and video courses -Packt's mission is to help developers stay relevant in a rapidly changing world. From new web frameworks and programming languages, to cutting edge data analytics, and DevOps, Packt takes software professionals in every field to what's important to them now.
From skills that will help you to develop and future proof your career to immediate solutions to every day tech challenges, Packt is a go-to resource to make you a better, smarter developer.
Packt Udemy courses continue this tradition, bringing you comprehensive yet concise video courses straight from the experts.