Skip to content

Commit

Permalink
[hotfix] Slise ads return empty cache-controlled data
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-tsx committed Feb 20, 2024
1 parent ee47e17 commit a16beb0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
7 changes: 4 additions & 3 deletions src/routers/slise-ad-rules/providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
getAllSliseAdProvidersBySites,
getSelectorsByProviderId,
getSliseAdProvidersByDomain,
getSliseAdProvidersForAllSites,
// getSliseAdProvidersForAllSites,
removeProviders,
removeSliseAdProvidersBySites,
removeSliseAdProvidersForAllSites,
Expand Down Expand Up @@ -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(
Expand Down
14 changes: 8 additions & 6 deletions src/utils/express-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const withExceptionHandler =
}
};

export const addObjectStorageMethodsToRouter = <V>(
export const addObjectStorageMethodsToRouter = <V extends any[]>(

Check warning on line 47 in src/utils/express-helpers.ts

View workflow job for this annotation

GitHub Actions / Checks if ts and lint works

Unexpected any. Specify a different type
router: Router,
path: string,
methods: ObjectStorageMethods<V>,
Expand All @@ -56,21 +56,23 @@ export const addObjectStorageMethodsToRouter = <V>(
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);
})
);

router
.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(
Expand Down

0 comments on commit a16beb0

Please sign in to comment.