Urgent.News

What's breaking now, across thousands of outlets.

Tech

One request a second for the whole app, so our place search has no search-as-you-type

Setting up a business campaign in Nakodo means saying where to look. You type a town, a city, a region or a country, press Add, choose which match you meant, and pick a distance. To search a places listing by coordinates, we need to turn "Leeds" into a latitude, a longitude and a sensible radius. That is geocoding, and the paid options are fine and metered. We used Nominatim , OpenStreetMap's own…

When building a place search feature in Nakodo's business campaign, the interface must prioritize the policy over performance. The free and metered Nominatim geocoder is used for geocoding, but it enforces a strict limit of one request per second across the entire user base. To adhere to this policy, the interface is designed without search-as-you-type functionality.

Users type their input, press Add or Enter, and then select from the returned matches. This approach avoids performance compromises and aligns with the policy, even though it may seem like a design choice. The rate limiting is implemented using Upstash's Ratelimit library, with a constant key of "global" to represent the shared bucket for all users.

The limiter is configured to allow a maximum of one request per second. The caching mechanism is set to retain results for 30 days, as the location data is unlikely to change within that timeframe. If the rate limiter is unavailable, a local timestamp-based wait mechanism is employed to manage the request flow. The User-Agent string is dynamically generated, ensuring compliance with the policy's requirement for an identifying identifier.

This solution provides a user-friendly experience while respecting the Nominatim geocoding API's usage policy.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

✨ Meet Swingly — a tiny character that lives on your webpage and swings gently.

I built Swingly, a tiny, playful npm package that brings a little personality to the corner of your website. 🧿 Maybe it’s your evil-eye protector. 🪄 Maybe it’s a tiny charm.

  • Swingly is a tiny npm package adding personality to websites.
  • Offers various characters like evil-eye, charm, or whimsical creatures.
  • Open to community contributions for unique characters and interactions.

Your tsconfig Is Still Written for TypeScript 5. Here's the Cleanup TS 7 Forces

Most tsconfig.json files are archaeology. Somebody copied one from a starter repo in 2021, somebody else added baseUrl so the @/ imports would work, and a third person set moduleResolution: "node"…

  • TypeScript 7.0 removed deprecated options like types and rootDir.
  • tsconfig.json now defaults to empty types array, preventing automatic loading of nodemodules/@types.
  • rootDir defaults to directory containing tsconfig.json, causing output directory issues.

More from Sunday 4 October →