2018-10-16 01:45:37 +00:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2018-10-24 03:33:04 +00:00
|
|
|
const rateLimit = require('express-rate-limit')
|
|
|
|
const rateLimiter = rateLimit({
|
|
|
|
windowMs: 10 * 60 * 1000, // 10 minutes
|
|
|
|
max: 100, // limit each IP to 100 requests per windowMs
|
|
|
|
skip (req, res) {
|
|
|
|
return !req.path.startsWith('/api')
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2018-10-16 01:45:37 +00:00
|
|
|
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.) *
|
|
|
|
* *
|
|
|
|
***************************************************************************/
|
|
|
|
|
2018-10-24 03:33:04 +00:00
|
|
|
order: [
|
|
|
|
'rateLimit',
|
|
|
|
'cookieParser',
|
|
|
|
'session',
|
|
|
|
'bodyParser',
|
|
|
|
'compress',
|
|
|
|
'poweredBy',
|
|
|
|
'router',
|
|
|
|
'www',
|
|
|
|
'favicon'
|
|
|
|
],
|
|
|
|
rateLimit: rateLimiter,
|
2018-10-16 01:45:37 +00:00
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
* *
|
|
|
|
* The body parser that will handle incoming multipart HTTP requests. *
|
|
|
|
* *
|
|
|
|
* https://sailsjs.com/config/http#?customizing-the-body-parser *
|
|
|
|
* *
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
// bodyParser: (function _configureBodyParser(){
|
|
|
|
// var skipper = require('skipper');
|
|
|
|
// var middlewareFn = skipper({ strict: true });
|
|
|
|
// return middlewareFn;
|
|
|
|
// })(),
|
2018-10-29 23:35:27 +00:00
|
|
|
}
|
|
|
|
}
|