feat: add refresh token and global exception filter

This commit is contained in:
2026-05-09 09:00:25 +03:30
parent 06f659101d
commit 73f7af3146
32 changed files with 512 additions and 42 deletions
@@ -0,0 +1 @@
export const REDIS = 'REDIS_CLIENT';
@@ -0,0 +1,41 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-unsafe-call */
import { Inject, Injectable } from '@nestjs/common';
import { REDIS } from '../constants/redis.constants';
import Redis from 'ioredis';
@Injectable()
export class RedisService {
constructor(
/**
* Inject Redis
*/
@Inject(REDIS)
private readonly redis: Redis,
) {}
get client() {
return this.redis;
}
async set(key: string, val: string, ttl?: number) {
if (ttl) {
await this.redis.set(key, val, 'EX', ttl);
} else {
await this.redis.set(key, val);
}
}
async get(key: string) {
return await this.redis.get(key);
}
async del(key: string) {
return await this.redis.del(key);
}
async onModuleDestroy() {
await this.redis.quit();
}
}
+25
View File
@@ -0,0 +1,25 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-unsafe-call */
import { Module } from '@nestjs/common';
import { RedisService } from './providers/redis.service';
import { REDIS } from './constants/redis.constants';
import { ConfigService } from '@nestjs/config';
import Redis from 'ioredis';
@Module({
providers: [
{
provide: REDIS,
inject: [ConfigService],
useFactory: (configService: ConfigService) => {
return new Redis({
host: configService.get<string>('redis.host'),
port: configService.get<number>('redis.port'),
});
},
},
RedisService,
],
exports: [RedisService],
})
export class RedisModule {}