@brave/n8n-nodes-brave-search
Version:
A n8n node for the Brave Search API
41 lines • 1.42 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const parameters_1 = __importDefault(require("./parameters"));
const key = 'place_search';
const endpoint = '/local/place_search';
const details = {
name: 'Place Search',
value: key,
description: 'Search for points of interest in an area',
action: 'Search for Places',
};
parameters_1.default.forEach((p) => (p.displayOptions = { show: { operation: [key] } }));
const trim = (v) => (typeof v === 'string' ? v.trim() : '');
const buildQuery = (params) => {
const { query, location, latitude, longitude, count, ...rest } = params;
const qs = { count, ...rest };
const q = trim(query);
if (q !== '')
qs.q = q;
const loc = trim(location);
if (loc !== '')
qs.location = loc;
const lat = trim(latitude);
const lon = trim(longitude);
if (lat !== '' && lon !== '') {
qs.latitude = lat;
qs.longitude = lon;
}
for (const [k, v] of Object.entries(qs)) {
if (v === '' || v === undefined)
delete qs[k];
}
if (qs.radius === 0)
delete qs.radius;
return qs;
};
exports.default = { key, endpoint, details, parameters: parameters_1.default, buildQuery };
//# sourceMappingURL=index.js.map