Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'pelias-logger' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.
const _ = require('lodash');
const iso3166 = require('../helper/iso3166');
const Debug = require('../helper/debug');
const debugLog = new Debug('controller:libpostal');
const logger = require('pelias-logger').get('api');
// mapping object from libpostal fields to pelias fields
var field_mapping = {
island: 'island',
category: 'category',
house: 'query',
house_number: 'number',
road: 'street',
suburb: 'neighbourhood',
city_district: 'borough',
city: 'city',
state_district: 'county',
state: 'state',
postcode: 'postalcode',
country: 'country',
unit: 'unit',
/**
The addendum mapper is responsible for adding interesting metadata
as an 'addendum' to the record.
@see: https://github.com/pelias/api/pull/1255
**/
const through = require('through2');
const peliasLogger = require('pelias-logger').get('openstreetmap');
const whitelist = [
'wheelchair', // Wheelchair accessibility
'iata', // IATA airport codes
'icao', // ICAO airport codes
'wikidata', // Wikidata concordance
'wikipedia', // Wikipedia concordance
// 'website', // Website URL
// 'phone', // Telephone number
// 'opening_hours', // Opening hours
];
module.exports = function(){
return through.obj(( doc, enc, next ) => {
try {
const _ = require('lodash');
const stable = require('stable');
const logger = require('pelias-logger').get('api');
function setup(comparator, should_execute) {
function middleware(req, res, next) {
// bail early if req/res don't pass conditions for execution or there's no data to sort
if (!should_execute(req, res) || _.isEmpty(res.data)) {
return next();
}
// capture the pre-sort order
const presort_order = res.data.map(_.property('_id'));
// stable operates on array in place
stable.inplace(res.data, comparator(req.clean));
// capture the post-sort order
const postsort_order = res.data.map(_.property('_id'));
const _ = require('lodash');
const logger = require('pelias-logger').get('api');
// handle application errors
function middleware(err, req, res) {
logger.error( 'Error: `%s`. Stack trace: `%s`.', err, err.stack );
if( res.statusCode < 400 ){
logger.info( 'status code changed from', res.statusCode, 'to 500' );
res.status(500);
}
// set error message
const error = (err && err.message) ? err.message : err;
let msg = 'internal server error';
if (_.isString(error) && !_.isEmpty(error)) {
msg = error;
/**
*
*Basic confidence score should be computed and returned for each item in the results.
* The score should range between 0-1, and take into consideration as many factors as possible.
*
* Some factors to consider:
*
* - number of results from ES
* - score of item within the range of highest-lowest scores from ES (within the returned set)
* - linguistic match of query
* - detection (or specification) of query type. i.e. an address shouldn't match an admin address.
*/
const _ = require('lodash');
const stats = require('stats-lite');
const logger = require('pelias-logger').get('api');
const field = require('../helper/fieldValue');
var RELATIVE_SCORES = true;
function setup(peliasConfig) {
if (!_.isNil(peliasConfig)) {
RELATIVE_SCORES = peliasConfig.hasOwnProperty('relativeScores') ? peliasConfig.relativeScores : true;
}
return computeScores;
}
function computeScores(req, res, next) {
// do nothing if no result data set or if query is not of the pelias_parser variety
if (_.isUndefined(req.clean) || _.isUndefined(res) ||
_.isUndefined(res.data) || _.isUndefined(res.meta) ||
res.meta.query_type !== 'search_pelias_parser') {
const logger = require('pelias-logger').get('api');
const Document = require('pelias-model').Document;
const placeTypes = require('../helper/placeTypes');
const _ = require('lodash');
/**
* Convert WOF integer ids to Pelias formatted ids that can be used by the /place endpoint.
* This should probably be moved to the import pipeline once we are happy with the way this works.
*/
function setup() {
return function (req, res, next) {
// do nothing if no result data set
if (!res || !res.data) {
return next();
}
/**
The popularity mapper is responsible for generating a 'popularity'
value by inspecting OSM tags.
Disused and abandoned places are given a strong negative score.
If the popularity score is less than zero then the document is discarded.
Feel free to make changes to this mapping file!
**/
const through = require('through2');
const peliasLogger = require('pelias-logger').get('openstreetmap');
const config = {
// https://taginfo.openstreetmap.org/keys/importance
importance: {
international: { _score: 50000 },
national: { _score: 10000 },
regional: { _score: 5000 },
urban: { _score: 1000 },
suburban: { _score: 500 },
local: { _score: 100 },
},
// concordances
wikipedia: { _score: 3000 },
wikidata: { _score: 3000 },
var _ = require('lodash'),
peliasSchema = require('pelias-schema'),
peliasLogger = require( 'pelias-logger' ).get( 'api' );
var ADMIN_FIELDS = [
'admin0',
'admin1',
'admin1_abbr',
'admin2',
'local_admin',
'locality',
'neighborhood',
'address.zip'
];
/**
* Get all admin fields that were expected and also found in schema
*
* @param {Object} [schema] optional: for testing only
const peliasConfig = require('pelias-config').generate(require('./schema'));
const _ = require('lodash');
const logger = require('pelias-logger').get('openstreetmap');
if (_.has(peliasConfig, 'imports.openstreetmap.adminLookup')) {
logger.info('imports.openstreetmap.adminLookup has been deprecated, ' +
'enable adminLookup using imports.adminLookup.enabled = true');
}
const importPipeline = require('./stream/importPipeline');
importPipeline.import();
const RateLimiter = require('request-rate-limiter');
const async = require('async');
const logger = require('pelias-logger').get('download_data_filtered');
const parallelTransform = require('parallel-transform');
const streamArray = require('stream-array');
const addToPlacesByPlacetype = require('./getPlaceInfo').addToPlacesByPlacetype;
const PLACETYPES = require('../../src/bundleList').getPlacetypes();
const limiter = new RateLimiter({
rate: 6,
interval: 1,
backoffCode: 429,
backoffTime: 1
});
const maxInFlight = 1;