feat: add refresh token and global exception filter
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user