Skip to content
This repository has been archived by the owner on Aug 27, 2024. It is now read-only.

Commit

Permalink
feat(surface): removing validator on the surface ids
Browse files Browse the repository at this point in the history
  • Loading branch information
bassrock committed Jul 12, 2024
1 parent 77fb7e0 commit ca09183
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 27 deletions.
10 changes: 0 additions & 10 deletions src/routes/scheduledItems.integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,6 @@ describe('/scheduled-items/:scheduledSurfaceID?date=date&apikey=apikey', () => {
expect(response.statusCode).equals(404);
});

it('should return 500 if incorrect scheduled surface is provided ', async () => {
const response = await requestAgent.get(
`/scheduled-items/NEW_TAB_DOES_NOT_EXIST`,
);

expect(response.statusCode).equals(500);
expect(response.body.error).to.not.be.undefined;
expect(response.body.error).to.equal('Not a valid Scheduled Surface.');
});

it('should return 500 if incorrect date format is provided ', async () => {
const response = await requestAgent.get(
`/scheduled-items/${testNewTab}?date=20220524`,
Expand Down
8 changes: 1 addition & 7 deletions src/routes/scheduledItems.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import { BrazeContentProxyResponse, TransformedCorpusItem } from './types';
import { ClientApiResponse } from '../graphql/types';
import {
getResizedImageUrl,
validateApiKey,
validateDate,
validateScheduledSurfaceGuid,
} from '../utils';
import { getResizedImageUrl, validateApiKey, validateDate } from '../utils';
import { getScheduledSurfaceStories } from '../graphql/client-api-proxy';
import config from '../config';
import { Router } from 'express';
Expand All @@ -29,7 +24,6 @@ router.get('/:scheduledSurfaceID', async (req, res, next) => {

try {
// Validate inputs
validateScheduledSurfaceGuid(scheduledSurfaceID);
validateDate(date);
await validateApiKey(apiKey);

Expand Down
10 changes: 0 additions & 10 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,6 @@
*/
import config from './config';

export function validateScheduledSurfaceGuid(name: string): void {
const allowlist = ['POCKET_HITS_EN_US', 'POCKET_HITS_DE_DE'];

if (allowlist.includes(name)) {
return;
} else {
throw new Error('Not a valid Scheduled Surface.');
}
}

/**
* Check if the date string provided is in YYYY-MM-DD format.
*
Expand Down

0 comments on commit ca09183

Please sign in to comment.