1.0.2 • Published 5 years ago

redis-repository-plugin v1.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

Redis Repository Plugin

Redis plugin for create-graphql-express

Instalation

npm install --save redis-repository-plugin

Configuration

Create file redis-repository.ts inside repositories folder.

import { RedisRepository } from 'redis-repository-plugin'

export default RedisRepository()

Include redis in repositories.d.ts (it has to be the same name as the file created above without -repository)

import { RedisRepositor } from 'redis-repository-plugin'

export interface Repositories {
  redis: RedisRepositor;
}

Set environment variables in .env.dev eg.:

REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=optional

Tests configuration

Repositories must be cleared after each test and closed after all tests.

edit tests/config/jest.setup.ts

import { app, repositories } from 'graphql-api-scripts'
import { Server } from 'http'
import { Repositories } from '../../src/repositories/repositories'

let instance: Server

const { redis }: Repositories = repositories

beforeAll(done => {
  instance = app.listen()
  done()
})

afterEach(async done => {
  redis._clear()
  done()
})

afterAll(async done => {
  redis._disconnect()
  instance.close(done)
})