From ee47e17f9c0344c9e842d9c75cbd9715f91743d2 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 20 Feb 2024 21:09:53 +0200 Subject: [PATCH 1/2] Revert "[hotfix] Fix prod Slise ads" This reverts commit 9ff3dda10c58e9442c801281d287250544d7c552. --- src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 6cd1bfb..aff53ba 100644 --- a/src/index.ts +++ b/src/index.ts @@ -20,7 +20,7 @@ import { getNotifications } from './notifications/utils/get-notifications.util'; import { getParsedContent } from './notifications/utils/get-parsed-content.util'; import { getPlatforms } from './notifications/utils/get-platforms.util'; import { redisClient } from './redis'; -// import { sliseRulesRouter } from './routers/slise-ad-rules'; +import { sliseRulesRouter } from './routers/slise-ad-rules'; import { getABData } from './utils/ab-test'; import { cancelAliceBobOrder } from './utils/alice-bob/cancel-alice-bob-order'; import { createAliceBobOrder } from './utils/alice-bob/create-alice-bob-order'; @@ -328,7 +328,7 @@ app.get('/api/advertising-info', (_req, res) => { } }); -// app.use('/api/slise-ad-rules', sliseRulesRouter); +app.use('/api/slise-ad-rules', sliseRulesRouter); app.post('/api/magic-square-quest/start', async (req, res) => { try { From a16beb052ec6b4bb73a9557bfeffa0f641e3545b Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 20 Feb 2024 22:20:43 +0200 Subject: [PATCH 2/2] [hotfix] Slise ads return empty cache-controlled data --- src/routers/slise-ad-rules/providers.ts | 7 ++++--- src/utils/express-helpers.ts | 14 ++++++++------ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/routers/slise-ad-rules/providers.ts b/src/routers/slise-ad-rules/providers.ts index 7d8b610..f5fe297 100644 --- a/src/routers/slise-ad-rules/providers.ts +++ b/src/routers/slise-ad-rules/providers.ts @@ -6,7 +6,7 @@ import { getAllSliseAdProvidersBySites, getSelectorsByProviderId, getSliseAdProvidersByDomain, - getSliseAdProvidersForAllSites, + // getSliseAdProvidersForAllSites, removeProviders, removeSliseAdProvidersBySites, removeSliseAdProvidersForAllSites, @@ -157,9 +157,10 @@ sliseAdProvidersRouter .route('/all-sites') .get( withExceptionHandler(async (_req, res) => { - const providers = await getSliseAdProvidersForAllSites(); + // const providers = await getSliseAdProvidersForAllSites(); - res.status(200).send(providers); + // res.status(200).send(providers); + res.status(200).header('Cache-Control', 'public, max-age=300').send([]); }) ) .post( diff --git a/src/utils/express-helpers.ts b/src/utils/express-helpers.ts index 8a6e05b..34f1745 100644 --- a/src/utils/express-helpers.ts +++ b/src/utils/express-helpers.ts @@ -44,7 +44,7 @@ export const withExceptionHandler = } }; -export const addObjectStorageMethodsToRouter = ( +export const addObjectStorageMethodsToRouter = ( router: Router, path: string, methods: ObjectStorageMethods, @@ -56,11 +56,12 @@ export const addObjectStorageMethodsToRouter = ( router.get( path === '/' ? `/:${keyName}` : `${path}/:${keyName}`, withExceptionHandler(async (req, res) => { - const { [keyName]: key } = req.params; + // const { [keyName]: key } = req.params; - const value = await methods.getByKey(key); + // const value = await methods.getByKey(key); + const value = []; - res.status(200).send(value); + res.status(200).header('Cache-Control', 'public, max-age=300').send(value); }) ); @@ -68,9 +69,10 @@ export const addObjectStorageMethodsToRouter = ( .route(path) .get( withExceptionHandler(async (_req, res) => { - const values = await methods.getAllValues(); + // const values = await methods.getAllValues(); + const values = {}; - res.status(200).send(values); + res.status(200).header('Cache-Control', 'public, max-age=300').send(values); }) ) .post(