Express Quick Sheet
Settings
Express Quick Sheet
Settings
app.set('x', 'yyy')app.get('x') //=> 'yyy'
app.enable('trust proxy')app.disable('trust proxy')
app.enabled('trust proxy') //=> true
Enviorment {#ced4 .graf .graf--h3 .graf-after--pre name="ced4"}
app.get('env')
Config
app.configure('production', function() { app.set...})
Wares
app.use(express.static(__dirname + '/public'))app.use(express.logger())
Helpers
app.locals({ title: "MyApp",})
Request & response
Request
// GET /user/tjreq.path //=> "/user/tj"req.url //=> "/user/tj"req.xhr //=> true|falsereq.method //=> "GET"req.paramsreq.params.name //=> "tj"req.params[0]
// GET /search?q=tobi+ferretreq.query.q // => "tobi ferret"
req.cookies
req.accepted// [ { value: 'application/json', quality: 1, type: 'application', subtype: 'json' },// { value: 'text/html', quality: 0.5, type: 'text',subtype: 'html' } ]
req.is('html')req.is('text/html')
```js {#64c5 .graf .graf--pre .graf-after--pre name="64c5"}
req.headersreq.headers['host']req.headers['user-agent']req.headers['accept-encoding']req.headers['accept-language']
### Response
```js
res.redirect('/')res.redirect(301, '/')
res.set('Content-Type', 'text/html')
res.send('hi')res.send(200, 'hi')
res.json({ a: 2 })
Top comments (0)