{"id":41757239,"url":"https://github.com/coderade/nodejs-time-microservice","last_synced_at":"2026-01-25T01:39:46.117Z","repository":{"id":30075086,"uuid":"111324168","full_name":"coderade/nodejs-time-microservice","owner":"coderade","description":"Simple time micro-service application that returns the local time for a given location based on the the Google Time Zone and Geocoding APIs.","archived":false,"fork":false,"pushed_at":"2024-12-07T06:47:25.000Z","size":666,"stargazers_count":0,"open_issues_count":17,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-07T07:26:24.887Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/coderade.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2017-11-19T19:13:06.000Z","updated_at":"2024-06-16T23:20:57.000Z","dependencies_parsed_at":"2024-06-17T00:27:40.548Z","dependency_job_id":"1acab9fd-4289-4b14-a4cd-ac42617a7ba0","html_url":"https://github.com/coderade/nodejs-time-microservice","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/coderade/nodejs-time-microservice","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderade%2Fnodejs-time-microservice","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderade%2Fnodejs-time-microservice/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderade%2Fnodejs-time-microservice/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderade%2Fnodejs-time-microservice/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coderade","download_url":"https://codeload.github.com/coderade/nodejs-time-microservice/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderade%2Fnodejs-time-microservice/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28741109,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-25T01:25:41.653Z","status":"ssl_error","status_checked_at":"2026-01-25T01:25:34.364Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":"2026-01-25T01:39:46.046Z","updated_at":"2026-01-25T01:39:46.106Z","avatar_url":"https://github.com/coderade.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Node.js Time Microservice\n\nSimple time microservice application that returns the local time for a given location.\n\nThis time microservice uses the Google [Time Zone](https://developers.google.com/maps/documentation/timezone/intro) and [Geocoding](https://developers.google.com/maps/documentation/geocoding/intro) APIs and has been created to be used with my [Slack Bot API](https://github.com/coderade/nodejs-msb-slack-bot) project.\n\nYou will need to [create a Google account](https://accounts.google.com/SignUp?hl=en) and generate an API key for the [Time Zone](https://developers.google.com/maps/documentation/timezone/intro) and [Geocoding](https://developers.google.com/maps/documentation/geocoding/intro) APIs to use this service.\n\n## Status\n\n[![Codeship Status for coderade/nodejs-time-microservice](https://app.codeship.com/projects/638192e0-0228-0136-46ac-4ef38d9281bc/status?branch=master)](https://app.codeship.com/projects/280043)\n\n## Resilient Architecture\n\nAs this service has been created to be used with my Slack Bot API project as an intent service to process the result of the current datetime from a location to be used on my natural language processing with [wit.ai](https://wit.ai/), I have tried to make it resilient. The service knows the endpoint address of the main bot application (`http://127.0.0.1:3000/service/time`) and it will try to announce itself every 30 seconds to the intent it can serve.\n\nThe main [bot application](https://github.com/coderade/nodejs-msb-slack-bot) will keep track of the services available and route the requests there.\n\n## How to Use\n\n1. Download and install Node.js using [NVM](https://github.com/creationix/nvm).\n2. Install [yarn](https://yarnpkg.com/en/) following the official [documentation](https://yarnpkg.com/lang/en/docs/install/#linux-tab).\n3. Clone the repository and install the node modules:\n    ```bash\n    yarn install\n    ```\n\n## Running the Service\n\nTo run this application, an API key for the [Time Zone](https://developers.google.com/maps/documentation/timezone/intro) and [Geocoding](https://developers.google.com/maps/documentation/geocoding/intro) APIs will be necessary.\n\n1. Create your API key for each of these API services.\n2. Pass them as environment variables.\n\nThis project uses the [dotenv](https://github.com/motdotla/dotenv) module to load the environment variables. On the root directory of the project, use the following command to copy the example environment file to the `.env` file that will be used to load the environment variables:\n    ```bash\n    cp .env-example .env\n    ```\n\n3. Edit the `GEOCODE_API_KEY` and `TIMEZONE_API_KEY` environment variables with your generated keys, like the following:\n    ```plaintext\n    GEOCODE_API_KEY=0000-0000-0000-0000-0000\n    TIMEZONE_API_KEY=0000-0000-0000-0000-0000\n    ```\n\n4. You can also pass the environment variables on your IDE. I use the [WebStorm](https://www.jetbrains.com/webstorm) IDE to debug my Node.js applications, which you can follow this [tutorial](https://www.jetbrains.com/help/webstorm/run-debug-configuration-node-js.html) to set Node.js environment variables in this IDE.\n\n5. Otherwise, you can pass the Time Zone and Geocoding API keys directly on your command line. To do this on the root directory of the project, run the following command passing your `GEOCODE_API_KEY` and `TIMEZONE_API_KEY` as env parameters:\n    ```bash\n    GEOCODE_API_KEY=\u003cYOUR GEOCODE API KEY\u003e TIMEZONE_API_KEY=\u003cYOUR TIMEZONE API KEY\u003e node bin/run.js\n    ```\n\nIf everything is ok, the console will show the following message:\n```plaintext\nThe time micro-service is listening on http://localhost:PORT in development mode.\n```\n\nThe service will try to connect to the [bot application](https://github.com/coderade/nodejs-msb-slack-bot). If the bot application is not running, you will receive the following error message:\n```plaintext\nError connecting to Coderade Bot.\n```\n\nThe service will try to connect again every 30 seconds. If the bot application is not running yet, you will receive an error like this:\n```plaintext\n{ Error: connect ECONNREFUSED 127.0.0.1:3000\n    at Object._errnoException (util.js:1031:13)\n    at _exceptionWithHostPort (util.js:1052:20)\n    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1195:14)\n  errno: 'ECONNREFUSED',\n  code: 'ECONNREFUSED',\n  syscall: 'connect',\n  address: '127.0.0.1',\n  port: 3000,\n  response: undefined }\n```\n\n## Checking the Service\n\nThis service has been created to be used with the bot application, but you can test it using your browser by passing a LOCATION as a URL parameter with the announced URL in the first message on the console log:\n\n```plaintext\nhttp://localhost:PORT/service/\u003cLOCATION\u003e\n```\n\nFor example:\n```plaintext\nhttp://localhost:34977/service/curitiba\n```\n\nYou will receive a JSON response similar to this:\n```json\n{\n  \"result\": \"Wednesday, December 13th 2017, 9:45:46 pm\"\n}\n```\n\n## Testing\n\nThis project uses [Mocha](https://mochajs.org/), [Should](https://shouldjs.github.io/), and [Istanbul](https://istanbul.js.org/) JS libraries to test the infrastructure, the services, and the Slack and Wit clients.\n\nThe tests are in the `test` directory. To run all the tests, lint the code, and check your coverage, run the following command:\n```bash\nnpm test\n```\n\nOr directly on the root of the project, use:\n```bash\nnyc mocha --recursive test --exit\n```\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderade%2Fnodejs-time-microservice","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoderade%2Fnodejs-time-microservice","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderade%2Fnodejs-time-microservice/lists"}