Skip to content

Commit

Permalink
remove middlewares
Browse files Browse the repository at this point in the history
  • Loading branch information
crassaertcampings committed Aug 29, 2024
1 parent 33368cf commit f1612a5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion routes/v1.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ function addRoutes(app, peliasConfig) {
middleware.requestLanguage,
middleware.sizeCalculator(),
controllers.search(peliasConfig, esclient, queries.autocomplete, not(hasResponseDataOrRequestErrors)),
middleware.distance('focus.point.'),
// middleware.distance('focus.point.'),
middleware.confidenceScore(peliasConfig.api),
middleware.applyOverrides(),
middleware.dedupe(),
Expand Down
12 changes: 12 additions & 0 deletions service/configurations/Language.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const url = require('url');
const logger = require('pelias-logger').get('api');

const _ = require('lodash');

Expand All @@ -10,17 +11,28 @@ class Language extends ServiceConfiguration {
}

getParameters(req, res) {
logger.info('get parameters for language');
_.get(res, 'data', []).reduce((acc, doc) => {
console.log(doc);
Array.prototype.push.apply(acc, _.values(_.pickBy(doc.parent, (v, k) => _.endsWith(k, '_id') ) ) );
return acc;
}, []);
// find all the values for all keys with names that end with '_id'
const ids = _.get(res, 'data', []).reduce((acc, doc) => {
Array.prototype.push.apply(acc, _.values(_.pickBy(doc.parent, (v, k) => _.endsWith(k, '_id') ) ) );
return acc;
}, []);

logger.info('id before flatten', ids);

const lang = _.get(req, 'clean.lang.iso6393');
const parameters = {
// arrays will be nested, so flatten first, then uniqify, and finally join elements with comma
ids: _.uniq(_.flattenDeep(ids)).join(',')
};

logger.info('parameters', parameters);

if (lang) {
parameters.lang = lang;
}
Expand Down

0 comments on commit f1612a5

Please sign in to comment.