cdnjs / api-server

📡 API server for api.cdnjs.com - The #1 free and open source CDN built to make life easier for developers.
https://api.cdnjs.com
MIT License
89 stars 38 forks source link

Limit Algolia query when searching #15

Closed xtuc closed 4 years ago

xtuc commented 4 years ago

When doing a search using the api and the string is too big Algolia will reject it. We should check the size against their constant

2020-05-06T06:33:43.000 36com265    'Invalid value for \\"query\\" parameter, expected string shorter than QUERY_ARGUMENTS_LIMIT_QUERY_MAX_LEN bytes',
2020-05-06T06:33:43.000 36com265   message:
2020-05-06T06:33:43.000 36com265 { name: 'ApiError',
2020-05-06T06:33:43.000 36com265   transporterStackTrace:
2020-05-06T06:33:43.000 36com265   status: 400,
2020-05-06T06:33:43.000 36com265        host: [Object],
2020-05-06T06:33:43.000 36com265        response: [Object],
2020-05-06T06:33:43.000 36com265 ::ffff:127.0.0.1 - - [06/May/2020:06:33:43 +0000] "GET /libraries?search=(big string...) HTTP/1.1" 200 38 "-" "Go-http-client/1.1"
2020-05-06T06:33:43.000 36com265        triesLeft: 3 } ] }
2020-05-06T06:33:43.000 36com265    [ { request: [Object],