All files / core/blong-realm/adapter/semlog blongSearchFindRequestSend.ts

100% Statements 18/18
66.66% Branches 2/3
100% Functions 1/1
100% Lines 18/18

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 191x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 5x 1x 1x 1x 1x 1x 1x  
import {handler} from '@feasibleone/blong';
 
/**
 * The request the port makes for `blong.search.find`: free text over what was observed.
 *
 * A parameter the caller left out is not sent at all, because the service's own default is
 * a better answer than an empty one spelled `q=undefined`. See `blongFlowFindRequestSend.ts`
 * for why this is a conversion and not a handler.
 */
export default handler(
    () =>
        function blongSearchFindRequestSend(params: {query?: string; limit?: number}) {
            const search = new URLSearchParams();
            if (params.query) search.set('q', params.query);
            if (params.limit !== undefined) search.set('limit', String(params.limit));
            return {method: 'GET', path: '/search', query: search.toString(), responseType: 'json'};
        },
);