From 4cc3613f648abf81f1bbb89c0978eaba67f1dcc2 Mon Sep 17 00:00:00 2001 From: Luis Alvarez Date: Mon, 24 May 2021 19:06:07 -0500 Subject: [PATCH] Removed is-allowed-method from BC --- framework/bigcommerce/api/index.ts | 1 - .../api/utils/is-allowed-method.ts | 28 ------------------- 2 files changed, 29 deletions(-) delete mode 100644 framework/bigcommerce/api/utils/is-allowed-method.ts diff --git a/framework/bigcommerce/api/index.ts b/framework/bigcommerce/api/index.ts index a6ee3f508..300f1087b 100644 --- a/framework/bigcommerce/api/index.ts +++ b/framework/bigcommerce/api/index.ts @@ -1,4 +1,3 @@ -import type { NextApiHandler } from 'next' import type { RequestInit } from '@vercel/fetch' import { CommerceAPI, diff --git a/framework/bigcommerce/api/utils/is-allowed-method.ts b/framework/bigcommerce/api/utils/is-allowed-method.ts deleted file mode 100644 index 78bbba568..000000000 --- a/framework/bigcommerce/api/utils/is-allowed-method.ts +++ /dev/null @@ -1,28 +0,0 @@ -import type { NextApiRequest, NextApiResponse } from 'next' - -export default function isAllowedMethod( - req: NextApiRequest, - res: NextApiResponse, - allowedMethods: string[] -) { - const methods = allowedMethods.includes('OPTIONS') - ? allowedMethods - : [...allowedMethods, 'OPTIONS'] - - if (!req.method || !methods.includes(req.method)) { - res.status(405) - res.setHeader('Allow', methods.join(', ')) - res.end() - return false - } - - if (req.method === 'OPTIONS') { - res.status(200) - res.setHeader('Allow', methods.join(', ')) - res.setHeader('Content-Length', '0') - res.end() - return false - } - - return true -}