From ca0918359a991a326304020b4351c2b5c80c83aa Mon Sep 17 00:00:00 2001 From: Daniel Brooks Date: Fri, 12 Jul 2024 07:36:11 -0700 Subject: [PATCH] feat(surface): removing validator on the surface ids --- src/routes/scheduledItems.integration.ts | 10 ---------- src/routes/scheduledItems.ts | 8 +------- src/utils.ts | 10 ---------- 3 files changed, 1 insertion(+), 27 deletions(-) diff --git a/src/routes/scheduledItems.integration.ts b/src/routes/scheduledItems.integration.ts index 66512392..9dd064a5 100644 --- a/src/routes/scheduledItems.integration.ts +++ b/src/routes/scheduledItems.integration.ts @@ -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`, diff --git a/src/routes/scheduledItems.ts b/src/routes/scheduledItems.ts index 98b6d773..6ed7f3e4 100644 --- a/src/routes/scheduledItems.ts +++ b/src/routes/scheduledItems.ts @@ -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'; @@ -29,7 +24,6 @@ router.get('/:scheduledSurfaceID', async (req, res, next) => { try { // Validate inputs - validateScheduledSurfaceGuid(scheduledSurfaceID); validateDate(date); await validateApiKey(apiKey); diff --git a/src/utils.ts b/src/utils.ts index 20cf08a8..87c1e9c4 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -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. *