-
Notifications
You must be signed in to change notification settings - Fork 3
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
Use in-memory token store when developing locally #273
Conversation
Removes the need for a local Redis container
server/data/index.ts
Outdated
|
||
type RestClientBuilder<T> = (token: string) => T | ||
|
||
export const dataAccess = () => ({ | ||
applicationInfo, | ||
hmppsAuthClient: new HmppsAuthClient(new TokenStore(createRedisClient())), | ||
hmppsAuthClient: new HmppsAuthClient( | ||
config.redis.enabled ? new RedisTokenStore(createRedisClient()) : new TestingTokenStore(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth calling this InMemoryToken store?
We use an in memory token store for jobs as it means don't need to worry about redis being accessible (dodgy DNS issues)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, I'll rename it
import RedisStore from 'connect-redis' | ||
import express, { Router } from 'express' | ||
import { createRedisClient } from '../data/redisClient' | ||
import config from '../config' | ||
import logger from '../../logger' | ||
|
||
export default function setUpWebSession(): Router { | ||
const client = createRedisClient() | ||
client.connect().catch((err: Error) => logger.error(`Error connecting to Redis`, err)) | ||
let store: Store |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this fall back to the inmemory store? what happens if you pass undefined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Express defaults to a MemoryStore, so passing undefined means it uses its own in-memory store for session data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Removes the need for a local Redis container