mirror of
https://github.com/codex-team/codex.docs.git
synced 2025-07-19 13:19:42 +02:00
Update search.ts
This commit is contained in:
parent
80e9504386
commit
e237f27eb8
1 changed files with 6 additions and 6 deletions
|
@ -1,5 +1,5 @@
|
||||||
import express, { Request, Response } from 'express';
|
import express, { Request, Response } from 'express';
|
||||||
import Search from '../../controllers/search';
|
import Search from '../../controllers/search.js';
|
||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
|
@ -13,18 +13,18 @@ router.get('/search', async (req: Request, res: Response) => {
|
||||||
const searchString = req.query.text as string;
|
const searchString = req.query.text as string;
|
||||||
|
|
||||||
/** Start measuring search time */
|
/** Start measuring search time */
|
||||||
const startTime = performance.now();
|
// const startTime = performance.now();
|
||||||
|
|
||||||
const search = new Search();
|
const search = new Search();
|
||||||
|
|
||||||
const searchResponse = await search.query(searchString);
|
const searchResponse = await search.query(searchString);
|
||||||
|
|
||||||
/** End measuring search time */
|
/** End measuring search time */
|
||||||
const endTime = performance.now();
|
// const endTime = performance.now();
|
||||||
|
|
||||||
/** Show search time */
|
/** Show search time */
|
||||||
const searchItem = (endTime - startTime).toFixed(6);
|
// const searchItem = (endTime - startTime).toFixed(6);
|
||||||
console.log(`🔎 "${searchString}" ⏱ ${searchItem} ms`);
|
// console.log(`🔎 "${searchString}" ⏱ ${searchItem} ms`);
|
||||||
|
|
||||||
const compactedPages = searchResponse.pages.map(page => {
|
const compactedPages = searchResponse.pages.map(page => {
|
||||||
return {
|
return {
|
||||||
|
@ -42,7 +42,7 @@ router.get('/search', async (req: Request, res: Response) => {
|
||||||
result: {
|
result: {
|
||||||
suggestions: searchResponse.suggestions,
|
suggestions: searchResponse.suggestions,
|
||||||
pages: compactedPages,
|
pages: compactedPages,
|
||||||
time: searchItem,
|
// time: searchItem,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue