Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[hotfix] Slise ads endpoints enabling #146

Merged
merged 2 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
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';
Expand Down Expand Up @@ -157,7 +157,7 @@
await redisClient.lpush('notifications', JSON.stringify(newNotification));

res.status(200).send({ message: 'Notification added successfully', notification: newNotification });
} catch (error: any) {

Check warning on line 160 in src/index.ts

View workflow job for this annotation

GitHub Actions / Checks if ts and lint works

Unexpected any. Specify a different type
res.status(500).send({ error: error.message });
}
});
Expand Down Expand Up @@ -328,14 +328,14 @@
}
});

// 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 {
await startMagicSquareQuest(req.body);

res.status(200).send({ message: 'Quest successfully started' });
} catch (error: any) {

Check warning on line 338 in src/index.ts

View workflow job for this annotation

GitHub Actions / Checks if ts and lint works

Unexpected any. Specify a different type
console.error(error);

if (error instanceof CodedError) {
Expand All @@ -349,7 +349,7 @@
app.get('/api/magic-square-quest/participants', basicAuth, async (req, res) => {
try {
res.status(200).send(await getMagicSquareQuestParticipants());
} catch (error: any) {

Check warning on line 352 in src/index.ts

View workflow job for this annotation

GitHub Actions / Checks if ts and lint works

Unexpected any. Specify a different type
console.error(error);

if (error instanceof CodedError) {
Expand All @@ -363,10 +363,10 @@
app.get('/api/signing-nonce', (req, res) => {
try {
const pkh = req.query.pkh;
if (!pkh || typeof pkh !== 'string') throw new Error('PKH is not a string');

Check warning on line 366 in src/index.ts

View workflow job for this annotation

GitHub Actions / Checks if ts and lint works

Unexpected value in conditional. A boolean expression is required

res.status(200).send(getSigningNonce(pkh));
} catch (error: any) {

Check warning on line 369 in src/index.ts

View workflow job for this annotation

GitHub Actions / Checks if ts and lint works

Unexpected any. Specify a different type
console.error(error);

if (error instanceof CodedError) {
Expand Down
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 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 @@
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
Loading