mirror of
https://github.com/hanzoai/calendar.git
synced 2026-10-30 14:46:43 +00:00
* refactor: pass redis storage to throttler guard * chore: upgrade throttler to latest * feat: ApiKey RateLimit table * chore: upgrade redis storage throttler * feat: rate limit by api key * refactor: on delete api key cascade rate limit * fix: permissions guard work with oauth credentials * chore: set rate limit in env * tests: throttler * feat: include rate limit name in response * fix: correctly handle multiple rate limits * chore: remove unused import * delete migrations * chore: prisma migration * doc * dummy * fix: permissions guard unit test * refactor: remove route specific @Throttles * fix: permissions guard
23 lines
615 B
TypeScript
23 lines
615 B
TypeScript
import { PrismaWriteService } from "@/modules/prisma/prisma-write.service";
|
|
import { TestingModule } from "@nestjs/testing";
|
|
|
|
export class RateLimitRepositoryFixture {
|
|
private dbWrite: PrismaWriteService["prisma"];
|
|
|
|
constructor(private readonly module: TestingModule) {
|
|
this.dbWrite = module.get(PrismaWriteService).prisma;
|
|
}
|
|
|
|
async createRateLimit(name: string, apiKeyId: string, ttl: number, limit: number, blockDuration: number) {
|
|
return await this.dbWrite.rateLimit.create({
|
|
data: {
|
|
name,
|
|
apiKeyId,
|
|
ttl,
|
|
limit,
|
|
blockDuration,
|
|
},
|
|
});
|
|
}
|
|
}
|