Book Image

Node.js Blueprints

By : Krasimir Stefanov Tsonev
Book Image

Node.js Blueprints

By: Krasimir Stefanov Tsonev

Overview of this book

Table of Contents (19 chapters)
Node.js Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Writing the backend of the application


The backend is the Node.js part, which will take care of the data delivery and will serve the necessary HTML, CSS, and JavaScript functionalities. In order to learn something new in every chapter, we will use different approaches for the common tasks. For sure, there are things that we need to do every time, for example, running a server that listens on a particular port. JavaScript is a really interesting language, and in most cases, we can solve the same problems in completely different ways. In the previous chapters, we used Express to send assets to the users. In addition, there were examples where we did this directly by reading the files with the filesystem API. However, this time, we will combine the ideas of the two methods, that is, the code that we will use will read the resources from the hard disk and we will work with dynamic paths.

Running the Node.js server

We will start the project in an empty directory. In the beginning, we need an empty...