You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Performs content-negotiation on the Accept HTTP header
27
+
* on the request object, when present. It uses `req.accepts()`
28
+
* to select a handler for the request, based on the acceptable
29
+
* types ordered by their quality values. If the header is not
30
+
* specified, the first callback is invoked. When no match is
31
+
* found, the server responds with 406 “Not Acceptable”, or invokes
32
+
* the `default` callback.
33
+
*
34
+
* The `Content-Type` response header is set when a callback is
35
+
* selected. However, you may alter this within the callback using
36
+
* methods such as `res.set()` or `res.type()`.
37
+
*
38
+
* The following example would respond with `{ "message": "hey" }`
39
+
* when the `Accept` header field is set to “application/json”
40
+
* or “*\/json” (however if it is “*\/*”, then the response will
41
+
* be “hey”).
42
+
*
43
+
* res.format({
44
+
* 'text/plain': function(){
45
+
* res.send('hey');
46
+
* },
47
+
*
48
+
* 'text/html': function(){
49
+
* res.send('<p>hey</p>');
50
+
* },
51
+
*
52
+
* 'appliation/json': function(){
53
+
* res.send({ message: 'hey' });
54
+
* }
55
+
* });
56
+
*
57
+
* By default it passes an `Error`
58
+
* with a `.status` of 406 to `next(err)`
59
+
* if a match is not made. If you provide
60
+
* a `.default` callback it will be invoked
61
+
* instead.
62
+
*
63
+
* @param {Object} obj
64
+
* @return {Response} for chaining
65
+
*/
11
66
format: (obj: Object)=>Response;
67
+
/**
68
+
* Sends a JSON response. This method sends a response (with the correct content-type) that is the parameter converted to a JSON string using JSON.stringify().
69
+
*
70
+
* The parameter can be any JSON type, including object, array, string, Boolean, number, or null, and you can also use it to convert other values to JSON.
71
+
*
72
+
* ```js
73
+
* res.json(null)
74
+
* res.json({ user: 'tobi' })
75
+
* res.status(500).json({ error: 'message' })
76
+
* ```
77
+
* @param {Object} body Any type of oject
78
+
*/
12
79
json: (body: Object)=>void;
80
+
/**
81
+
* Sends the HTTP response.
82
+
* @param {Object} body
83
+
*/
13
84
send: (body: Object)=>void;
85
+
/**
86
+
* Set response header
87
+
* @param {string} key Header key
88
+
* @param {string} value Header value
89
+
*/
14
90
set: (key: string,value: string)=>Response;
91
+
/**
92
+
* Set status code for response
93
+
* @param {number} status Status code. Ex: 200, 201, 400, 404, 500 etc.
94
+
*/
15
95
status: (status: number)=>Response;
96
+
/**
97
+
* Sets the Content-Type HTTP header
98
+
*
99
+
* @param {string} type Mime type will be set as Content-Type response header
0 commit comments