import { Plugin as GenzyRedisPlugin, RedisService } from "genzy-redis-plugin";
class TestService {
private redisService: RedisService;
constructor({ redisService }: { redisService: RedisService }) {
this.redisService = redisService;
}
async check(key: string) {
const fromCache = await this.redisService.get(key);
if (!fromCache) {
throw new Error("Key not found.");
}
}
}
const controllers = new GenzyContainer();
const services = new GenzyContainer().addLocalService(TestService);
const app = new GenzyApi()
.addPlugin(new GenzyRedisPlugin({ containers: [services] }))
.buildAppFrom(controllers);