Skip to content

Commit

Permalink
style: lint files
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien-R44 committed Jul 15, 2023
1 parent 0dc04d2 commit 9276f82
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 45 deletions.
9 changes: 6 additions & 3 deletions src/abstract_connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ export abstract class AbstractConnection<T extends Redis | Cluster> extends Even
*/
protected abstract makeSubscriberConnection(): void

constructor(public connectionName: string, application: ApplicationService) {
constructor(
public connectionName: string,
application: ApplicationService
) {
super()
}

Expand Down Expand Up @@ -177,11 +180,11 @@ export abstract class AbstractConnection<T extends Redis | Cluster> extends Even
this.ioSubscriberConnection!.on('connect', () => this.emit('subscriber:connect', this))
this.ioSubscriberConnection!.on('ready', () => this.emit('subscriber:ready', this))
this.ioSubscriberConnection!.on('error', (error: any) =>
this.emit('subscriber:error', error, this),
this.emit('subscriber:error', error, this)
)
this.ioSubscriberConnection!.on('close', () => this.emit('subscriber:close', this))
this.ioSubscriberConnection!.on('reconnecting', () =>
this.emit('subscriber:reconnecting', this),
this.emit('subscriber:reconnecting', this)
)

/**
Expand Down
4 changes: 2 additions & 2 deletions src/define_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type RedisConfig = {
* Define config for redis
*/
export function defineConfig<T extends RedisConfig & { connection: keyof T['connections'] }>(
config: T,
config: T
): T {
if (!config) {
throw new InvalidArgumentsException('Invalid config. It must be a valid object')
Expand All @@ -36,7 +36,7 @@ export function defineConfig<T extends RedisConfig & { connection: keyof T['conn

if (!config.connection || !config.connections[config.connection as any]) {
throw new InvalidArgumentsException(
'Invalid config. Missing property "connection" or the connection name is not defined inside "connections" object',
'Invalid config. Missing property "connection" or the connection name is not defined inside "connections" object'
)
}

Expand Down
2 changes: 1 addition & 1 deletion src/redis_cluster_connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class RawRedisClusterConnection extends AbstractConnection<Cluster> {
protected makeSubscriberConnection() {
this.ioSubscriberConnection = new Redis.Cluster(
this.#config.clusters as [],
this.#config.clusterOptions,
this.#config.clusterOptions
)
}

Expand Down
2 changes: 1 addition & 1 deletion src/redis_connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class RawRedisConnection extends AbstractConnection<Redis> {
constructor(
connectionName: string,
config: RedisConnectionConfig,
application: ApplicationService,
application: ApplicationService
) {
super(connectionName, application)
this.#config = this.#normalizeConfig(config)
Expand Down
20 changes: 10 additions & 10 deletions src/redis_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ export class RawRedisManager<ConnectionList extends RedisConnectionsList> {
connection: keyof ConnectionList
connections: ConnectionList
},
emitter: EmitterService,
emitter: EmitterService
) {
this.#app = app
this.#config = config
this.#emitter = emitter
this.#healthCheckConnections = Object.keys(this.#config.connections).filter(
(connection) => this.#config.connections[connection].healthCheck,
(connection) => this.#config.connections[connection].healthCheck
)
}

Expand Down Expand Up @@ -107,22 +107,22 @@ export class RawRedisManager<ConnectionList extends RedisConnectionsList> {
this.#emitter.emit('redis:ready', { connection })
})
connection.on('ready', ($connection) =>
this.#emitter.emit('redis:ready', { connection: $connection }),
this.#emitter.emit('redis:ready', { connection: $connection })
)
connection.on('connect', ($connection) =>
this.#emitter.emit('redis:connect', { connection: $connection }),
this.#emitter.emit('redis:connect', { connection: $connection })
)
connection.on('error', (error, $connection) =>
this.#emitter.emit('redis:error', { error, connection: $connection }),
this.#emitter.emit('redis:error', { error, connection: $connection })
)
connection.on('node:added', ($connection, node) =>
this.#emitter.emit('redis:node:added', { node, connection: $connection }),
this.#emitter.emit('redis:node:added', { node, connection: $connection })
)
connection.on('node:removed', (node, $connection) =>
this.#emitter.emit('redis:node:removed', { node, connection: $connection }),
this.#emitter.emit('redis:node:removed', { node, connection: $connection })
)
connection.on('node:error', (error, address, $connection) =>
this.#emitter.emit('redis:node:error', { error, address, connection: $connection }),
this.#emitter.emit('redis:node:error', { error, address, connection: $connection })
)

/**
Expand All @@ -138,7 +138,7 @@ export class RawRedisManager<ConnectionList extends RedisConnectionsList> {
* Returns redis factory for a given named connection
*/
connection<ConnectionName extends keyof ConnectionList>(
connectionName?: ConnectionName,
connectionName?: ConnectionName
): GetConnectionType<ConnectionList, ConnectionName> {
const name = connectionName || this.#getDefaultConnection()

Expand Down Expand Up @@ -223,7 +223,7 @@ export class RawRedisManager<ConnectionList extends RedisConnectionsList> {
*/
async report() {
const reports = await Promise.all(
this.#healthCheckConnections.map((connection) => this.connection(connection).getReport(true)),
this.#healthCheckConnections.map((connection) => this.connection(connection).getReport(true))
)

const healthy = !reports.find((report) => !!report.error)
Expand Down
6 changes: 3 additions & 3 deletions src/repl_bindings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ export function defineReplBindings(app: ApplicationService, repl: Repl) {
repl.server!.context.redis = await app.container.make('redis')
repl.notify(
`Loaded "redis" service. You can access it using the "${repl.colors.underline(
'redis',
)}" variable`,
'redis'
)}" variable`
)
},
{ description: 'Load "redis" service in the REPL context' },
{ description: 'Load "redis" service in the REPL context' }
)
}
10 changes: 5 additions & 5 deletions src/types/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { RawRedisManager } from '../redis_manager.js'
export type PubSubChannelHandler<T extends any = string> = (data: T) => Promise<void> | void
export type PubSubPatternHandler<T extends any = string> = (
channel: string,
data: T,
data: T
) => Promise<void> | void

/**
Expand All @@ -45,7 +45,7 @@ export interface RedisPubSubContract {
publish(
channel: string,
message: string,
callback: (error: Error | null, count: number) => void,
callback: (error: Error | null, count: number) => void
): void
publish(channel: string, message: string): Promise<number>
subscribe(channel: string, handler: PubSubChannelHandler | string): void
Expand Down Expand Up @@ -121,15 +121,15 @@ export type RedisClusterConnectionFactory = {
new (
connectionName: string,
config: RedisClusterConfig,
application: ApplicationService,
application: ApplicationService
): RawRedisClusterConnection & AbstractConnection<Cluster> & IORedisCommands & RedisPubSubContract
}

export type RedisConnectionFactory = {
new (
connectionName: string,
config: RedisConnectionConfig,
application: ApplicationService,
application: ApplicationService
): RawRedisConnection & AbstractConnection<IoRedis> & IORedisCommands & RedisPubSubContract
}

Expand All @@ -140,7 +140,7 @@ export type RedisManagerFactory = {
connection: keyof ConnectionList
connections: ConnectionList
},
emitter: Emitter<any>,
emitter: Emitter<any>
): RawRedisManager<ConnectionList> & IORedisCommands & RedisPubSubContract
}

Expand Down
4 changes: 2 additions & 2 deletions test/define_config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ test.group('Define Config', () => {
assert.throws(
// @ts-ignore
() => defineConfig({ connection: 'hey' }),
'Invalid config. Missing property "connections" inside it',
'Invalid config. Missing property "connections" inside it'
)
})

Expand All @@ -32,7 +32,7 @@ test.group('Define Config', () => {
connection: 'hey',
connections: {},
}),
'Invalid config. Missing property "connection" or the connection name is not defined inside "connections" object',
'Invalid config. Missing property "connection" or the connection name is not defined inside "connections" object'
)
})
})
20 changes: 10 additions & 10 deletions test/redis_cluster_connection.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ test.group('Redis cluster factory', () => {
const factory = new RedisClusterConnection(
'main',
{ clusters: nodes },
new AppFactory().create(BASE_URL, () => {}),
new AppFactory().create(BASE_URL, () => {})
)

factory.on('ready', async () => {
Expand All @@ -35,7 +35,7 @@ test.group('Redis cluster factory', () => {
const factory = new RedisClusterConnection(
'main',
{ clusters: [{ host: process.env.REDIS_HOST!!, port: 7000 }] },
new AppFactory().create(BASE_URL, () => {}),
new AppFactory().create(BASE_URL, () => {})
)

factory.on('node:added', async () => {
Expand All @@ -49,7 +49,7 @@ test.group('Redis cluster factory', () => {
const factory = new RedisClusterConnection(
'main',
{ clusters: nodes },
new AppFactory().create(BASE_URL, () => {}),
new AppFactory().create(BASE_URL, () => {})
)

await factory.set('greeting', 'hello world')
Expand All @@ -66,7 +66,7 @@ test.group('Redis cluster factory', () => {
const factory = new RedisClusterConnection(
'main',
{ clusters: nodes },
new AppFactory().create(BASE_URL, () => {}),
new AppFactory().create(BASE_URL, () => {})
)

factory.on('end', () => {
Expand All @@ -88,7 +88,7 @@ test.group('Redis cluster factory', () => {
{
clusters: nodes,
},
new AppFactory().create(BASE_URL, () => {}),
new AppFactory().create(BASE_URL, () => {})
)

factory.on('end', () => {
Expand All @@ -108,7 +108,7 @@ test.group('Redis cluster factory', () => {
const factory = new RedisClusterConnection(
'main',
{ clusters: [{ host: process.env.REDIS_HOST!, port: 5000 }] },
new AppFactory().create(BASE_URL, () => {}),
new AppFactory().create(BASE_URL, () => {})
)

factory.on('end', () => {
Expand All @@ -133,7 +133,7 @@ test.group('Redis cluster factory', () => {
const factory = new RedisClusterConnection(
'main',
{ clusters: nodes },
new AppFactory().create(BASE_URL, () => {}),
new AppFactory().create(BASE_URL, () => {})
)

factory.on('end', () => {
Expand All @@ -154,7 +154,7 @@ test.group('Redis cluster factory', () => {
const factory = new RedisClusterConnection(
'main',
{ clusters: nodes },
new AppFactory().create(BASE_URL, () => {}),
new AppFactory().create(BASE_URL, () => {})
)

factory.on('end', () => {
Expand All @@ -180,7 +180,7 @@ test.group('Redis cluster factory', () => {
const factory = new RedisClusterConnection(
'main',
{ clusters: [{ host: process.env.REDIS_HOST!, port: 5000 }] },
new AppFactory().create(BASE_URL, () => {}),
new AppFactory().create(BASE_URL, () => {})
)

factory.on('end', () => {
Expand All @@ -203,7 +203,7 @@ test.group('Redis cluster factory', () => {
const factory = new RedisClusterConnection(
'main',
{ clusters: nodes },
new AppFactory().create(BASE_URL, () => {}),
new AppFactory().create(BASE_URL, () => {})
)

factory.defineCommand('defineValue', {
Expand Down
16 changes: 8 additions & 8 deletions test/redis_connection.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test.group('Redis factory', () => {
host: process.env.REDIS_HOST,
port: Number(process.env.REDIS_PORT),
},
new AppFactory().create(BASE_URL, () => {}),
new AppFactory().create(BASE_URL, () => {})
)

factory.on('ready', async () => {
Expand All @@ -28,7 +28,7 @@ test.group('Redis factory', () => {
host: process.env.REDIS_HOST,
port: Number(process.env.REDIS_PORT),
},
new AppFactory().create(BASE_URL, () => {}),
new AppFactory().create(BASE_URL, () => {})
)

await factory.set('greeting', 'hello world')
Expand All @@ -47,7 +47,7 @@ test.group('Redis factory', () => {
host: process.env.REDIS_HOST,
port: Number(process.env.REDIS_PORT),
},
new AppFactory().create(BASE_URL, () => {}),
new AppFactory().create(BASE_URL, () => {})
)

factory.on('end', () => {
Expand All @@ -68,7 +68,7 @@ test.group('Redis factory', () => {
host: process.env.REDIS_HOST,
port: Number(process.env.REDIS_PORT),
},
new AppFactory().create(BASE_URL, () => {}),
new AppFactory().create(BASE_URL, () => {})
)

factory.on('end', () => {
Expand All @@ -86,7 +86,7 @@ test.group('Redis factory', () => {
const factory = new RedisConnection(
'main',
{ port: 4444 },
new AppFactory().create(BASE_URL, () => {}),
new AppFactory().create(BASE_URL, () => {})
)

factory.on('end', () => {
Expand All @@ -111,7 +111,7 @@ test.group('Redis factory', () => {
host: process.env.REDIS_HOST,
port: Number(process.env.REDIS_PORT),
},
new AppFactory().create(BASE_URL, () => {}),
new AppFactory().create(BASE_URL, () => {})
)

factory.on('end', () => {
Expand Down Expand Up @@ -140,7 +140,7 @@ test.group('Redis factory', () => {
host: process.env.REDIS_HOST,
port: 4444,
},
new AppFactory().create(BASE_URL, () => {}),
new AppFactory().create(BASE_URL, () => {})
)

factory.on('end', () => {
Expand All @@ -167,7 +167,7 @@ test.group('Redis factory', () => {
host: process.env.REDIS_HOST,
port: Number(process.env.REDIS_PORT),
},
new AppFactory().create(BASE_URL, () => {}),
new AppFactory().create(BASE_URL, () => {})
)

factory.defineCommand('defineValue', {
Expand Down

0 comments on commit 9276f82

Please sign in to comment.