Blame view
imports/modules/rate-limit.js
573 Bytes
0b8062427
|
1 2 3 |
import { Meteor } from 'meteor/meteor'; import { DDPRateLimiter } from 'meteor/ddp-rate-limiter'; import { _ } from 'meteor/underscore'; |
4c9b3dfc1
|
4 |
const fetchMethodNames = methods => _.pluck(methods, 'name'); |
0b8062427
|
5 6 7 8 9 10 11 12 13 14 15 |
const assignLimits = ({ methods, limit, timeRange }) => { const methodNames = fetchMethodNames(methods); if (Meteor.isServer) { DDPRateLimiter.addRule({ name(name) { return _.contains(methodNames, name); }, connectionId() { return true; }, }, limit, timeRange); } }; |
4c9b3dfc1
|
16 |
export default function rateLimit(options) { return assignLimits(options); } |