redis-repository-plugin
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

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)
})

Readme

Keywords

none

Package Sidebar

Install

npm i redis-repository-plugin

Weekly Downloads

0

Version

1.0.2

License

MIT

Unpacked Size

2.51 kB

Total Files

4

Last publish

Collaborators

  • rnsantos