-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
http.js
69 lines (59 loc) · 3.33 KB
/
http.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/**
* HTTP Server Settings
* (sails.config.http)
*
* Configuration for the underlying HTTP server in Sails.
* (for additional recommended settings, see `config/env/production.js`)
*
* For more information on configuration, check out:
* https://sailsjs.com/config/http
*/
module.exports.http = {
/****************************************************************************
* *
* Sails/Express middleware to run for every HTTP request. *
* (Only applies to HTTP requests -- not virtual WebSocket requests.) *
* *
* https://sailsjs.com/documentation/concepts/middleware *
* *
****************************************************************************/
middleware: {
/***************************************************************************
* *
* The order in which middleware should be run for HTTP requests. *
* (This Sails app's routes are handled by the "router" middleware below.) *
* *
***************************************************************************/
order: [
'cookieParser', // Default HTTP cookie parser.
// 'session', // We are using our own custom handling of sessions, via policies and responses.
'bodyParser', // Default HTTP request body parser.
'compress', // Default HTTP compression handler.
'customPoweredBy', // Custom header middleware (found below).
'router', // Default route handler (config/routes.js)
'assetLog', // Custom middleware to finalize request logs for what is assumed to be assets.
'www', // Default hook to serve static files.
'favicon' // Default hook to serve favicon.
],
customPoweredBy: (req, res, next) => {
// Set our own custom "X-Powered-By" header.
res.set('X-Powered-By', 'Awesome Sauce');
return next();
},
assetLog: async (req, res, next) => {
await sails.helpers.finalizeRequestLog(req, res, {body: 'asset likely'});
return next();
}
},
/****************************************************************************************
* *
* These are custom configuration options, designed so the `keep-models-safe` helper *
* can standardize date formats for you. This also means you can customize how you *
* see date data from your API on your local machine, if you were so inclined. *
* *
****************************************************************************************/
dateOutput: {
format: '', // Empty string defaults to ISO-8601.
tz: 'UTC' // Timezone coercion.
}
};