{"library":"node-req","title":"Node.js HTTP Request Parser","description":"node-req is a minimalist I/O module designed to parse and extract specific values from Node.js's native `http.IncomingMessage` object, explicitly designed with no side-effects. It provides a set of helper methods for accessing common request components such as query strings, HTTP method, headers, IP addresses, protocol (HTTP/HTTPS), subdomains, and content negotiation details. Currently at version 2.1.2, this package has not received updates in approximately six years, indicating it is no longer actively maintained. Its core differentiation lies in its pure parsing approach, making no assumptions about routing or higher-level HTTP handling, thus allowing it to integrate into various Node.js server architectures as a low-level utility. It leverages the `qs` package internally for robust query string parsing.","language":"javascript","status":"abandoned","last_verified":"Thu Apr 23","install":{"commands":["npm install node-req"],"cli":null},"imports":["const nodeReq = require('node-req')","const { get } = require('node-req')","const { method } = require('node-req')"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const http = require('http');\nconst nodeReq = require('node-req');\n\nconst server = http.createServer((req, res) => {\n  // Parse query string (e.g., /?name=Alice&age=30)\n  const query = nodeReq.get(req);\n  const name = query.name || 'Guest';\n\n  // Get HTTP method (e.g., GET, POST)\n  const method = nodeReq.method(req);\n\n  // Get all request headers\n  const headers = nodeReq.headers(req);\n  const userAgent = nodeReq.header(req, 'user-agent');\n\n  // Get client IP address\n  const ip = nodeReq.ip(req, true); // `true` for trusting proxy headers\n\n  // Check if the request has a body (e.g., for POST, PUT)\n  const hasBody = nodeReq.hasBody(req);\n\n  res.writeHead(200, { 'Content-Type': 'text/plain' });\n  res.end(\n    `Hello, ${name}!\\n` +\n    `Method: ${method}\\n` +\n    `User-Agent: ${userAgent}\\n` +\n    `Client IP: ${ip}\\n` +\n    `Has Body: ${hasBody}\\n` +\n    `Full Query: ${JSON.stringify(query)}\\n`\n  );\n});\n\nconst PORT = process.env.PORT || 3000;\nserver.listen(PORT, () => {\n  console.log(`Server listening on http://localhost:${PORT}`);\n  console.log('Try visiting: http://localhost:3000/?name=Bob&city=NewYork');\n});","lang":"javascript","description":"This quickstart demonstrates how to set up a basic Node.js HTTP server and use `node-req` to parse various components of an incoming request, including query parameters, HTTP method, headers, and client IP, then respond with the extracted information.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}