{"id":19206886,"url":"https://github.com/pkoretic/weather-service","last_synced_at":"2025-07-25T16:02:34.637Z","repository":{"id":27405310,"uuid":"113777620","full_name":"pkoretic/weather-service","owner":"pkoretic","description":"Node.js weather service","archived":false,"fork":false,"pushed_at":"2022-12-30T17:46:36.000Z","size":341,"stargazers_count":2,"open_issues_count":10,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-20T10:04:39.085Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pkoretic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-10T19:35:21.000Z","updated_at":"2020-09-28T01:53:59.000Z","dependencies_parsed_at":"2023-01-14T06:40:27.961Z","dependency_job_id":null,"html_url":"https://github.com/pkoretic/weather-service","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pkoretic/weather-service","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkoretic%2Fweather-service","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkoretic%2Fweather-service/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkoretic%2Fweather-service/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkoretic%2Fweather-service/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pkoretic","download_url":"https://codeload.github.com/pkoretic/weather-service/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkoretic%2Fweather-service/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267029007,"owners_count":24024199,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-25T02:00:09.625Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T13:17:20.381Z","updated_at":"2025-07-25T16:02:34.506Z","avatar_url":"https://github.com/pkoretic.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# weather-service\nNode.js weather service.\n\n  * [Running](#running)\n  * [Configuration](#configuration)\n  * [API](#api)\n  * [Caching, Compression, HTTP/2](#caching-compression-http2)\n  * [Providers](#providers)\n  * [Scalability](#scalability)\n  * [Testing](#testing)\n\n## Running\n\n```\nnpm install\nPROVIDER_API_KEY=xxxx npm start\n```\n\nBy default this starts HTTP/2 server on the localhost, port 3000.\n```\nlistening on localhost:3000\n```\n\n***Note*** for each provider a valid api key is needed if the service requires it. See\nhttp://openweathermap.org/appid for **openweather** provider.\n\n## Configuration\n\nConfiguration values can be changed by setting enviroment variables.\n\n* **HTTP_HOST** - provide alternative host for the HTTP server\n* **HTTP_PORT** - provide alternative port for the HTTP server\n* **ACCESS_KEY** - when set, clients need to provide this accessKey to authorize requests\n* **PROVIDER_NAME** - set weather service provider, currently only **openweather** is supported\nwhich is also a default value\n* **PROVIDER_API_KEY** - set a valid weather service provider api key\n\nExample usage:\n```\nHTTP_PORT=3001 ACCESS_KEY=1234 PROVIDER_API_KEY=xxxx npm start\n```\n\n## API\n\n* Get forecast by the **city** name\n\n    * **Request** - https://localhost:3000/forecast?city={cityName,[country_code]}\n\n        The openweather provider supports additional ISO 3166 country code for better acurracy.\n\n        *https://localhost:3000/forecast?city=Berlin,de*\n\n    * **Response**\n\n        The response contains weather data for the next 24 hours in block of 3 hours.\n\n        ```\n        {\n            \"sunrise\": \"2017-12-10T07:06:59\",\n            \"sunset\": \"2017-12-10T14:52:08\",\n            \"time\": [\n            {\n                \"from\": \"2017-12-10T18:00:00\",\n                \"to\": \"2017-12-10T21:00:00\",\n                \"name\": \"light snow\",\n                \"icon\": \"13n\",\n                \"temperature\": -0.41,\n                \"humidity\": 93,\n                \"precipitation\": {\n                    \"value\": 1.402,\n                    \"type\": \"snow\"\n                },\n                \"wind\": {\n                    \"speed\": 6.16,\n                    \"desc\": \"Moderate breeze\",\n                    \"deg\": 147.001,\n                    \"dir\": \"SSE\"\n                }\n            },\n            ...\n        }\n        ```\n\n        * **sunrise** - sun rise time in the ISO UTC format\n        * **sunset** - sun set time in the ISO UTC format\n        * **time** - array of weather data in the block of 3 hours\n            * *from* - start of the time block range in the ISO UTC format\n            * *to* - end of the time block range in the ISO UTC format\n            * *name* - textual representation of the weather, i.e. *clear sky*\n            * *icon* - uid of the weather icon\n            * *temperature* - temperature, `celsius`\n            * *humidity* - humidity value, `percent`\n            * *precipitation* - if provided contains:\n                * value - precipitation value, `milimitters(mm)`\n                * type - one of [snow, rain, no]\n            * *wind*\n                * *speed* - speed of the wind, `meters per second(mps)`\n                * *desc* - textual representation of the wind, i.e. *Moderate breeze*\n                * *deg* - wind direction, `degrees`\n                * *dir* - direction of the wind by the initials [N, E, S, W, NE, SE, SW, ...]\n\n* Get forecast by **latitude** and **longitude**\n\n    * **Request** - https://localhost:3000/forecast?lat={latitue}\u0026lon={longitude}\n\n        ```https://localhost:3000/forecast?lat=52.520008\u0026lon=13.404954```\n\n    * **Response**\n\n        Same as above.\n\n* Get weather **icon** by the uid (this is provided by the api)\n\n    * **Request** - https://localhost:3000/icon/{icon.png}\n\n        ```https://localhost:3000/icon/11n.png```\n\n    * **Response**\n\n        Raw image.\n\n * Access key - when access key is setup on the server clients also need to provide it as part of\n the request\n\n    ```https://localhost:3000/forecast?city=Berlin\u0026accessKey=1234```\n\n## Caching, Compression, HTTP/2\n\nService employs multiple techniques to minimize the latency and data returned to the client.\n* HTTP/2 - enabled by default but also supports HTTP/1 through ALPN.\n * HTTP compression - supports standard HTTP gzip, deflate compression to minimize data size.\n * HTTP and in memory caching - caches requests for a specified amount of time to avoid processing\n data at each request returning Cache-Control headers to the client.\n\n## Providers\n\n At the moment only **openweather** is provided. This can be easily extended to support other\n providers. See [providers](providers) for more info.\n\n## Scalability\n\n Vertical and horizontal scaling is supported. `pm2` can be used to easily scale the app, i.e.:\n\n ```\n npm install pm2@latest -g\n pm2 start index.js -i 4\n ```\n\n## Testing\n\n To check if all tests are valid and passed run:\n\n ```\n npm run test\n\n\n listening on localhost:3000\n  API\nGET /forecast?city=Berlin - 320ms\n    ✓ should get forecast by city (374ms)\nGET /forecast?lat=52.520008\u0026lon=13.404954 - 226ms\n    ✓ should get forecast by latitude, longitude (247ms)\nGET /forecast?lat=52.520008 - 0ms\n    ✓ should throw error on missing longitude\nGET /forecast?lon=13.404954 - 0ms\n    ✓ should throw error on missing latitude\nGET /forecast - 0ms\n    ✓ should throw error on invalid parameters\n\n\n  5 passing (660ms)\n ```\n\n This starts the service and checks data from the providers so valid api key is also needed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpkoretic%2Fweather-service","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpkoretic%2Fweather-service","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpkoretic%2Fweather-service/lists"}