@stacksjs/rpx 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +173 -0
- package/dist/cli.js +254754 -0
- package/dist/config.d.ts +3 -0
- package/dist/https.d.ts +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +57188 -0
- package/dist/start.d.ts +14 -0
- package/dist/types.d.ts +24 -0
- package/dist/utils.d.ts +1 -0
- package/package.json +82 -0
package/README.md
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
<p align="center"><img src="https://github.com/stacksjs/rpx/blob/main/.github/art/cover.jpg?raw=true" alt="Social Card of this repo"></p>
|
|
2
|
+
|
|
3
|
+
[![npm version][npm-version-src]][npm-version-href]
|
|
4
|
+
[![GitHub Actions][github-actions-src]][github-actions-href]
|
|
5
|
+
[](http://commitizen.github.io/cz-cli/)
|
|
6
|
+
<!-- [![npm downloads][npm-downloads-src]][npm-downloads-href] -->
|
|
7
|
+
<!-- [![Codecov][codecov-src]][codecov-href] -->
|
|
8
|
+
|
|
9
|
+
# A Better Developer Experience
|
|
10
|
+
|
|
11
|
+
> A zero-config reverse proxy for local development with SSL support, custom domains, and more.
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- Simple, lightweight Reverse Proxy
|
|
16
|
+
- Custom Domains _(with wildcard support)_
|
|
17
|
+
- Zero-Config Setup
|
|
18
|
+
- SSL Support _(HTTPS by default)_
|
|
19
|
+
- Auto HTTP-to-HTTPS Redirection
|
|
20
|
+
|
|
21
|
+
## Install
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
bun install -d @stacksjs/rpx
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
<!-- _Alternatively, you can install:_
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
brew install rpx # wip
|
|
31
|
+
pkgx install rpx # wip
|
|
32
|
+
``` -->
|
|
33
|
+
|
|
34
|
+
## Get Started
|
|
35
|
+
|
|
36
|
+
There are two ways of using this reverse proxy: _as a library or as a CLI._
|
|
37
|
+
|
|
38
|
+
### Library
|
|
39
|
+
|
|
40
|
+
Given the npm package is installed:
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
import type { TlsConfig } from '@stacksjs/rpx'
|
|
44
|
+
import { startProxy } from '@stacksjs/rpx'
|
|
45
|
+
|
|
46
|
+
export interface ReverseProxyConfig {
|
|
47
|
+
from: string // domain to proxy from, defaults to localhost:3000
|
|
48
|
+
to: string // domain to proxy to, defaults to stacks.localhost
|
|
49
|
+
https: TlsConfig // use https, defaults to true, also redirects http to https
|
|
50
|
+
verbose: boolean // log verbose output, defaults to false
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const config: ReverseProxyOptions = {
|
|
54
|
+
from: 'localhost:3000',
|
|
55
|
+
to: 'my-project.localhost',
|
|
56
|
+
https: {
|
|
57
|
+
keyPath: './key.pem',
|
|
58
|
+
certPath: './cert.pem',
|
|
59
|
+
caCertPath: './ca.pem',
|
|
60
|
+
},
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
startProxy(config)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### CLI
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
reverse-proxy --from localhost:3000 --to my-project.localhost
|
|
70
|
+
reverse-proxy --from localhost:8080 --to my-project.test --keyPath ./key.pem --certPath ./cert.pem
|
|
71
|
+
reverse-proxy --help
|
|
72
|
+
reverse-proxy --version
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Configuration
|
|
76
|
+
|
|
77
|
+
The Reverse Proxy can be configured using a `reverse-proxy.config.ts` _(or `reverse-proxy.config.js`)_ file and it will be automatically loaded when running the `reverse-proxy` command.
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
// reverse-proxy.config.{ts,js}
|
|
81
|
+
import type { ReverseProxyOptions } from './src/types'
|
|
82
|
+
import os from 'node:os'
|
|
83
|
+
import path from 'node:path'
|
|
84
|
+
|
|
85
|
+
const config: ReverseProxyOptions = {
|
|
86
|
+
from: 'localhost:5173',
|
|
87
|
+
to: 'stacks.localhost',
|
|
88
|
+
https: {
|
|
89
|
+
domain: 'stacks.localhost',
|
|
90
|
+
hostCertCN: 'stacks.localhost',
|
|
91
|
+
caCertPath: path.join(os.homedir(), '.stacks', 'ssl', `stacks.localhost.ca.crt`),
|
|
92
|
+
certPath: path.join(os.homedir(), '.stacks', 'ssl', `stacks.localhost.crt`),
|
|
93
|
+
keyPath: path.join(os.homedir(), '.stacks', 'ssl', `stacks.localhost.crt.key`),
|
|
94
|
+
altNameIPs: ['127.0.0.1'],
|
|
95
|
+
altNameURIs: ['localhost'],
|
|
96
|
+
organizationName: 'stacksjs.org',
|
|
97
|
+
countryName: 'US',
|
|
98
|
+
stateName: 'California',
|
|
99
|
+
localityName: 'Playa Vista',
|
|
100
|
+
commonName: 'stacks.localhost',
|
|
101
|
+
validityDays: 180,
|
|
102
|
+
verbose: false,
|
|
103
|
+
},
|
|
104
|
+
verbose: false,
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export default config
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
_Then run:_
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
./rpx start
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
To learn more, head over to the [documentation](https://reverse-proxy.sh/).
|
|
117
|
+
|
|
118
|
+
## Testing
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
bun test
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Changelog
|
|
125
|
+
|
|
126
|
+
Please see our [releases](https://github.com/stacksjs/stacks/releases) page for more information on what has changed recently.
|
|
127
|
+
|
|
128
|
+
## Contributing
|
|
129
|
+
|
|
130
|
+
Please review the [Contributing Guide](https://github.com/stacksjs/contributing) for details.
|
|
131
|
+
|
|
132
|
+
## Community
|
|
133
|
+
|
|
134
|
+
For help, discussion about best practices, or any other conversation that would benefit from being searchable:
|
|
135
|
+
|
|
136
|
+
[Discussions on GitHub](https://github.com/stacksjs/stacks/discussions)
|
|
137
|
+
|
|
138
|
+
For casual chit-chat with others using this package:
|
|
139
|
+
|
|
140
|
+
[Join the Stacks Discord Server](https://discord.gg/stacksjs)
|
|
141
|
+
|
|
142
|
+
## Postcardware
|
|
143
|
+
|
|
144
|
+
Two things are true: Stacks OSS will always stay open-source, and we do love to receive postcards from wherever Stacks is used! 🌍 _We also publish them on our website. And thank you, Spatie_
|
|
145
|
+
|
|
146
|
+
Our address: Stacks.js, 12665 Village Ln #2306, Playa Vista, CA 90094
|
|
147
|
+
|
|
148
|
+
## Sponsors
|
|
149
|
+
|
|
150
|
+
We would like to extend our thanks to the following sponsors for funding Stacks development. If you are interested in becoming a sponsor, please reach out to us.
|
|
151
|
+
|
|
152
|
+
- [JetBrains](https://www.jetbrains.com/)
|
|
153
|
+
- [The Solana Foundation](https://solana.com/)
|
|
154
|
+
|
|
155
|
+
## Credits
|
|
156
|
+
|
|
157
|
+
- [Chris Breuer](https://github.com/chrisbbreuer)
|
|
158
|
+
- [All Contributors](../../contributors)
|
|
159
|
+
|
|
160
|
+
## License
|
|
161
|
+
|
|
162
|
+
The MIT License (MIT). Please see [LICENSE](https://github.com/stacksjs/stacks/tree/main/LICENSE.md) for more information.
|
|
163
|
+
|
|
164
|
+
Made with 💙
|
|
165
|
+
|
|
166
|
+
<!-- Badges -->
|
|
167
|
+
[npm-version-src]: https://img.shields.io/npm/v/@stacksjs/rpx?style=flat-square
|
|
168
|
+
[npm-version-href]: https://npmjs.com/package/@stacksjs/rpx
|
|
169
|
+
[github-actions-src]: https://img.shields.io/github/actions/workflow/status/stacksjs/rpx/ci.yml?style=flat-square&branch=main
|
|
170
|
+
[github-actions-href]: https://github.com/stacksjs/rpx/actions?query=workflow%3Aci
|
|
171
|
+
|
|
172
|
+
<!-- [codecov-src]: https://img.shields.io/codecov/c/gh/stacksjs/rpx/main?style=flat-square
|
|
173
|
+
[codecov-href]: https://codecov.io/gh/stacksjs/rpx -->
|