nodejs
3 guides
How to handle errors in Node.js: try/catch, error-first callbacks, promises, and event emittersNode.js errors come in several asynchronous styles, and each has its own correct way to be caught. This guide explains try/catch for synchronous code, error-first callbacks, promise rejection handling, and the 'error' event for streams and event emitters.How to Use Environment Variables in Node.js: process.env, .env files, and secure secretsEnvironment variables are the standard way to configure a Node.js app without hardcoding values. Node reads them through process.env, you can load them from .env files with the built-in --env-file flag or the dotenv package, and secrets should stay out of your code and version control. This guide walks through each approach and when to use it.How to implement rate limiting in Node.js: algorithms and practical examplesRate limiting protects Node.js APIs from abuse and overload. This guide explains fixed window, sliding window, and token bucket algorithms, shows how to add rate limiting to an Express API, and how to test it.