Overview While it is rare to build backends directly using raw Node.js today, understanding SQL injection attacks is still valuable. This article uses Node.js and MySQL to explain SQL injection vulnerabilities and how to mitigate them. SQL injection is an ancient attack that has existed since the ad...
Cookies remain a relevant mechanism for storing small amounts of string data in web applications, despite the prevalence of LocalStorage and SessionStorage. In HTTP communication, cookies are automatically included in requests sent from the client to the server, and servers can set cookies with broa...
To verify Node.js installlation, run the version check command: node --version A Node.js application consists of three core components: Module imports using require() Server creation to handle client requests Request/resopnse handlign logic Here's how to create a simple HTTP server: const server = r...
Server-Sent Events (SSE) establish a unidirectional, persistent connection enabling servers to push real-time data to browsers. Although an older specification, SSE has seen a massive resurgence as the backbone for streaming text generation in modern AI applications. Core Concepts Event Stream: A se...
Express is a web application framework for Node.js, designed for building web servers and APIs efficiently. It simplifies development compared to using Node.js's native http module directly, similar to how jQuery abstracts browser APIs. Setting Up Express Install Express in your project directory: n...
File manipulation is a fundamental server-side feature and an essential skill for backend development. File operations primarily involve reading and writing. Node.js provides built-in methods for these tasks, which you can invoke directly. Creating Directories Synchronous Method const fileSystem = r...
Native fs Module in Node.js The built-in fs module in Node.js provides file system operations using callback functions. Here's an example of reading a file: const fs = require('fs'); fs.readFile('./data/file.txt', 'utf8', (error, data) => { if (error) { console.error('Error reading file:', error)...
Node.js Overview and Download 1. Runtime Environments, Compilers, and Development Tools A runtime environment provides the necessary components to execute code, including a core compiler. Node.js is a JavaScript runtime environment. In contrast, an Integrated Development Environment (IDE) like Visua...
Streams in Node.js are a core abstraction for handling data flow, particularly useful when dealing with large files, video, audio, or network communications. They allow data to be processed in chunks as it becomes available, rather than loading antire datasets into memory at once. Consider a scenari...
To simulate a production environment locally, a server must be built to serve a bundled application. This involves using Node.js's http module to create a server that responds to browser requests. Two React projects are created for comparison: one using create-react-app (CRA) and another using creat...