New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make global module as an option #175
Comments
I can submit a PR if you want me to (not with the above patch but exposing |
@lhr0909 thanks for opening the issue! |
please follow the steps below:
npm install --save @liaoliaots/nestjs-redis@6
// shared-redis.module.ts
import { Module } from '@nestjs/common';
import { RedisModule } from '@liaoliaots/nestjs-redis';
@Module({
imports: [
RedisModule.forRoot(
{
readyLog: true,
config: {
host: '127.0.0.1',
port: 6380,
password: 'bitnami'
}
},
false // <--- make the module non global
)
],
exports: [RedisModule] // <--- important: share this module
})
export class SharedRedis {}
// cats.module.ts
import { Module } from '@nestjs/common';
import { CatsService } from './cats.service';
import { CatsController } from './cats.controller';
import { SharedRedis } from '../shared-redis.module';
@Module({
imports: [SharedRedis], // <---
providers: [CatsService],
controllers: [CatsController]
})
export class CatsModule {}
npm run start:dev |
好的!这两天我会整合测试一下。感谢🙏 |
Does it work for you? I've got error as below:
Everything looks fine in the module's configuration. |
@AvantaR I upgraded on my end and it worked as expected (I didn't do the shared module trick though). Curious why this happens. Maybe @liaoliaots can help 😄 |
Ok, it was not related to this module, but to the circular imports in my code. Thanks. |
@AvantaR It may be useful for you to import files in the correct order: As mentioned above, decorator If import - - OR - - |
Hi! 👋
Firstly, thanks for your work on this project! 🙂
I would like to set up the redis module in a non-global way, so is there a chance we can make it configurable? Thanks!
Here is the diff that solved my problem:
This issue body was partially generated by patch-package.
The text was updated successfully, but these errors were encountered: