From bb547e8911cdf924f58a72f32526379cb198ddcf Mon Sep 17 00:00:00 2001 From: xfarrow Date: Mon, 11 Mar 2024 18:08:01 +0100 Subject: [PATCH] Create osm_data_fetcher.js --- .../apis/nodejs/src/utils/osm_data_fetcher.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 backend/apis/nodejs/src/utils/osm_data_fetcher.js diff --git a/backend/apis/nodejs/src/utils/osm_data_fetcher.js b/backend/apis/nodejs/src/utils/osm_data_fetcher.js new file mode 100644 index 0000000..59cd790 --- /dev/null +++ b/backend/apis/nodejs/src/utils/osm_data_fetcher.js @@ -0,0 +1,17 @@ +const OsmRateLimiter = { + lastFetchTime: 0, + + canFetch: function () { + return Date.now() - this.lastFetchTime >= 1000; + }, + + updateFetchTime: function () { + this.lastFetchTime = Date.now(); + } +}; + +function retrieveCitiesFullName(name){ + if (!OsmRateLimiter.canFetch()) { + // todo + } +} \ No newline at end of file