Learn Node.js by building a backend framework - Velocy
You can access the current version of the book in the chapters directory or in PDF format (both Light and Dark modes are available) by clicking here. Note that this version includes the current release of the content, and is not the final version.
This book is still in a very early stage. It contains an insignificant portion of the total content that the book is supposed to cover. There’s going to be 0 dependencies for our backend framework, as well as our logging library. Everything will be done using vanilla Node.js, the hard-way (the best way to learn).
If you're not familiar with javascript, you may also check out my other repository - Learn Javascript - The Easy Way that takes you on a deep and a fun journey into Javascript - from the very basics to the advanced concepts that you'd ever need, without diving into too much theory. Only practical code examples.
To master a new concept, it's often best to begin from the ground up. This isn't just another Node.js guide; it's a comprehensive, code-along experience aimed at building a real world product that may be used by thousands of developers. The product that we're going to build will be a backend framework, that too from scratch.
You won't just learn how Node.js works, but also why it operates in a particular way. The guide also includes discussions on relevant data structures and design patterns.
The book also includes a wide range of exercises specifically created to challenge you, that may require commitment and consistent effort on your part. The first exercises start from chapter 7
This guide goes beyond the basics. We're focused on delivering a modular, optimized backend framework that is close to being production-ready. Topics like performance optimization, security measures, and various testing approaches will be covered to ensure the framework is both reliable and extendable.
I highly recommend actively coding alongside this guide, rather than just reading through it, for a full understanding of Node.js and its more intricate aspects.
The repo for our backend framework- Velocy. (W.I.P)
- (Optional) Node.js is way faster than you think
- What the heck is a web server any way?
- Your first
node.js
program - Working with files
- What will the logging library do
- How do you work with files anyway?
- Let’s get back to
files
- A little more about file descriptors
- Creating our first file
path
argumentflag
argumentmode
argument- Reading from a file
- A small primer on
for..of
andfor await..of
in javascript - Reading the
json
file - Buffers
logtar
our own logging library- Initializing a new project
- A little about
SemVer
- Creating a
LogLevel
class - The
Logger
class - The
LogConfig
class - Design patterns
- Using
builder
pattern with theLogConfig
class - jsdoc comments
- The
RollingConfig
class - Finishing up the
RollingConfig
class - Adding more useful methods in the
LogConfig
class - Refactoring the code
- Writing logs
- 1. Re-using the File Handle
- 2. Log Rotation
- 3. Asynchronous Logging
- 4. Getting Caller Information (Module and Line Number)
- Testing our current API
- Implementing logging methods
- DRY (Don't Repeat Yourself)
- The
log
method - Considering the
log_level
member variable - Writing to a file
- Another gotcha
- Logs directory configuration
- The
require
object - Adding a new helper to create log directory
- Updating the
init
method - Completing the
log
method
- Capturing metadata
- A small intro to
async
vssync
- Adding Rolling File Support
- Stack traces across
await
points
- HTTP Deep dive
Velocy
- Our backend framework- Why Velocy?
- What is a backend framework/library anyway?
- Core features of our backend framework
- A basic
Router
implementation - The
Router
class this
is not good- Improving the
Router
API - The Need for a
Trie
- Ex. Implementing a
Trie
- Ex. Implementing our Trie based
Router
- Ex. Adding
HTTP
method support - Adding HTTP methods to the Router
- Ex. Implementing Dynamic Routing
- Running Our Server
- Building our first web-server
- Ex. Query Parameters (Advanced)