Skip to content

Commit

Permalink
style: 코드 스타일 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
son-daehyeon committed Sep 14, 2024
1 parent 00e0d3a commit 63d587f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
20 changes: 15 additions & 5 deletions src/common/database/redis/service/redis.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ export class RedisService {
}

async exists(key: string): Promise<boolean> {
if (!this.group) throw new Error('Group is not set');
if (!this.group) {
throw new Error('Group is not set');
}

const _key = this.#generateKey(key);

Expand All @@ -37,15 +39,19 @@ export class RedisService {
}

async get(key: string): Promise<string> {
if (!this.group) throw new Error('Group is not set');
if (!this.group) {
throw new Error('Group is not set');
}

const _key = this.#generateKey(key);

return (await this.redisClient.get(_key)) || '';
}

async set(key: string, value: string, seconds: number = 0): Promise<void> {
if (!this.group) throw new Error('Group is not set');
if (!this.group) {
throw new Error('Group is not set');
}

const _key = this.#generateKey(key);

Expand All @@ -63,7 +69,9 @@ export class RedisService {
}

async delete(key: string): Promise<void> {
if (!this.group) throw new Error('Group is not set');
if (!this.group) {
throw new Error('Group is not set');
}

const _key = this.#generateKey(key);

Expand All @@ -73,7 +81,9 @@ export class RedisService {
}

#generateKey(key: string): string {
if (!this.group) throw new Error('Group is not set');
if (!this.group) {
throw new Error('Group is not set');
}

return `${this.group}:${key}`;
}
Expand Down
16 changes: 12 additions & 4 deletions src/common/s3/service/s3.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ export class S3Service {
}

async upload(file: Express.Multer.File): Promise<string> {
if (!this.directory) throw new Error('Directory is not set');
if (!this.directory) {
throw new Error('Directory is not set');
}

let _key = `${this.directory}/${uuid()}${extname(file.originalname)}`;
_key = _key.replace(/ /g, '_');
Expand All @@ -56,7 +58,9 @@ export class S3Service {
}

async delete(key: string): Promise<void> {
if (!this.directory) throw new Error('Directory is not set');
if (!this.directory) {
throw new Error('Directory is not set');
}

const _key = `${this.directory}/${key}`;

Expand All @@ -71,7 +75,9 @@ export class S3Service {
}

async getKeys(): Promise<string[]> {
if (!this.directory) throw new Error('Directory is not set');
if (!this.directory) {
throw new Error('Directory is not set');
}

const result = await this.s3Client.send(
new ListObjectsV2Command({
Expand All @@ -87,7 +93,9 @@ export class S3Service {
}

extractKeyFromUrl(url: string): string {
if (!this.directory) throw new Error('Directory is not set');
if (!this.directory) {
throw new Error('Directory is not set');
}

return url.split(`.com/`)[1].substring(this.directory.length + 1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const Length = (length: number) => (object: NonNullable<unknown>, propert
validate: (value: unknown, args: ValidationArguments) => {
const [length] = args.constraints;

return typeof value === 'string' && value.length == length;
return typeof value === 'string' && value.length === length;
},
},
});
Expand Down

0 comments on commit 63d587f

Please sign in to comment.