# nestjs-throttler-storage-mongo

> Mongo storage provider for nestjs/throttler

Latest version **1.0.1-alpha** (published 2023-06-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install nestjs-throttler-storage-mongo
pnpm add nestjs-throttler-storage-mongo
yarn add nestjs-throttler-storage-mongo
bun add nestjs-throttler-storage-mongo
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1-alpha |
| Published | 2023-06-19 |
| First published | 2023-06-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 101.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Ganesha moorthy |
| Maintainers | ganesha2552 |
| Keywords | mongo, storage, nestjs-throttler, mongo-storage, express, fastify, ttl, nestjs, nest, throttler |

## Links

- npm: https://www.npmjs.com/package/nestjs-throttler-storage-mongo
- Repository: https://github.com/Ganesha2552/nestjs-throttler-storage-mongo
- Homepage: https://github.com/Ganesha2552/nestjs-throttler-storage-mongo#readme
- Issues: https://github.com/Ganesha2552/nestjs-throttler-storage-mongo/issues
- npm.io page: https://npm.io/package/nestjs-throttler-storage-mongo

## Dependencies (1)

- [mongodb](https://npm.io/package/mongodb.md) ^5.6.0

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [mongoose-typescript](https://npm.io/package/mongoose-typescript.md) — 85 weekly downloads

## Recent versions

- 1.0.1-alpha (latest) — 2023-06-19
- 1.0.1 — 2023-06-16
- 1.0.0 — 2023-06-16

## README

Mongo storage provider for the [@nestjs/throttler](https://github.com/nestjs/throttler) package.

    
![npm version](https://img.shields.io/npm/v/nestjs-throttler-storage-mongo?style=plastic)
![npm download](https://img.shields.io/npm/dm/nestjs-throttler-storage-mongo?style=plastic)

<a href="https://www.npmjs.com/nestjs-throttler-storage-mongo"><img src="https://img.shields.io/npm/l/nestjs-throttler-storage-mongo.svg" alt="Package License" /></a>
<a href="https://coveralls.io/github/Ganesha2552/nestjs-throttler-storage-mongo?branch=main"><img src="https://coveralls.io/repos/github/Ganesha2552/nestjs-throttler-storage-mongo/badge.svg?branch=main#5" alt="Coverage" /></a>

### MongoDB Storage Provider for @nestjs/throttler

This package provides a MongoDB TTL (Time-to-Live) storage provider for the [@nestjs/throttler](https://github.com/nestjs/throttler) package
. It allows you to store rate limiter data in a MongoDB collection with automatic expiration of entries using TTL indexes.

Installation
Install the package via npm:

```bash
npm install nestjs-throttler-storage-mongo
```

Yarn

```bash
yarn add nestjs-throttler-storage-mongo
```


## Usage
To start using NestJS MongoDB Storage Provider, you need to import the ThrottlerStorageMongoService
 into your application module and configure it with your Mongo connection url and MongoClientOptions.


```ts

import { ThrottlerModule } from '@nestjs/throttler';
import { ThrottlerStorageMongoService } from 'nestjs-throttler-storage-mongo';

@Module({
imports: [
ThrottlerModule.forRoot({
ttl: 60,
limit: 5,

      // Below are possible options on how to configure the storage service.

      // connection url
      storage: new ThrottlerStorageMongoService('mongodb://'),

      // MongoDB connection string with connection options
      storage: new ThrottlerStorageMongoService('mongodb://',{
        useNewUrlParser: true,
        useUnifiedTopology: true,
        // Other connection options
        }
      ),
    }),

],
})
export class AppModule {}

```


## Inject another config module and service:

```ts
import { ThrottlerModule } from '@nestjs/throttler';
import { ThrottlerStorageMongoService } from 'nestjs-throttler-storage-mongo';

@Module({
  imports: [
    ThrottlerModule.forRootAsync({
      imports: [ConfigModule],
      inject: [ConfigService],
      useFactory: (config: ConfigService) => ({
        ttl: config.get('THROTTLE_TTL'),
        limit: config.get('THROTTLE_LIMIT'),
        storage: new ThrottlerStorageMongoService('mongodb://'),
      }),
    }),
  ],
})
export class AppModule {}
```


## Issues

Bugs and features related to the mongo implementation are welcome in this repository.

## License

NestJS Throttler Mongo Storage is licensed under the MIT license.

---
_Source: https://npm.io/package/nestjs-throttler-storage-mongo · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
