Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return async context => {
let _namespace;
if (namespace) {
_namespace = namespace;
} else {
const user = context.params.user;
_namespace = user ? user[userIdKey] : 'default';
}
try {
await messageLimiter.consume(_namespace);
} catch (e) {
throw new errors.TooManyRequests(errorMessage || 'Too many requests', errorData);
}
return context;
};
};