Skip to content
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

Redis client #97

Open
Wiz1991 opened this issue Feb 25, 2021 · 2 comments
Open

Redis client #97

Wiz1991 opened this issue Feb 25, 2021 · 2 comments

Comments

@Wiz1991
Copy link

Wiz1991 commented Feb 25, 2021

How would you wrap up redis and use it as a dependency? I created a loader for it and injected it but i have no type support or anything else?

@warapitiya
Copy link

Can you share an example code?

@dheeraj-rn
Copy link

Here is what I did with redis.

// redis.js 
const uitl = require('util');
const redis = require('redis');
const config = require('../config');

module.exports = () => {
  const client = redis.createClient(config.env.redis);
  client.get = uitl.promisify(client.get);
  return client;
};

// dependencyInjector.js
const { Container } = require('typedi');
const Redis = require('./redis');

module.exports = () => {

  Container.set('RedisClient', Redis());
};

You can find the whole code here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants