Learn Node.js by building a backend framework with 0 dependencies
Ishtmeet Singh
Posted on August 31, 2024
I have created an open-source (free) book on github for everyone who is trying to dip their feet into the world of backend development (not just Node.js)
You can also access the content in a more easy-to-follow way on the book’s website - CacheLane - Learn Node.js the Hard Way
This is going to take a very long time to build a finished version (a couple of months), but no worries, I have committed myself and promised to add new content every single day. So even if you're someone who likes to read a little at a time, you're going to receive enough content every day to read and gain knowledge from.
Back to the main point. What is this book all about?
We start from basically 0 knowledge (little javascript knowledge is preferred) and end up creating a complete production ready backend framework, with absolutely 0 libraries at all! You're not going to ever do npm install
throughout the book. On top of that, we're also going to create a cors, logging and tracing library, from scratch - that too without any dependencies. Say no to npm install
Isn't it better to work smart and not hard?
Yes, you may be right. But to learn things the proper way, and to have solid foundations, you have to ditch all the tools that do the heavy lifting for you, and do everything from scratch, to understand how the internals work.
If you know how the internals work, you are not limited by any language or framework. You can apply that knowledge no matter what language or framework you're working with.
These are some of the topics you can expect to master/learn throughout the book
- Best coding practices, and how to properly think ahead when starting a massive/complex project. We'll start small, with a piece of code that just works. Then refactor that to make it modular, and reusable.
- In-depth understanding of web and networks and an intro to how do websites/servers work
- Learn the best practices for creating reusable modules, to be used throughout your projects, not just one.
- Low level file handling and learn about file handles, file descriptors, closing them and reusing them for efficient file processing.
- Buffers and Streams are going to be used thoroughly throughout the book. You learn various ways to deal with files, loading all at once in memory or load it in chunks/buffer (streams)
- Proper error handling
- HTTP, HTTP2 and a little on HTTP3. Our web framework will be HTTP2 compatible.
- There will also be a small section explaining about
regex
es, as they're an essential tool, especially when we're building a web framework, our router should handle regex based paths - File rolling for our logger. Our log library will log to files, and a new file will be issued whenever there are certain limits reached. Limits will be provided by the client who uses our library. Some of those are - 1. create a new log file every X seconds, minutes, hours, days or weeks. 2. Issue a new file whenever its size reaches a specific threshold. 3. Add the request duration and other metadata. 4. Allow some sensitive fields to ignore while logging.
- We'll also create a mini cors middleware from scratch, which will come packaged with our backend framework.
- Support static file serving.
- And much more.
We're also going to benchmark our framework's endpoints and compare it with some of the fastest nodejs web frameworks out there.
I plan to add many more features to this guide cum book. If you're interested you can check it out on github.
Any suggestions and improvements are welcome.
Posted on August 31, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.