Find online courses made by experts from around the world.
Take your courses with you and learn anywhere, anytime.
Learn and practice real-world skills and achieve your goals.
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).
Not for you? No problem.
30 day money back guarantee.
Learn on the go.
Desktop, iOS and Android.
Certificate of completion.
|Section 1: Getting Started|
|This video will offer the overview of the course.|
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.
|Section 2: Consuming Services|
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.
|Section 3: Proving That Our Application Works|
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.
|Section 4: Let's Get Real-time|
|Our application is currently static. It loads data once and then it doesn't change. By installing Socket.io, we can provide real-time functionalities.|
We've installed Socket.io, but it doesn't do anything yet. Let's add a real-time commenting system to our app.
|We can send data to everyone, but what if we want to send data to a specific user? Let's add a chatroom to our application.|
|We can send messages to specific people, but how do we send messages to everyone? Let's create a public room for people to chat in.|
|Section 5: Advanced Express|
Sometimes, we want to perform an action on every request, for example, authentication. Middleware allows us to run functions on every request.
|Each section of an application can be considered separate—user management is different from a checkout and payment process. Subapplications allow you to write multiple distinct modules and glue them all together in one application.|
|For AJAX requests, we usually don't want to send back HTML. Express makes it really easy to send back JSON for AJAX requests.|
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.
|Section 6: Security|
|Unless your application is running over HTTPS, communication between your app and the user isn't encrypted. To encrypt the data, we need an SSL certificate to run over HTTPS.|
|CSRF is when people can trigger actions on your site with carefully crafted links/forms on their site. To prevent this, we use node-csurf, which generates a token on every request that we check.|
|There are a lot of lesser known but still important application vulnerabilities out there. Helmet provides an easy way to mitigate several of them, wrapped up in one useful library.|
|Section 7: Shipping to Production|
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.
|When our application crashes, it will stay dead until we restart it. This means that no requests will be accepted from users. Supervisord will watch our application and automatically restart it when needed.|
|Section 8: Using Larger Express Applications|
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.
Over the past ten years Packt Publishing has developed an extensive catalogue of over 2000 books, e-books and video courses aimed at keeping IT professionals ahead of the technology curve. From new takes on established technologies through to the latest guides on emerging platforms, topics and trends – Packt's focus has always been on giving our customers the working knowledge they need to get the job done. Our Udemy courses continue this tradition, bringing you comprehensive yet concise video courses straight from the experts.