req.secure

req.secure A Boolean property that is true if a TLS connection is established. Equivalent to: 'https' == req.protocol;

req.query

req.query This property is an object containing a property for each query string parameter in the route. If there is no query string, it is the empty object, {}. // GET /search?q=tobi+ferret req.query.q // => "tobi ferret" // GET /shoes?order=desc&shoe[color]=blue&shoe[type]=converse req.query.order // => "desc" req.query.shoe.color // => "blue" req.query.shoe.type // => "converse"

res.headersSent

res.headersSent Boolean property that indicates if the app sent HTTP headers for the response. app.get('/', function (req, res) { console.log(res.headersSent); // false res.send('OK'); console.log(res.headersSent); // true });

req.fresh

req.fresh Indicates whether the request is “fresh.” It is the opposite of req.stale. It is true if the cache-control request header doesn’t have a no-cache directive and any of the following are true: The if-modified-since request header is specified and last-modified request header is equal to or earlier than the modified response header. The if-none-match request header is *. The if-none-match request header, after being parsed into its directives, does not match the etag response header. r

req.ip

req.ip Contains the remote IP address of the request. When the trust proxy setting does not evaluate to false, the value of this property is derived from the left-most entry in the X-Forwarded-For header. This header can be set by the client or by the proxy. req.ip // => "127.0.0.1"

Basic routing

Routing refers to determining how an application responds to a client request to a particular endpoint, which is a URI (or path) and a specific HTTP request method (GET, POST, and so on). Each route can have one or more handler functions, which are executed when the route is matched. Route definition takes the following structure: app.METHOD(PATH, HANDLER) Where: app is an instance of express. METHOD is an HTTP request method. PATH is a path on the server. HANDLER is the function executed

Routing

Routing refers to the definition of application end points (URIs) and how they respond to client requests. For an introduction to routing, see Basic routing. The following code is an example of a very basic route. var express = require('express'); var app = express(); // respond with "hello world" when a GET request is made to the homepage app.get('/', function(req, res) { res.send('hello world'); }); Route methods A route method is derived from one of the HTTP methods, and is attached to a

res.append()

res.append(field [, value]) res.append() is supported by Express v4.11.0+ Appends the specified value to the HTTP response header field. If the header is not already set, it creates the header with the specified value. The value parameter can be a string or an array. Note: calling res.set() after res.append() will reset the previously-set header value. res.append('Link', ['<http://localhost/>', '<http://localhost:3000/>']); res.append('Set-Cookie', 'foo=bar; Path=/; HttpOnly'); re

req.originalUrl

req.originalUrl req.url is not a native Express property, it is inherited from Node’s http module. This property is much like req.url; however, it retains the original request URL, allowing you to rewrite req.url freely for internal routing purposes. For example, the “mounting” feature of app.use() will rewrite req.url to strip the mount point. // GET /search?q=something req.originalUrl // => "/search?q=something"

app.get()

app.get(path, callback [, callback ...]) Routes HTTP GET requests to the specified path with the specified callback functions. For more information, see the routing guide. You can provide multiple callback functions that behave just like middleware, except these callbacks can invoke next('route') to bypass the remaining route callback(s). You can use this mechanism to impose pre-conditions on a route, then pass control to subsequent routes if there’s no reason to proceed with the current route.