← Back to Tutorials
Chapter 14
Practice & Certification
Node.js Compiler
Node.js uses the V8 JavaScript engine, which features JIT (Just-In-Time) compilation. However, there are tools to compile Node.js applications into standalone executables.
# pkg - Package Node.js into executable
npm install -g pkg
pkg app.js --output myapp
# nexe - Create standalone executables
npm install -g nexe
nexe app.js --output myapp.exe
# Node SEA (Single Executable Applications) - experimental
# node --experimental-sea-config sea-config.json
Examples
REST API (Complete Example)
const express = require('express');
const app = express();
app.use(express.json());
let tasks = [];
let id = 1;
app.get('/tasks', (req, res) => res.json(tasks));
app.post('/tasks', (req, res) => {
const { title } = req.body;
if (!title) return res.status(400).json({ error: 'Title required' });
const task = { id: id++, title, completed: false };
tasks.push(task);
res.status(201).json(task);
});
app.put('/tasks/:id', (req, res) => {
const task = tasks.find(t => t.id === parseInt(req.params.id));
if (!task) return res.status(404).json({ error: 'Task not found' });
Object.assign(task, req.body);
res.json(task);
});
app.delete('/tasks/:id', (req, res) => {
tasks = tasks.filter(t => t.id !== parseInt(req.params.id));
res.status(204).send();
});
app.listen(3000);
Exercises (All Chapters)
Ch1: Create a script that prints your name, the date, and the OS platform.
Ch2: Read 3 files in parallel, concatenate, and write to a new file.
Ch3: Create an NPM project with chalk and print colored text.
Ch4: Build a CLI tool that reads, compresses, hashes, and writes metadata.
Ch5: Create a TypeScript file with a Task interface and compile it.
Ch6: Build a task management REST API with Express.js.
Ch7: Create a product catalog API with Mongoose and aggregations.
Ch8: Build a real-time chat application with Socket.IO and rooms.
Ch9: Write Jest tests for the task API with supertest.
Ch10: Create a Dockerfile for the task API with multi-stage build.
Ch11: Run the task API in cluster mode with PM2 and benchmark.
Ch12: Propose a microservices architecture for an e-commerce app.
Ch13: Build a weather station on Raspberry Pi with WebSockets.
Ch14: Complete practice problems below.
Quiz
What is the event loop in Node.js?
What is the difference between CommonJS and ES Modules?
How does Node.js handle multiple concurrent requests with a single thread?
What are the phases of the event loop?
When would you use worker_threads vs cluster?
What is the purpose of the next() function in Express middleware?
How do you handle unhandled promise rejections?
What is the difference between require and import?
How does the fs.promises API differ from fs callbacks?
What is the purpose of package-lock.json?
Practice Problems
Write a function that recursively lists all files in a directory tree.
Create a command-line to-do app that persists tasks to a JSON file.
Implement a rate limiter middleware for Express.
Build a real-time stock price simulator using Socket.IO.
Create a simple key-value store that persists to disk (similar to Redis).
Implement a URL shortener service with Express and a database.
Write a file watcher that logs changes and triggers a build script.
Study Plan
Week Topics Goal
1 Ch1-2 Understand Node.js architecture and async programming
2 Ch3-4 Master modules, NPM, and core modules
3 Ch5-6 Build web applications with Express
4 Ch7-8 Integrate databases and real-time communication
5 Ch9-10 Test, debug, and deploy applications
6 Ch11-13 Scale, optimize, and explore advanced topics
7 Ch14-15 Practice projects and review
Interview Preparation
Common Interview Questions
Explain the Node.js event loop in detail.
How do you handle errors in async functions?
What is the difference between process.nextTick, setImmediate, and setTimeout?
How does Node.js handle file system operations?
Explain streams and buffers in Node.js.
How would you scale a Node.js application?
What are the security best practices for Node.js applications?
How do you manage environment-specific configuration?
Explain middleware in Express.js.
How do you debug a Node.js application in production?
Bootcamp Projects
Beginner: Blog API with Express and file-based storage
Intermediate: E-commerce API with MongoDB, JWT auth, and Stripe integration
Advanced: Real-time collaborative document editor (like Google Docs) using Socket.IO and OT
Expert: Microservices-based video streaming platform with gRPC, Redis, and RabbitMQ
Certification Path
Consider the following certifications to validate your Node.js skills:
OpenJS Node.js Application Developer (JSNAD): Foundational knowledge
OpenJS Node.js Services Developer (JSNSP): Focus on building services
AWS Certified Developer — Associate: Node.js on AWS
Microsoft Certified: Azure Developer Associate: Node.js on Azure
Final Exercise: Build a complete e-commerce REST API with the following features: user registration/login with JWT, product catalog with categories, shopping cart, order management, payment integration (Stripe mock), and admin dashboard endpoints. Write comprehensive tests and create a Docker Compose setup.
← Previous: Hardware & IoT
Back to Index
Next: References →