http.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /**
  2. * HTTP Server Settings
  3. * (sails.config.http)
  4. *
  5. * Configuration for the underlying HTTP server in Sails.
  6. * Only applies to HTTP requests (not WebSockets)
  7. *
  8. * For more information on configuration, check out:
  9. * http://sailsjs.org/#/documentation/reference/sails.config/sails.config.http.html
  10. */
  11. module.exports.http = {
  12. /****************************************************************************
  13. * *
  14. * Express middleware to use for every Sails request. To add custom *
  15. * middleware to the mix, add a function to the middleware config object and *
  16. * add its key to the "order" array. The $custom key is reserved for *
  17. * backwards-compatibility with Sails v0.9.x apps that use the *
  18. * `customMiddleware` config option. *
  19. * *
  20. ****************************************************************************/
  21. middleware: {
  22. /***************************************************************************
  23. * *
  24. * The order in which middleware should be run for HTTP request. (the Sails *
  25. * router is invoked by the "router" middleware below.) *
  26. * *
  27. ***************************************************************************/
  28. order: [
  29. // 'startRequestTimer',
  30. // 'cookieParser',
  31. // 'session',
  32. // 'myRequestLogger',
  33. // 'bodyParser',
  34. // 'handleBodyParserError',
  35. // 'compress',
  36. // 'methodOverride',
  37. // 'poweredBy',
  38. 'disablePoweredBy',
  39. // '$custom',
  40. 'router'
  41. // 'www',
  42. // 'favicon',
  43. // '404',
  44. // '500'
  45. ],
  46. // Replacing the x-powered-by header with the expected
  47. // server header for TFB
  48. disablePoweredBy: function(req, res, next) {
  49. res.removeHeader("x-powered-by")
  50. res.set('Server', 'Sails <sailsjs.org>');
  51. next();
  52. },
  53. /****************************************************************************
  54. * *
  55. * Example custom middleware; logs each request to the console. *
  56. * *
  57. ****************************************************************************/
  58. // myRequestLogger: function (req, res, next) {
  59. // console.log("Requested :: ", req.method, req.url);
  60. // return next();
  61. // }
  62. /***************************************************************************
  63. * *
  64. * The body parser that will handle incoming multipart HTTP requests. By *
  65. * default as of v0.10, Sails uses *
  66. * [skipper](http://github.com/balderdashy/skipper). See *
  67. * http://www.senchalabs.org/connect/multipart.html for other options. *
  68. * *
  69. ***************************************************************************/
  70. // bodyParser: require('skipper')
  71. },
  72. /***************************************************************************
  73. * *
  74. * The number of seconds to cache flat files on disk being served by *
  75. * Express static middleware (by default, these files are in `.tmp/public`) *
  76. * *
  77. * The HTTP static cache is only active in a 'production' environment, *
  78. * since that's the only time Express will cache flat-files. *
  79. * *
  80. ***************************************************************************/
  81. // cache: 31557600000
  82. };