Reputation: 309
I want to use one of the ExpressJS middleware in SailsJS application. Its the "express-limiter" module(which is a express middleware) for rate limiting an api using IP address. Normally in express we do:
app.use(limiter({ some parameters }))
How to I use this middleware or any other express middleware in SailsJS application? Appreciate your help.
Upvotes: 4
Views: 1095
Reputation: 204
install the middleware npm install --save express-limiter
change the config/http.js
file adding the express-limiter
middleware: {
order: [
'express-limiter-key'
],
'express-limiter-key' = require('express-limiter')
}
the
var limiter = require('limiter')
won't work since >middleware.order
is simply a lookup, and will search only keywords inmiddleware
object.
Upvotes: 2
Reputation: 13644
npm install --save yourMiddleware
sails.config.http.middleware
limiter
in the order
, I suppose close to the top.Upvotes: 1