From e8d1ba9c96c3240457ed09e78a12f771de20e2bf Mon Sep 17 00:00:00 2001 From: Sergo Date: Sat, 12 Aug 2023 10:56:16 +0300 Subject: [PATCH] add redis creds --- .dockerignore | 2 +- config/prod.js | 11 ++++++----- deployment.yaml | 10 +++++++++- src/app.ts | 23 ++++++++++++++--------- 4 files changed, 30 insertions(+), 16 deletions(-) diff --git a/.dockerignore b/.dockerignore index 6ca5555..495f8ee 100644 --- a/.dockerignore +++ b/.dockerignore @@ -7,4 +7,4 @@ node_modules deployment.yaml Dockerfile readme.md -.git +.git \ No newline at end of file diff --git a/config/prod.js b/config/prod.js index d1551f0..e609051 100644 --- a/config/prod.js +++ b/config/prod.js @@ -4,14 +4,15 @@ module.exports = { gatewayUri: process.env.OIDC_GATEWAY_URI, clientId: process.env.OIDC_CLIENT_ID, clientSecret: process.env.OIDC_CLIENT_SECRET, - redirectUris: process.env.OIDC_REDIRECT_URIS + redirectUris: process.env.OIDC_REDIRECT_URIS, }, wildDuck: { url: process.env.WILDDUCK_URL, token: process.env.WILDDUCK_TOKEN, - domain: process.env.WILDDUCK_DOMAIN + domain: process.env.WILDDUCK_DOMAIN, }, redis: { - url: process.env.REDIS_URL - } -}; \ No newline at end of file + url: process.env.REDIS_URL, + password: process.env.REDIS_PASSWORD, + }, +}; diff --git a/deployment.yaml b/deployment.yaml index 7ef2aea..2b9d782 100644 --- a/deployment.yaml +++ b/deployment.yaml @@ -99,7 +99,15 @@ spec: name: walias-secrets key: WILDDUCK_DOMAIN - name: REDIS_URL - value: walias-cache + valueFrom: + secretKeyRef: + name: redis-walias-cache-owner-secrets + key: REDIS_MASTER_URI + - name: REDIS_PASSWORD + valueFrom: + secretKeyRef: + name: redis-walias-cache-owner-secrets + key: REDIS_PASSWORD envFrom: - secretRef: name: oidc-client-walias-owner-secrets diff --git a/src/app.ts b/src/app.ts index 123a78c..5b0cca3 100644 --- a/src/app.ts +++ b/src/app.ts @@ -16,6 +16,7 @@ import { channels } from './channels'; import { Env, getEnv } from './helpers/get-env'; const app: Application = express(feathers()); +let sessionStore; // Load app configuration app.configure(configuration()); @@ -28,15 +29,19 @@ app.use( app.use(cookieParser()); -const sessionStore = - getEnv() === Env.prod - ? new RedisStore({ - prefix: 'walias:', - client: createClient({ - url: config.get('redis.url'), - }), - }) - : undefined; +if (getEnv() === Env.prod) { + const redisClient = createClient({ + url: config.get('redis.url'), + password: config.get('redis.password'), + }); + + sessionStore = new RedisStore({ + prefix: 'walias:', + client: redisClient, + }); + + redisClient.connect().catch(console.error); +} app.use( session({