UNPKG

create-chuntianxiaozhu

Version:

春天小猪模板工具

15 lines (13 loc) 497 B
import { Injectable } from '@nestjs/common'; import { ThrottlerGuard } from '@nestjs/throttler'; import { Request } from 'express'; @Injectable() export class ThrottlerProxyGuard extends ThrottlerGuard { protected getTracker(req: Request): string { const csrfToken = req.cookies._csrf != null ? req.cookies._csrf : ''; const uuid = req.headers['uuid'] || ''; const user = req['user'] || {}; const sub = user.sub != null ? user.sub : ''; return csrfToken + sub + uuid; } }