{"id":13754130,"url":"https://github.com/lehoangduc/node-registrify","last_synced_at":"2025-04-08T04:34:46.598Z","repository":{"id":52270260,"uuid":"71591041","full_name":"lehoangduc/node-registrify","owner":"lehoangduc","description":"Fast, simple Service registry for Client-side service discovery in microservices system","archived":false,"fork":false,"pushed_at":"2021-05-02T11:12:42.000Z","size":15,"stargazers_count":25,"open_issues_count":0,"forks_count":3,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-23T06:41:23.238Z","etag":null,"topics":["microservice","nodejs","redis"],"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/lehoangduc.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":"2016-10-21T19:30:34.000Z","updated_at":"2025-02-26T18:05:32.000Z","dependencies_parsed_at":"2022-09-25T04:22:44.730Z","dependency_job_id":null,"html_url":"https://github.com/lehoangduc/node-registrify","commit_stats":{"total_commits":8,"total_committers":3,"mean_commits":"2.6666666666666665","dds":0.5,"last_synced_commit":"88e83c2bb84289a958ebc3c8284fd5c7cd21cc93"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lehoangduc%2Fnode-registrify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lehoangduc%2Fnode-registrify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lehoangduc%2Fnode-registrify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lehoangduc%2Fnode-registrify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lehoangduc","download_url":"https://codeload.github.com/lehoangduc/node-registrify/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247485280,"owners_count":20946398,"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","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":["microservice","nodejs","redis"],"created_at":"2024-08-03T09:01:41.348Z","updated_at":"2025-04-08T04:34:46.347Z","avatar_url":"https://github.com/lehoangduc.png","language":"JavaScript","readme":"# node-registrify\n\u003e Fast, simple Service registry for Client-side service discovery in microservices system.\n\n[![npm package](https://nodei.co/npm/node-registrify.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://nodei.co/npm/node-registrify/)\n\nThe project using Nodejs and Hapi framework with Redis for storing info.\n\n## Installation\n\n``` bash\n  $ [sudo] npm install node-registrify -g\n```\n\n## Usage\nThere are two ways to use node-registrify: through the command line or by using in your code.\n\n### Command Line Usage\nYou can use node-registrify to run scripts continuously.\n\n**Example**\n```\nnode-registry --server-host localhost --server-port 8000\n```\n\n**Options**\n```\n  $ node-registrify --help\n  Usage: node-registrify [options]\n  \n  options:\n  -h, --help                 output usage information\n  -V, --version              output the version number\n  --server-host [value]      Host on which to listen to (defaults to localhost)\n  --server-port [value]      Port on which to listen to (defaults to 8000)\n  --redis-host [value]       Redis host (defaults to localhost)\n  --redis-port [value]       Redis port (defaults to 6379)\n  --redis-db [value]         Redis db (defaults to 0)\n  --log-level [value]        Log level (defaults to \"info\")\n  --log-max-entries [value]  Log max entries for a service (defaults to 10)\n```\n\n### Using In Your Code\n``` js\nconst NodeRegistrify = require('node-registrify');\n\nNodeRegistrify.init({\n  api_host:   'localhost',\n  api_port:   '8000',\n  redis_host: 'localhost',\n  redis_port: '6379',\n  redis_db:   0,\n  log_level: 'info',\n  log_max_entries: 10\n});\n\nNodeRegistrify.run();\n```\n\n## REST APIs\n\n#### Ping\n```\ncurl -XGET /ping\n```\n\n#### Register a service\n```\ncurl -XPUT -F \"\u003cmeta_key\u003e=\u003cmeta_value\u003e\"... /services/\u003cservice_name\u003e/\u003chost_name\u003e\n```\n\n* Example Client PHP codes (with [guzzlehttp/guzzle](https://github.com/guzzle/guzzle)):\n```php\n\n$client = new HttpClient([\n\t'base_uri' =\u003e self::$serviceUrl,\n\t'timeout'  =\u003e self::REQUEST_TIMEOUT_SECONDS\n]);\n\n$client-\u003eput(sprintf('/services/%s/%s', $service, gethostname()), [\n\t'form_params' =\u003e [\n\t    'id' =\u003e 'redis',\n\t\t'pid' =\u003e getmypid(),\n\t\t'ip' =\u003e '192.168.1.2',\n\t\t'port' =\u003e 6379\n\t]\n]);\n\n```\n\n#### Delete a service\n```\ncurl -XDELETE /services/\u003cservice_name\u003e/\u003chost_name\u003e\n```\n\n* Example Client PHP codes (with [guzzlehttp/guzzle](https://github.com/guzzle/guzzle)):\n```php\n\n$client = new HttpClient([\n\t'base_uri' =\u003e self::$serviceUrl,\n\t'timeout'  =\u003e self::REQUEST_TIMEOUT_SECONDS\n]);\n\n$client-\u003edelete(sprintf('/services/%s/%s', $service, gethostname()));\n\n```\n\n#### Send log to a service\n```\ncurl -XPOST -H \"Content-Type: text/html\" -d \"this is a log\" /services/\u003cservice_name\u003e/\u003chost_name\u003e/log\n```\n\n* Example Client PHP codes (with [guzzlehttp/guzzle](https://github.com/guzzle/guzzle)):\n```php\n\n$client = new HttpClient([\n\t'base_uri' =\u003e self::$serviceUrl,\n\t'timeout'  =\u003e self::REQUEST_TIMEOUT_SECONDS\n]);\n\n$client-\u003epost(sprintf('/services/%s/%s/log', $service, gethostname()), [\n\t'headers' =\u003e [\n\t\t'Content-type' =\u003e 'text/html; charset=utf-8',\n\t],\n\t'body' =\u003e $message\n]);\n```\n\n#### List all services\n```\ncurl -XGET /services\n```\n\n#### List all hosts\n```\ncurl -XGET /hosts\n```\n\n#### List all services in given host\n```\ncurl -XGET /services/\u003chost_name\u003e/services\n```\n\n#### Get info of given service in a host\n```\ncurl -XGET /services/\u003cservice_name\u003e/\u003chost_name\u003e\n```\n\n#### Get info of given service\n```\ncurl -XGET /services/\u003cservice_name\u003e\n```\n\n#### List all hosts in given service\n```\ncurl -XGET /services/\u003cservice_name\u003e/hosts\n```\n\n#### List all logs in given service\n```\ncurl -XGET /services/\u003cservice_name\u003e/\u003chost_name\u003e/logs\n```\n","funding_links":[],"categories":["redis"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flehoangduc%2Fnode-registrify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flehoangduc%2Fnode-registrify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flehoangduc%2Fnode-registrify/lists"}