From ab8645086454be4cc7642e51a736cecd588841f7 Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Wed, 12 Oct 2022 10:27:39 +0800 Subject: [PATCH] Rename X-Device to X-OmnivoreClient in the request headers --- .github/workflows/run-tests.yaml | 8 +++++++- packages/api/src/server.ts | 10 +++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml index 5f2681791..2986614a8 100644 --- a/.github/workflows/run-tests.yaml +++ b/.github/workflows/run-tests.yaml @@ -43,7 +43,13 @@ jobs: ports: - 9200 redis: - image: "redis:6.2.7" + image: redis + # Set health checks to wait until redis has started + options: >- + --health-cmd "redis-cli ping" + --health-interval 10s + --health-timeout 5s + --health-retries 5 ports: - 6379 steps: diff --git a/packages/api/src/server.ts b/packages/api/src/server.ts index b9c13fe98..98003f432 100755 --- a/packages/api/src/server.ts +++ b/packages/api/src/server.ts @@ -107,16 +107,16 @@ export const createApp = (): { // set user device from request header to Redis app.use('/api/', async (req, res, next) => { - const device = req.header('X-Device') + const client = req.header('X-OmnivoreClient') const token = // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access req.header('Authorization') || (req.cookies['auth'] as string | undefined) - if (device && token) { - const key = `device:${token}` + if (client && token) { + const key = `client:${token}` if (!(await redisClient.exists(key))) { - await redisClient.set(key, device, { - EX: 600, // 10 minutes + await redisClient.set(key, client, { + EX: 600, // expires in 10 minutes NX: true, }) }