From e50410a87570bf92c193bb49a82215ea7e655116 Mon Sep 17 00:00:00 2001 From: Juan Picado Date: Sun, 12 Sep 2021 17:12:47 +0200 Subject: [PATCH] feat: fastify search endpoint v1 without auth and format (#2432) --- packages/core/server/src/endpoints/search.ts | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/packages/core/server/src/endpoints/search.ts b/packages/core/server/src/endpoints/search.ts index eee0b6322..7a053518b 100644 --- a/packages/core/server/src/endpoints/search.ts +++ b/packages/core/server/src/endpoints/search.ts @@ -3,12 +3,22 @@ import { logger } from '@verdaccio/logger'; async function searchRoute(fastify) { - fastify.get('/-/v1/search', async () => { + fastify.get('/-/v1/search', async (request, reply) => { + // TODO: apply security layer here like in + // packages/api/src/v1/search.ts + // TODO: add validations for query, some parameters are mandatory + // TODO: review which query fields are mandatory + + const { url, query } = request; + const storage = fastify.storage; + + const data = await storage.searchManager?.search({ + query: query, + url: url, + }); + logger.http('search endpoint'); - // @ts-ignore - console.log('-storage->', fastify.storage); - console.log('-config->', fastify.config); - return {}; + reply.code(200).send(data); }); }