Overview
SvelteKit Rate Limiter is a modular rate limiter designed for password resets, account registration, and similar functionalities. It can be easily integrated into your SvelteKit project by using the provided modules in your page.server.ts files or hooks.server.ts. The rate limiter utilizes an in-memory cache using @isaacs/ttlcache, but can also be swapped out for alternative caching solutions. The source file includes interfaces for both the cache and limiters, allowing for easy customization.
Features
- Modular rate limiter for password resets, account registration, etc.
- Use in
page.server.tsfiles orhooks.server.ts - Supports in-memory cache using
@isaacs/ttlcache - Customizable limiters through plugins
Installation
To install SvelteKit Rate Limiter, follow these steps:
- Install the package using npm:
npm install sveltekit-rate-limiter
- Import the necessary modules into your SvelteKit project:
import { RateLimiter, RateLimiterStore, RetryAfterRateLimiter } from 'sveltekit-rate-limiter';
- Begin using the rate limiter in your code.
Summary
SvelteKit Rate Limiter is a versatile tool for implementing rate limiting functionality in SvelteKit projects. With its modular design and support for customizable limiters, it provides developers with the flexibility and control they need to protect sensitive actions such as password resets and account registration. By utilizing an in-memory cache and providing interfaces for cache and limiters, SvelteKit Rate Limiter allows for easy integration and customization.