Skip to content

Commit

Permalink
lint project sources
Browse files Browse the repository at this point in the history
  • Loading branch information
iamolegga committed Nov 13, 2019
1 parent a92484c commit f3863e8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
6 changes: 3 additions & 3 deletions lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from './redis.service'
export * from './redis.module'
export * from './redis.interface'
export * from './redis.service';
export * from './redis.module';
export * from './redis.interface';
4 changes: 2 additions & 2 deletions lib/redis.constants.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const REDIS_MODULE_OPTIONS = Symbol('REDIS_MODULE_OPTIONS')
export const REDIS_CLIENT = Symbol('REDIS_CLIENT')
export const REDIS_MODULE_OPTIONS = Symbol('REDIS_MODULE_OPTIONS');
export const REDIS_CLIENT = Symbol('REDIS_CLIENT');
8 changes: 5 additions & 3 deletions lib/redis.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import { ModuleMetadata } from '@nestjs/common/interfaces';
import { RedisOptions } from 'ioredis';

export interface RedisModuleOptions extends RedisOptions {
name?: string
url?: string
name?: string;
url?: string;
}

export interface RedisModuleAsyncOptions
extends Pick<ModuleMetadata, 'imports'> {
useFactory?: (...args: any[]) =>
useFactory?: (
...args: any[]
) =>
| RedisModuleOptions
| RedisModuleOptions[]
| Promise<RedisModuleOptions>
Expand Down
20 changes: 10 additions & 10 deletions lib/redis.service.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import { Injectable, Inject } from "@nestjs/common";
import { Injectable, Inject } from '@nestjs/common';
import { REDIS_CLIENT } from './redis.constants';
import * as Redis from "ioredis";
import { RedisClient, RedisClientError } from "./redis-client.provider";
import * as Redis from 'ioredis';
import { RedisClient, RedisClientError } from './redis-client.provider';

@Injectable()
export class RedisService {
constructor(
@Inject(REDIS_CLIENT) private readonly redisClient: RedisClient
) { }
@Inject(REDIS_CLIENT) private readonly redisClient: RedisClient,
) {}

getClient(name?: string): Redis.Redis {
if (!name) {
name = this.redisClient.defaultKey
}
name = this.redisClient.defaultKey;
}
if (!this.redisClient.clients.has(name)) {
throw new RedisClientError(`client ${name} is not exists`)
throw new RedisClientError(`client ${name} is not exists`);
}
return this.redisClient.clients.get(name)
return this.redisClient.clients.get(name);
}

getClients(): Map<string, Redis.Redis> {
return this.redisClient.clients;
}
Expand Down

0 comments on commit f3863e8

Please sign in to comment.