DTP Base provides a scalable and secure Node.js application development harness ready for production service.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

229 lines
5.2 KiB

// limiter.js
// Copyright (C) 2024 DTP Technologies, LLC
// All Rights Reserved
'use strict';
const ONE_SECOND = 1000;
const ONE_MINUTE = ONE_SECOND * 60;
const ONE_HOUR = ONE_MINUTE * 60;
const ONE_DAY = ONE_HOUR * 24;
export default {
/*
* AuthController
*/
auth: {
postOtpEnable: {
total: 5,
expire: ONE_MINUTE * 30,
message: 'You are enabling One-Time Passwords too quickly. Please try again later',
},
postOtpAuthenticate: {
total: 5,
expire: ONE_MINUTE,
message: 'You are trying One-Time Passwords too quickly. Please try again later',
},
postForgotPassword: {
total: 5,
expire: ONE_DAY,
message: 'Password reset has been locked for one day. Please try again later.',
},
postPasswordReset: {
total: 3,
expire: ONE_DAY,
message: 'Password reset has been locked for one day. Please try again later.',
},
postLogin: {
total: 5,
expire: ONE_MINUTE,
message: 'You are logging in too quickly',
},
getPersonalApiToken: {
total: 20,
expire: ONE_MINUTE,
message: 'You are requesting tokens too quickly',
},
getSocketToken: {
total: 20,
expire: ONE_MINUTE,
message: 'You are requesting tokens too quickly',
},
getForgotPasswordForm: {
total: 3,
expire: ONE_HOUR,
message: 'Password reset has been locked for one day. Please try again later.',
},
getResetPasswordForm: {
total: 5,
expire: ONE_DAY,
message: 'Password reset has been locked for one day. Please try again later.',
},
getLogout: {
total: 10,
expire: ONE_MINUTE,
message: 'You are logging out too quickly',
},
},
/*
* EmailController
*/
email: {
postEmailVerify: {
total: 10,
expire: ONE_HOUR,
message: "You are posting email verifications too quickly",
},
getEmailOptOut: {
total: 10,
expire: ONE_HOUR,
message: "You are opting out too quickly",
},
getEmailVerify: {
total: 10,
expire: ONE_HOUR,
message: "You are requesting the email verification form too quickly",
},
},
/*
* HomeController
*/
home: {
getHome: {
total: 20,
expire: ONE_MINUTE,
message: 'You are loading the home page too quickly',
}
},
/*
* ImageController
*/
image: {
postCreateImage: {
total: 5,
expire: ONE_MINUTE,
message: 'You are uploading images too quickly',
},
getProxyImage: {
total: 50,
expire: ONE_SECOND * 6,
message: 'You are requesting proxy images too quickly',
},
getImage: {
total: 500,
expire: ONE_SECOND * 10,
message: 'You are requesting images too quickly',
},
deleteImage: {
total: 60,
expire: ONE_MINUTE,
message: 'You are deleting images too quickly',
},
},
/*
* ManifestController
*/
manifest: {
getManifest: {
total: 60,
expire: ONE_MINUTE,
message: 'You are fetching application manifests too quickly',
}
},
/*
* UserController
*/
user: {
postCreateUser: {
total: 4,
expire: ONE_HOUR * 4,
message: 'You are creating accounts too quickly',
},
postProfilePhoto: {
total: 5,
expire: ONE_MINUTE * 5,
message: 'You are updating your profile photo too quickly',
},
postUpdateSettings: {
total: 12,
expire: ONE_MINUTE,
message: 'You are updating account settings too quickly',
},
postBlockUser: {
total: 10,
expire: ONE_HOUR,
message: 'You are blocking people too quickly',
},
getResendWelcomeEmail: {
total: 3,
expire: ONE_HOUR,
message: 'You are sending welcome emails too often',
},
getOtpSetup: {
total: 10,
expire: ONE_MINUTE,
message: 'You are configuring two-factor authentication too quickly',
},
getOtpDisable: {
total: 10,
expire: ONE_MINUTE,
message: 'You are disabling two-factor authentication too quickly',
},
getStripeCustomerPortal: {
total: 4,
expire: ONE_MINUTE,
message: 'You are accessing the Stripe Customer Portal too quickly',
},
getSettings: {
total: 8,
expire: ONE_MINUTE,
message: 'You are requesting user settings too quickly',
},
getBlockView: {
total: 10,
expire: ONE_MINUTE,
message: 'You are loading your block list too quickly',
},
getUserProfile: {
total: 12,
expire: ONE_MINUTE,
message: 'You are requesting user profiles too quickly',
},
deleteProfilePhoto: {
total: 5,
expire: ONE_MINUTE * 5,
message: 'You are deleting your profile photo too quickly',
},
deleteBlockedUser: {
total: 30,
expire: ONE_HOUR,
message: 'You are un-blocking people too quickly',
},
},
/*
* VideoController
*/
video: {
getVideoMedia: {
total: 60,
expire: ONE_HOUR,
message: 'You are loading videos too quickly',
},
},
/*
* WelcomeController
*/
welcome: {
total: 12,
expire: ONE_MINUTE,
message: 'You are loading these pages too quickly',
},
};