From 54a2da74f662f23770e4bd6941bb6d8938935b18 Mon Sep 17 00:00:00 2001 From: "@wwwjim" Date: Mon, 16 Nov 2020 00:18:02 -0800 Subject: [PATCH] remove unused search endpoints --- common/actions.js | 8 +----- pages/api/search/[query].js | 22 ---------------- pages/api/search/slates/[query].js | 41 ------------------------------ 3 files changed, 1 insertion(+), 70 deletions(-) delete mode 100644 pages/api/search/[query].js delete mode 100644 pages/api/search/slates/[query].js diff --git a/common/actions.js b/common/actions.js index ede71c6e..5f9378e1 100644 --- a/common/actions.js +++ b/common/actions.js @@ -79,13 +79,6 @@ export const getNetworkDirectory = async () => { }); }; -export const searchSlates = async (data) => { - return await returnJSON(`/api/search/slates/${data.query}`, { - ...DEFAULT_OPTIONS, - body: JSON.stringify({ data }), - }); -}; - export const getSlateById = async (data) => { return await returnJSON(`/api/slates/get`, { ...DEFAULT_OPTIONS, @@ -125,6 +118,7 @@ export const search = async (data) => { if (Strings.isEmpty(data.query)) { return { decorator: "NO_SERVER_TRIP", data: { results: [] } }; } + if (Strings.isEmpty(data.resourceURI)) { return { decorator: "NO_RESOURCE_URI", data: { results: [] } }; } diff --git a/pages/api/search/[query].js b/pages/api/search/[query].js deleted file mode 100644 index fd7d3c5e..00000000 --- a/pages/api/search/[query].js +++ /dev/null @@ -1,22 +0,0 @@ -import * as Strings from "~/common/strings"; -import * as Data from "~/node_common/data"; - -export default async (req, res) => { - if (Strings.isEmpty(req.query.query)) { - return { - decorator: "SERVER_SEARCH_NO_QUERY", - data: { results: [] }, - }; - } - - const { query } = req.query; - const users = await Data.queryUsers({ query }); - const slates = await Data.querySlates({ query }); - - let results = [...users, ...slates]; - - return res.status(200).send({ - decorator: "SERVER_SEARCH_QUERY", - data: { query, results }, - }); -}; diff --git a/pages/api/search/slates/[query].js b/pages/api/search/slates/[query].js deleted file mode 100644 index fa1e125b..00000000 --- a/pages/api/search/slates/[query].js +++ /dev/null @@ -1,41 +0,0 @@ -import * as Data from "~/node_common/data"; -import * as Serializers from "~/node_common/serializers"; -import * as Strings from "~/common/strings"; - -export default async (req, res) => { - if (Strings.isEmpty(req.query.query)) { - return { - decorator: "SERVER_SEARCH_NO_QUERY", - data: { results: [] }, - }; - } - - const { query } = req.query; - const slates = await Data.querySlates({ query }); - - //NOTE(martina): this way of deeplinking no longer works now that slates can have same names (however it is currently unused so I've left it here) - if (req.body.data.deeplink) { - if (slates.length) { - const slate = slates.filter((item) => item.slatename === query)[0]; - const user = await Data.getUserById({ id: slate.data.ownerId }); - slate.user = Serializers.user(user); - - return res.status(200).send({ - decorator: "SERVER_DEEPLINK", - data: { slate }, - }); - } - - return res.status(500).send({ - decorator: "SERVER_DEEPLINK_ERROR", - error: true, - }); - } - - let results = [...slates]; - - return res.status(200).send({ - decorator: "SERVER_SEARCH_QUERY", - data: { query, results }, - }); -};