I am new to node.js and was going through an example could not understand app.set(\'title\', \'My Site\'); does please help?
I know I am a bit late to the party but I had the same problem and that's how I got here. After I did some research, I fell that the answer is a bit incomplete. In case that first parameter is an application setting, the following table must be read.
Property -> Type -> Description
case sensitive routing -> Boolean -> Enable case sensitivity. When enabled, "/Foo" and "/foo" are different routes. When disabled, "/Foo" and "/foo" are treated the same.
env ->
String ->
Environment mode. Be sure to set to "production" in a production environment; see Production best practices: performance and reliability.
process.env.NODE_ENV (NODE_ENV environment variable) or “development” if NODE_ENV is not set.
etag -> Varied -> Set the ETag response header. For possible values, see the etag options table.
jsonp callback name -> String -> Specifies the default JSONP callback name.
json replacer ->
Varied ->
The 'replacer' argument used by JSON.stringify
.
NOTE: Sub-apps will inherit the value of this setting.
json spaces ->
Varied ->
The 'space' argument used by JSON.stringify
. This is typically set to the number of spaces to use to indent prettified JSON.
NOTE: Sub-apps will inherit the value of this setting.
query parser -> Varied -> Disable query parsing by setting the value to false, or set the query parser to use either “simple” or “extended” or a custom query string parsing function. The simple query parser is based on Node’s native query parser, querystring. The extended query parser is based on qs. A custom query string parsing function will receive the complete query string, and must return an object of query keys and their values.
strict routing -> Boolean -> Enable strict routing. When enabled, the router treats "/foo" and "/foo/" as different. Otherwise, the router treats "/foo" and "/foo/" as the same. NOTE: Sub-apps will inherit the value of this setting.
subdomain offset -> Number -> The number of dot-separated parts of the host to remove to access subdomain.
trust proxy -> Varied -> Indicates the app is behind a front-facing proxy, and to use the X-Forwarded-* headers to determine the connection and the IP address of the client. NOTE: X-Forwarded-* headers are easily spoofed and the detected IP addresses are unreliable.
When enabled, Express attempts to determine the IP address of the client connected through the front-facing proxy, or series of proxies. The req.ips
property, then contains an array of IP addresses the client is connected through. To enable it, use the values described in the trust proxy options table.
The trust proxy
setting is implemented using the proxy-addr package. For more information, see its documentation.
NOTE: Sub-apps will inherit the value of this setting, even though it has a default value.
views ->
String or Array ->
A directory or an array of directories for the application's views. If an array, the views are looked up in the order they occur in the array.
process.cwd() + '/views'
view cache -> Boolean -> Enables view template compilation caching.
view engine -> String -> The default engine extension to use when omitted. NOTE: Sub-apps will inherit the value of this setting.
x-powered-by -> Boolean -> Enables the "X-Powered-By: Express" HTTP header.