Skip to content

Commit a57bb57

Browse files
committed
initial commit
0 parents  commit a57bb57

25 files changed

+5284
-0
lines changed

.editorconfig

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
insert_final_newline = true
6+
trim_trailing_whitespace = true
7+
charset = utf-8
8+
9+
[*.js]
10+
indent_style = space
11+
indent_size = 2
12+
13+
[{package.json,*.yml,*.cjson}]
14+
indent_style = space
15+
indent_size = 2

.eslintignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
coverage
3+
dist

.eslintrc

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": ["eslint-config-unjs"],
3+
"rules": {
4+
"unicorn/consistent-function-scoping": 0
5+
}
6+
}

.github/workflows/autofix.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: autofix.ci # needed to securely identify the workflow
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: ["main"]
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
autofix:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v3
16+
- run: corepack enable
17+
- uses: actions/setup-node@v3
18+
with:
19+
node-version: 18
20+
cache: "pnpm"
21+
- run: pnpm install
22+
- name: Fix lint issues
23+
run: pnpm run lint:fix
24+
- uses: autofix-ci/action@8caa572fd27b0019a65e4c695447089c8d3138b9
25+
with:
26+
commit-message: "chore: apply automated lint fixes"

.github/workflows/ci.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: ci
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
ci:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v3
16+
- run: corepack enable
17+
- uses: actions/setup-node@v3
18+
with:
19+
node-version: 18
20+
cache: "pnpm"
21+
- run: pnpm install
22+
- run: pnpm lint
23+
- run: pnpm typecheck
24+
- run: pnpm build
25+
# - run: pnpm vitest --coverage
26+
# - uses: codecov/codecov-action@v3

.gitignore

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
node_modules
2+
coverage
3+
dist
4+
types
5+
.vscode
6+
.DS_Store
7+
.eslintcache
8+
*.log*
9+
*.conf*
10+
*.env*

.prettierrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

LICENSE

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
MIT License
2+
3+
Copyright (c) Pooya Parsa <[email protected]>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+
23+
----
24+
25+
cloudflared forked from https://github.com/JacobLinCool/node-cloudflared/
26+
27+
MIT License
28+
29+
Copyright (c) 2022 JacobLinCool
30+
31+
Permission is hereby granted, free of charge, to any person obtaining a copy
32+
of this software and associated documentation files (the "Software"), to deal
33+
in the Software without restriction, including without limitation the rights
34+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
35+
copies of the Software, and to permit persons to whom the Software is
36+
furnished to do so, subject to the following conditions:
37+
38+
The above copyright notice and this permission notice shall be included in all
39+
copies or substantial portions of the Software.
40+
41+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
42+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
43+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
44+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
45+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
46+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
47+
SOFTWARE.

README.md

+121
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# 🚇 untun
2+
3+
[![npm version][npm-version-src]][npm-version-href]
4+
[![npm downloads][npm-downloads-src]][npm-downloads-href]
5+
[![bundle][bundle-src]][bundle-href]
6+
7+
[![License][license-src]][license-href]
8+
9+
Tunnel your local HTTP(s) server to the world!
10+
11+
Powered by 🔥 [Cloudflare Quick Tunnels](https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/do-more-with-tunnels/trycloudflare/) and used by 👂 [unjs/listhen](https://github.com/unjs/listhen)!
12+
13+
## Usage (CLI)
14+
15+
Globally run tunnel with `npx`:
16+
17+
```sh
18+
npx untun@latest tunnel http://localhost:3000
19+
```
20+
21+
```
22+
◐ Starting cloudflared tunnel to http://localhost:3000
23+
ℹ Waiting for tunnel URL...
24+
✔ Tunnel ready at https://unjs-is-awesome.trycloudflare.com
25+
```
26+
27+
Use `npx untun tunnel --help` for more usage info.
28+
29+
## Usage (API)
30+
31+
Install package:
32+
33+
```sh
34+
# npm
35+
npm install untun
36+
37+
# yarn
38+
yarn add untun
39+
40+
# pnpm
41+
pnpm install untun
42+
```
43+
44+
Import:
45+
46+
```ts
47+
// ESM
48+
import { startTunnel } from "untun";
49+
50+
// CommonJS
51+
const { startTunnel } = require("untun");
52+
```
53+
54+
Start tunnel:
55+
56+
```ts
57+
const tunnel = await startTunnel({ port: 3000 });
58+
```
59+
60+
## Options
61+
62+
### `url`
63+
64+
- Default: `{protocol}://{hostname}:{port}`
65+
66+
The local server URL to tunnel.
67+
68+
### `port`
69+
70+
- Default: `3000`
71+
72+
The local server PORT (only effective if `url` is not provided).
73+
74+
### `hostname`
75+
76+
- Default: `localhost`
77+
78+
The local server hostname (only effective if `url` is not provided).
79+
80+
### `protocol`
81+
82+
- Default: `http`
83+
84+
The local server protocol (only effective if `url` is not provided).
85+
86+
### `verifyTLS`
87+
88+
- Default: `false`
89+
90+
Verify local server TLS certificate.
91+
92+
## Development
93+
94+
- Clone this repository
95+
- Install latest LTS version of [Node.js](https://nodejs.org/en/)
96+
- Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable`
97+
- Install dependencies using `pnpm install`
98+
- Run interactive tests using `pnpm dev`
99+
100+
## License
101+
102+
Made with 💛
103+
104+
Published under [MIT License](./LICENSE).
105+
106+
cloudflared integration based on a fork of [JacobLinCool/node-cloudflared](https://github.com/JacobLinCool/node-cloudflared)
107+
108+
Your installation of cloudflared software constitutes a symbol of your signature indicating that you accept the terms of the Cloudflare [License](https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/downloads/license/), [Terms](https://www.cloudflare.com/terms/) and [Privacy Policy](https://www.cloudflare.com/privacypolicy/).
109+
110+
<!-- Badges -->
111+
112+
[npm-version-src]: https://img.shields.io/npm/v/untun?style=flat&colorA=18181B&colorB=F0DB4F
113+
[npm-version-href]: https://npmjs.com/package/untun
114+
[npm-downloads-src]: https://img.shields.io/npm/dm/untun?style=flat&colorA=18181B&colorB=F0DB4F
115+
[npm-downloads-href]: https://npmjs.com/package/untun
116+
[codecov-src]: https://img.shields.io/codecov/c/gh/unjs/untun/main?style=flat&colorA=18181B&colorB=F0DB4F
117+
[codecov-href]: https://codecov.io/gh/unjs/untun
118+
[bundle-src]: https://img.shields.io/bundlephobia/minzip/untun?style=flat&colorA=18181B&colorB=F0DB4F
119+
[bundle-href]: https://bundlephobia.com/result?p=untun
120+
[license-src]: https://img.shields.io/github/license/unjs/untun.svg?style=flat&colorA=18181B&colorB=F0DB4F
121+
[license-href]: https://github.com/unjs/untun/blob/main/LICENSE

bin/untun.mjs

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env node
2+
3+
import { runMain } from "../dist/cli.mjs";
4+
5+
runMain();

package.json

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"name": "untun",
3+
"version": "0.1.0",
4+
"description": "Tunnel your local HTTP(s) server to the world! Powered by Cloudflare Quick Tunnels",
5+
"repository": "unjs/untun",
6+
"license": "MIT",
7+
"sideEffects": false,
8+
"type": "module",
9+
"exports": {
10+
".": {
11+
"types": "./dist/index.d.ts",
12+
"import": "./dist/index.mjs",
13+
"require": "./dist/index.cjs"
14+
},
15+
"./cli": {
16+
"types": "./dist/cli.d.ts",
17+
"import": "./dist/cli.mjs",
18+
"require": "./dist/cli.cjs"
19+
}
20+
},
21+
"main": "./dist/index.cjs",
22+
"module": "./dist/index.mjs",
23+
"types": "./dist/index.d.ts",
24+
"files": [
25+
"dist",
26+
"bin"
27+
],
28+
"scripts": {
29+
"build": "unbuild",
30+
"dev": "vitest dev",
31+
"lint": "eslint --cache --ext .ts,.js,.mjs,.cjs . && prettier -c src test",
32+
"lint:fix": "eslint --cache --ext .ts,.js,.mjs,.cjs . --fix && prettier -c src test -w",
33+
"prepack": "pnpm run build",
34+
"release": "pnpm test && changelogen --release && npm publish && git push --follow-tags",
35+
"typecheck": "tsc --noEmit",
36+
"test": "pnpm lint &&pnpm typecheck && vitest run --coverage",
37+
"untun": "jiti ./scripts/untun.mjs"
38+
},
39+
"dependencies": {
40+
"citty": "^0.1.2",
41+
"consola": "^3.2.3",
42+
"pathe": "^1.1.1"
43+
},
44+
"devDependencies": {
45+
"@types/node": "^20.4.10",
46+
"@vitest/coverage-v8": "^0.34.1",
47+
"changelogen": "^0.5.4",
48+
"eslint": "^8.47.0",
49+
"eslint-config-unjs": "^0.2.1",
50+
"jiti": "^1.19.1",
51+
"prettier": "^3.0.1",
52+
"typescript": "^5.1.6",
53+
"unbuild": "^1.2.1",
54+
"vitest": "^0.34.1"
55+
},
56+
"packageManager": "[email protected]"
57+
}

0 commit comments

Comments
 (0)