How to use the TooManyRequests function from http-errors
Find comprehensive JavaScript http-errors.TooManyRequests code examples handpicked from public code repositorys.
119 120 121 122 123 124 125 126 127 128
preconditionRequired: function preconditionRequired (message) { return new createError.PreconditionRequired(message) }, tooManyRequests: function tooManyRequests (message) { return new createError.TooManyRequests(message) }, requestHeaderFieldsTooLarge: function requestHeaderFieldsTooLarge (message) { return new createError.RequestHeaderFieldsTooLarge(message)
30
340
17
+ 55 other calls in file
60 61 62 63 64 65 66 67 68
if ( differenceInSeconds(new Date(), new Date(lastRequest)) < options.metrics[event] ) { throw new TooManyRequests() } await server.pg.write.query(metricsInsert({ event, os, version }))
21
1
2
166 167 168 169 170 171 172 173 174 175
module.exports.Locked = new HTTPErrors.Locked() module.exports.FailedDependency = new HTTPErrors.FailedDependency() module.exports.UnorderedCollection = new HTTPErrors.UnorderedCollection() module.exports.UpgradeRequired = new HTTPErrors.UpgradeRequired() module.exports.PreconditionRequired = new HTTPErrors.PreconditionRequired() module.exports.TooManyRequests = new HTTPErrors.TooManyRequests() module.exports.RequestHeaderFieldsTooLarge = new HTTPErrors.RequestHeaderFieldsTooLarge() module.exports.UnavailableForLegalReasons = new HTTPErrors.UnavailableForLegalReasons() module.exports.InternalServerError = new HTTPErrors.InternalServerError() module.exports.NotImplemented = new HTTPErrors.NotImplemented()
1
0
7
+ 41 other calls in file
GitHub: fega/mongo-server
56 57 58 59 60 61 62 63 64 65
*/ const email = (req.body[conf.emailField] || '').toLowerCase(); if (!email) throw new HttpError.BadRequest('Missing Email'); if (!isEmail(email)) throw new HttpError.BadRequest('Invalid Email'); const tokens = await MagicTokens.find({ email, exp: { $gte: new Date() } }).toArray(); if (tokens.length >= conf.max) throw new HttpError.TooManyRequests('Token limit reached'); /** * Handle custom logic */
5
25
3
149 150 151 152 153 154 155 156 157 158
case 426: { httpError = createError.UpgradeRequired(); break; } case 429: { httpError = createError.TooManyRequests(); break; } case 431: { httpError = createError.RequestHeaderFieldsTooLarge();
0
0
2
+ 41 other calls in file
http-errors.NotFound is the most popular function in http-errors (1819 examples)