mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Rename X-Device to X-OmnivoreClient in the request headers
This commit is contained in:
parent
d74eee131c
commit
ab86450864
2 changed files with 12 additions and 6 deletions
8
.github/workflows/run-tests.yaml
vendored
8
.github/workflows/run-tests.yaml
vendored
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue