{"id":24617704,"url":"https://github.com/jacoblincool/node-cloudflared","last_synced_at":"2025-04-12T22:36:12.591Z","repository":{"id":49325249,"uuid":"517294914","full_name":"JacobLinCool/node-cloudflared","owner":"JacobLinCool","description":"Cloudflared in Node. Create HTTPS tunnel in 10 seconds. Works on macOS, Linux, and Windows.","archived":false,"fork":false,"pushed_at":"2025-02-12T11:39:07.000Z","size":332,"stargazers_count":80,"open_issues_count":1,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-04T07:17:27.026Z","etag":null,"topics":["cloudflared","nodejs"],"latest_commit_sha":null,"homepage":"https://jacoblincool.github.io/node-cloudflared","language":"TypeScript","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/JacobLinCool.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2022-07-24T10:42:28.000Z","updated_at":"2025-03-28T15:54:19.000Z","dependencies_parsed_at":"2024-06-18T20:08:43.319Z","dependency_job_id":"e5c32c06-dd50-47c9-ab40-25b7111a9d9c","html_url":"https://github.com/JacobLinCool/node-cloudflared","commit_stats":{"total_commits":97,"total_committers":5,"mean_commits":19.4,"dds":0.08247422680412375,"last_synced_commit":"9681e9cc444bd9e0c257ec95702429c4838786cb"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JacobLinCool%2Fnode-cloudflared","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JacobLinCool%2Fnode-cloudflared/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JacobLinCool%2Fnode-cloudflared/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JacobLinCool%2Fnode-cloudflared/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JacobLinCool","download_url":"https://codeload.github.com/JacobLinCool/node-cloudflared/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248642764,"owners_count":21138352,"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":["cloudflared","nodejs"],"created_at":"2025-01-24T23:40:03.401Z","updated_at":"2025-04-12T22:36:12.573Z","avatar_url":"https://github.com/JacobLinCool.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cloudflared\n\nA Node.js package that allows you to easily create HTTPS tunnels using Cloudflare's `cloudflared` command-line tool. It provides a typed API for creating tunnels and managing the `cloudflared` binary installation.\n\n\u003e This tool will automatically install the [latest version of `cloudflared`](https://github.com/cloudflare/cloudflared/releases/latest) (or `CLOUDFLARED_VERSION` env var if exists) at the first time.\n\u003e Then, it just passes down the command to `cloudflared`.\n\n## Installation\n\nYou can install this package using your favorite package manager:\n\n### PNPM\n\n```sh\npnpm i -g cloudflared\n```\n\n### NPM\n\n```sh\nnpm i -g cloudflared\n```\n\n### Yarn\n\n```sh\nyarn global add cloudflared\n```\n\n\u003e If `CLOUDFLARED_VERSION` env var is set, it will install the specified version of `cloudflared`, otherwise it will install the latest version.\n\n## CLI Usage\n\nYou can use the `cloudflared` command-line tool to create HTTPS tunnels. You can find the usage of `cloudflared` [here](https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/tunnel-useful-commands/).\n\nIn addition to the standard `cloudflared` commands, this package also provides an extra subcommand: `cloudflared bin`. You can use it to manage the `cloudflared` binary version.\n\n```sh\n❯ cloudflared bin --help\ncloudflared bin                    : Prints the path to the binary\ncloudflared bin remove             : Removes the binary\ncloudflared bin install [version]  : Installs the binary\ncloudflared bin list               : Lists 30 latest releases\ncloudflared bin help               : Prints this help message\nExamples:\ncloudflared bin install            : Installs the latest version of cloudflared\ncloudflared bin install 2023.4.1   : Installs cloudflared 2023.4.1\nYou can find releases at https://github.com/cloudflare/cloudflared/releases\n```\n\n## Library Usage\n\nYou can also use it as a library in your TypeScript / JavaScript projects.\n\n### Binary Path \u0026 Install\n\nYou can get the path of the `cloudflared` binary and install it using the `bin` and `install` functions, respectively.\n\n```js\nimport { bin, install } from \"cloudflared\";\nimport fs from \"node:fs\";\nimport { spawn } from \"node:child_process\";\n\nif (!fs.existsSync(bin)) {\n  // install cloudflared binary\n  await install(bin);\n}\n\n// run cloudflared\nspawn(bin, [\"--version\"], { stdio: \"inherit\" });\n```\n\n- `bin`: The path of the binary.\n- `install`: A function that installs the binary to the given path.\n\n### Tunnel\n\nCheckout [`examples/tunnel.js`](examples/tunnel.js).\n\n`Tunnel` is inherited from `EventEmitter`, so you can listen to the events it emits, checkout [`examples/events.mjs`](examples/events.mjs).\n\n```js\nimport { Tunnel } from \"cloudflared\";\n\nconsole.log(\"Cloudflared Tunnel Example.\");\nmain();\n\nasync function main() {\n  // run: cloudflared tunnel --hello-world\n  const tunnel = Tunnel.quick();\n\n  // show the url\n  const url = new Promise((resolve) =\u003e tunnel.once(\"url\", resolve));\n  console.log(\"LINK:\", await url);\n\n  // wait for connection to be established\n  const conn = new Promise((resolve) =\u003e tunnel.once(\"connected\", resolve));\n  console.log(\"CONN:\", await conn);\n\n  // stop the tunnel after 15 seconds\n  setTimeout(tunnel.stop, 15_000);\n\n  tunnel.on(\"exit\", (code) =\u003e {\n    console.log(\"tunnel process exited with code\", code);\n  });\n}\n```\n\n```sh\n❯ node examples/tunnel.js\nCloudflared Tunnel Example.\nLINK: https://mailto-davis-wilderness-facts.trycloudflare.com\nCONN: {\n  id: 'df1b8330-44ea-4ecb-bb93-8a32400f6d1c',\n  ip: '198.41.200.193',\n  location: 'tpe01'\n}\ntunnel process exited with code 0\n```\n\n### Service\n\nCheckout [`examples/service.js`](examples/service.js).\n\n```js\nimport { service } from \"cloudflared\";\n\nconsole.log(\"Cloudflared Service Example.\");\nmain();\n\nasync function main() {\n  if (service.exists()) {\n    console.log(\"Service is running.\");\n    const current = service.current();\n    for (const { service, hostname } of current.config.ingress) {\n      console.log(`  - ${service} -\u003e ${hostname}`);\n    }\n    console.log(\"metrics server:\", current.metrics);\n  } else {\n    console.log(\"Service is not running.\");\n  }\n}\n```\n\n```sh\n❯ node examples/service.js\nCloudflared Service Example.\nService is running.\n  - http://localhost:12345 -\u003e sub.example.com\n  - http_status:404 -\u003e undefined\nmetrics server: 127.0.0.1:49177/metrics\n```\n\nNOTICE: On linux, service can only be installed and uninstalled by root.\n\nRun service test on linux: `sudo -E env \"PATH=$PATH\" pnpm test`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacoblincool%2Fnode-cloudflared","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjacoblincool%2Fnode-cloudflared","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacoblincool%2Fnode-cloudflared/lists"}