-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
this are me settings:
import { ConfigService } from '@nestjs/config';
import { ThrottlerStorageMongoService } from 'nestjs-throttler-storage-mongo';
import { getMongoConfigs } from './get-mongo.configs';
import { seconds } from '@nestjs/throttler';
export const configThrottlingWithMongoRec = (config: ConfigService) => {
const ttlInMilliseconds = seconds(config.get('THROTTLE_TTL')); // Convert ttl to milliseconds
const expireAt = new Date(Date.now() + ttlInMilliseconds); // Calculate expireAt based on current time
console.log('configThrottlingWithMongoRec', {
uri: getMongoConfigs(config).uri,
ttl: ttlInMilliseconds,
limit: +config.get('THROTTLE_LIMIT'),
expireAt,
});
return {
storage: new ThrottlerStorageMongoService(getMongoConfigs(config).uri),
throttlers: [
{
ttl: ttlInMilliseconds, // Use ttl in milliseconds for storage
limit: +config.get('THROTTLE_LIMIT'),
},
],
};
};
result of console.log:
configThrottlingWithMongoRec {
uri: 'mongodb+srv://admin:[email protected]/shoplist',
ttl: 5000,
limit: 5,
expireAt: 2024-05-08T12:47:01.051Z
}
this is what i receive in Mongo:
"_id": {
"$oid": "663b745957f26e53877db200"
},
"key": "064a679b470bf496d5d7da6efbe6bf56",
"expireAt": {
"$date": "2024-05-08T14:11:00.100Z"
},
"totalHits": 10
}```
expected to see expireAt in mongo same as in console.log
Metadata
Metadata
Assignees
Labels
No labels