-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
This reverts commit 79f88a4.
- Loading branch information
1 parent
119a2a3
commit 1571d13
Showing
3 changed files
with
104 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './redis.module'; | ||
export * from './interface/redis.constants'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { Configuration } from '@hpi-schul-cloud/commons/lib'; | ||
import { Module } from '@nestjs/common'; | ||
import { LegacyLogger, LoggerModule } from '@src/core/logger'; | ||
import { createClient, RedisClientType } from 'redis'; | ||
import { REDIS_CLIENT } from './interface/redis.constants'; | ||
|
||
@Module({ | ||
imports: [LoggerModule], | ||
providers: [ | ||
{ | ||
provide: REDIS_CLIENT, | ||
useFactory: (logger: LegacyLogger) => { | ||
logger.setContext(RedisModule.name); | ||
|
||
if (Configuration.has('REDIS_URI')) { | ||
const redisUrl: string = Configuration.get('REDIS_URI') as string; | ||
const client: RedisClientType = createClient({ url: redisUrl }); | ||
|
||
client.on('error', (error) => logger.error(error)); | ||
client.on('connect', (msg) => logger.log(msg)); | ||
|
||
return client; | ||
} | ||
|
||
return undefined; | ||
}, | ||
inject: [LegacyLogger], | ||
}, | ||
], | ||
exports: [REDIS_CLIENT], | ||
}) | ||
export class RedisModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters