orator-http-proxy 1.0.1 → 1.0.4
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/CONTRIBUTING.md +50 -0
- package/README.md +109 -3
- package/docs/.nojekyll +0 -0
- package/docs/README.md +67 -0
- package/docs/_sidebar.md +8 -0
- package/docs/configuration.md +87 -0
- package/docs/cover.md +11 -0
- package/docs/css/docuserve.css +73 -0
- package/docs/getting-started.md +106 -0
- package/docs/index.html +39 -0
- package/docs/retold-catalog.json +41 -0
- package/docs/retold-keyword-index.json +19 -0
- package/package.json +6 -6
- package/source/Orator-HTTP-Proxy.js +1 -1
- package/test/Orator-HTTP-Proxy_tests.js +1003 -0
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Contributing to Retold
|
|
2
|
+
|
|
3
|
+
We welcome contributions to Retold and its modules. This guide covers the expectations and process for contributing.
|
|
4
|
+
|
|
5
|
+
## Code of Conduct
|
|
6
|
+
|
|
7
|
+
The Retold community values **empathy**, **equity**, **kindness**, and **thoughtfulness**. We expect all participants to treat each other with respect, assume good intent, and engage constructively. These values apply to all interactions: pull requests, issues, discussions, and code review.
|
|
8
|
+
|
|
9
|
+
## How to Contribute
|
|
10
|
+
|
|
11
|
+
### Pull Requests
|
|
12
|
+
|
|
13
|
+
Pull requests are the preferred method for contributing changes. To submit one:
|
|
14
|
+
|
|
15
|
+
1. Fork the module repository you want to change
|
|
16
|
+
2. Create a branch for your work
|
|
17
|
+
3. Make your changes, following the code style of the module you are editing
|
|
18
|
+
4. Ensure your changes have test coverage (see below)
|
|
19
|
+
5. Open a pull request against the module's main branch
|
|
20
|
+
|
|
21
|
+
**Submitting a pull request does not guarantee it will be accepted.** Maintainers review contributions for fit, quality, and alignment with the project's direction. A PR may be declined, or you may be asked to revise it. This is normal and not a reflection on the quality of your effort.
|
|
22
|
+
|
|
23
|
+
### Reporting Issues
|
|
24
|
+
|
|
25
|
+
If you find a bug or have a feature suggestion, open an issue on the relevant module's repository. Include enough detail to reproduce the problem or understand the proposal.
|
|
26
|
+
|
|
27
|
+
## Test Coverage
|
|
28
|
+
|
|
29
|
+
Every commit must include test coverage for the changes it introduces. Retold modules use Mocha in TDD style. Before submitting:
|
|
30
|
+
|
|
31
|
+
- **Write tests** for any new functionality or bug fixes
|
|
32
|
+
- **Run the existing test suite** with `npm test` and confirm all tests pass
|
|
33
|
+
- **Check coverage** with `npm run coverage` if the module supports it
|
|
34
|
+
|
|
35
|
+
Pull requests that break existing tests or lack coverage for new code will not be merged.
|
|
36
|
+
|
|
37
|
+
## Code Style
|
|
38
|
+
|
|
39
|
+
Follow the conventions of the module you are working in. The general Retold style is:
|
|
40
|
+
|
|
41
|
+
- **Tabs** for indentation, never spaces
|
|
42
|
+
- **Plain JavaScript** only (no TypeScript)
|
|
43
|
+
- **Allman-style braces** (opening brace on its own line)
|
|
44
|
+
- **Variable naming:** `pVariable` for parameters, `tmpVariable` for temporaries, `libSomething` for imports
|
|
45
|
+
|
|
46
|
+
When in doubt, match what the surrounding code does.
|
|
47
|
+
|
|
48
|
+
## Repository Structure
|
|
49
|
+
|
|
50
|
+
Each module is its own git repository. The [retold](https://github.com/stevenvelozo/retold) repository tracks module organization but does not contain module source code. Direct your pull request to the specific module repository where your change belongs.
|
package/README.md
CHANGED
|
@@ -1,5 +1,111 @@
|
|
|
1
|
-
# Orator
|
|
1
|
+
# Orator HTTP Proxy
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> HTTP proxy pass-through for Orator service servers
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Orator HTTP Proxy provides a simple way to forward incoming requests to a backend service. Register route prefixes that should be proxied, point them at a destination URL, and the module handles the rest. This is useful for microservice architectures where a frontend server needs to proxy API calls to a separate backend service.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Route-Based Proxying** - Proxy specific route prefixes to a destination URL
|
|
10
|
+
- **Multi-Verb Support** - Proxies GET, PUT, POST, and DELETE requests
|
|
11
|
+
- **Configurable** - Settings via constructor options or Fable settings
|
|
12
|
+
- **HTTP-to-HTTPS** - Handles proxying from HTTP origins to HTTPS destinations
|
|
13
|
+
- **Fable Service Provider** - Registers as a standard Fable service
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
```javascript
|
|
18
|
+
const libFable = require('fable');
|
|
19
|
+
const libOrator = require('orator');
|
|
20
|
+
const libOratorServiceServerRestify = require('orator-serviceserver-restify');
|
|
21
|
+
const libOratorHTTPProxy = require('orator-http-proxy');
|
|
22
|
+
|
|
23
|
+
const _Fable = new libFable({
|
|
24
|
+
Product: 'MyProxyServer',
|
|
25
|
+
ServicePort: 8080
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// Set up Orator with Restify
|
|
29
|
+
_Fable.serviceManager.addServiceType('Orator', libOrator);
|
|
30
|
+
_Fable.serviceManager.addServiceType('OratorServiceServer', libOratorServiceServerRestify);
|
|
31
|
+
_Fable.serviceManager.instantiateServiceProvider('Orator');
|
|
32
|
+
_Fable.serviceManager.instantiateServiceProvider('OratorServiceServer');
|
|
33
|
+
|
|
34
|
+
// Set up the proxy
|
|
35
|
+
_Fable.serviceManager.addServiceType('OratorHTTPProxy', libOratorHTTPProxy);
|
|
36
|
+
_Fable.serviceManager.instantiateServiceProvider('OratorHTTPProxy',
|
|
37
|
+
{
|
|
38
|
+
DestinationURL: 'http://backend-api:3000/',
|
|
39
|
+
RequestPrefixList: ['/api/v1/*']
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// Initialize Orator and connect proxy routes
|
|
43
|
+
_Fable.Orator.initialize(
|
|
44
|
+
() =>
|
|
45
|
+
{
|
|
46
|
+
_Fable.OratorHTTPProxy.connectProxyRoutes();
|
|
47
|
+
_Fable.Orator.startService();
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Installation
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npm install orator-http-proxy
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Configuration
|
|
58
|
+
|
|
59
|
+
| Setting | Type | Default | Description |
|
|
60
|
+
|---------|------|---------|-------------|
|
|
61
|
+
| `DestinationURL` | string | `"http://127.0.0.1/"` | URL to proxy requests to |
|
|
62
|
+
| `RequestPrefixList` | array | `["/1.0/*"]` | Route prefixes to intercept and proxy |
|
|
63
|
+
| `LogLevel` | number | `0` | Logging verbosity (higher = more output) |
|
|
64
|
+
| `httpProxyOptions` | object | `{}` | Additional options passed to `http-proxy` |
|
|
65
|
+
|
|
66
|
+
Settings can also be provided via Fable settings:
|
|
67
|
+
|
|
68
|
+
| Fable Setting | Maps To |
|
|
69
|
+
|---------------|---------|
|
|
70
|
+
| `OratorHTTPProxyDestinationURL` | `DestinationURL` |
|
|
71
|
+
| `OratorHTTPProxyRequestPrefixList` | `RequestPrefixList` |
|
|
72
|
+
| `OratorHTTPProxyLogLevel` | `LogLevel` |
|
|
73
|
+
|
|
74
|
+
## API
|
|
75
|
+
|
|
76
|
+
### connectProxyRoutes(pRequestPrefixList, pProxyURL)
|
|
77
|
+
|
|
78
|
+
Create proxy handlers for the specified route prefixes. Both parameters are optional and fall back to the configured defaults.
|
|
79
|
+
|
|
80
|
+
```javascript
|
|
81
|
+
// Use configured defaults
|
|
82
|
+
_Fable.OratorHTTPProxy.connectProxyRoutes();
|
|
83
|
+
|
|
84
|
+
// Override at call time
|
|
85
|
+
_Fable.OratorHTTPProxy.connectProxyRoutes(
|
|
86
|
+
['/api/*', '/data/*'],
|
|
87
|
+
'http://other-backend:4000/'
|
|
88
|
+
);
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Documentation
|
|
92
|
+
|
|
93
|
+
Full documentation is available in the [`docs`](./docs) folder, or served locally:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
npx docsify-cli serve docs
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Related Packages
|
|
100
|
+
|
|
101
|
+
- [orator](https://github.com/stevenvelozo/orator) - API server abstraction
|
|
102
|
+
- [orator-serviceserver-restify](https://github.com/stevenvelozo/orator-serviceserver-restify) - Restify service server implementation
|
|
103
|
+
- [fable](https://github.com/stevenvelozo/fable) - Application services framework
|
|
104
|
+
|
|
105
|
+
## License
|
|
106
|
+
|
|
107
|
+
MIT
|
|
108
|
+
|
|
109
|
+
## Contributing
|
|
110
|
+
|
|
111
|
+
Pull requests are welcome. For details on our code of conduct, contribution process, and testing requirements, see the [Retold Contributing Guide](https://github.com/stevenvelozo/retold/blob/main/docs/contributing.md).
|
package/docs/.nojekyll
ADDED
|
File without changes
|
package/docs/README.md
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Orator HTTP Proxy
|
|
2
|
+
|
|
3
|
+
> HTTP proxy pass-through for Orator service servers
|
|
4
|
+
|
|
5
|
+
Orator HTTP Proxy is a Fable service that forwards incoming requests matching specified route prefixes to a backend destination URL. It uses the [http-proxy](https://github.com/http-party/node-http-proxy) library under the hood.
|
|
6
|
+
|
|
7
|
+
This is a common pattern in microservice architectures: a frontend Orator server handles static files and client-facing routes, while proxying API calls to a separate backend service. Instead of configuring a reverse proxy at the infrastructure level, you can handle it right in your application.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- **Route-Based Proxying** - Proxy specific route prefixes to a destination URL
|
|
12
|
+
- **Multi-Verb Support** - Proxies GET, PUT, POST, and DELETE requests
|
|
13
|
+
- **Configurable** - Settings via constructor options or Fable settings
|
|
14
|
+
- **HTTP-to-HTTPS** - Handles proxying from HTTP origins to HTTPS destinations
|
|
15
|
+
- **Fable Service Provider** - Registers as a standard Fable service
|
|
16
|
+
|
|
17
|
+
## How It Works
|
|
18
|
+
|
|
19
|
+
When you call `connectProxyRoutes()`, the module registers GET, PUT, POST, and DELETE handlers on the Orator service server for each prefix in the `RequestPrefixList`. When a matching request comes in, it is forwarded to the `DestinationURL` using `http-proxy`.
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
Client Request: GET /api/v1/users
|
|
23
|
+
↓
|
|
24
|
+
Orator ServiceServer matches /api/v1/*
|
|
25
|
+
↓
|
|
26
|
+
HTTP Proxy forwards to http://backend:3000/api/v1/users
|
|
27
|
+
↓
|
|
28
|
+
Backend response is returned to the client
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Quick Start
|
|
32
|
+
|
|
33
|
+
```javascript
|
|
34
|
+
const libFable = require('fable');
|
|
35
|
+
const libOrator = require('orator');
|
|
36
|
+
const libOratorServiceServerRestify = require('orator-serviceserver-restify');
|
|
37
|
+
const libOratorHTTPProxy = require('orator-http-proxy');
|
|
38
|
+
|
|
39
|
+
const _Fable = new libFable({
|
|
40
|
+
Product: 'MyProxyServer',
|
|
41
|
+
ServicePort: 8080
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
_Fable.serviceManager.addServiceType('Orator', libOrator);
|
|
45
|
+
_Fable.serviceManager.addServiceType('OratorServiceServer', libOratorServiceServerRestify);
|
|
46
|
+
_Fable.serviceManager.addServiceType('OratorHTTPProxy', libOratorHTTPProxy);
|
|
47
|
+
_Fable.serviceManager.instantiateServiceProvider('Orator');
|
|
48
|
+
_Fable.serviceManager.instantiateServiceProvider('OratorServiceServer');
|
|
49
|
+
_Fable.serviceManager.instantiateServiceProvider('OratorHTTPProxy',
|
|
50
|
+
{
|
|
51
|
+
DestinationURL: 'http://backend-api:3000/',
|
|
52
|
+
RequestPrefixList: ['/api/v1/*']
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
_Fable.Orator.initialize(
|
|
56
|
+
() =>
|
|
57
|
+
{
|
|
58
|
+
_Fable.OratorHTTPProxy.connectProxyRoutes();
|
|
59
|
+
_Fable.Orator.startService();
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Related Packages
|
|
64
|
+
|
|
65
|
+
- [orator](https://github.com/stevenvelozo/orator) - Main Orator service abstraction
|
|
66
|
+
- [orator-serviceserver-restify](https://github.com/stevenvelozo/orator-serviceserver-restify) - Restify service server
|
|
67
|
+
- [fable](https://github.com/stevenvelozo/fable) - Service provider framework
|
package/docs/_sidebar.md
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# Configuration
|
|
2
|
+
|
|
3
|
+
## Options
|
|
4
|
+
|
|
5
|
+
Configuration can be provided through constructor options, Fable settings, or both. The module checks in this order:
|
|
6
|
+
|
|
7
|
+
1. Constructor options (passed when instantiating the service)
|
|
8
|
+
2. Fable settings (with `OratorHTTPProxy` prefix)
|
|
9
|
+
3. Built-in defaults
|
|
10
|
+
|
|
11
|
+
### Constructor Options
|
|
12
|
+
|
|
13
|
+
| Option | Type | Default | Description |
|
|
14
|
+
|--------|------|---------|-------------|
|
|
15
|
+
| `DestinationURL` | string | `"http://127.0.0.1/"` | URL to proxy requests to |
|
|
16
|
+
| `RequestPrefixList` | array | `["/1.0/*"]` | Route prefixes to intercept and proxy |
|
|
17
|
+
| `LogLevel` | number | `0` | Logging verbosity (0 = quiet, higher = more output) |
|
|
18
|
+
| `httpProxyOptions` | object | `{}` | Additional options passed to `http-proxy` |
|
|
19
|
+
|
|
20
|
+
### Fable Settings
|
|
21
|
+
|
|
22
|
+
| Fable Setting | Maps To |
|
|
23
|
+
|---------------|---------|
|
|
24
|
+
| `OratorHTTPProxyDestinationURL` | `DestinationURL` |
|
|
25
|
+
| `OratorHTTPProxyRequestPrefixList` | `RequestPrefixList` |
|
|
26
|
+
| `OratorHTTPProxyLogLevel` | `LogLevel` |
|
|
27
|
+
|
|
28
|
+
### Example: Configuration via Options
|
|
29
|
+
|
|
30
|
+
```javascript
|
|
31
|
+
_Fable.serviceManager.instantiateServiceProvider('OratorHTTPProxy',
|
|
32
|
+
{
|
|
33
|
+
DestinationURL: 'http://backend:3000/',
|
|
34
|
+
RequestPrefixList: ['/api/*'],
|
|
35
|
+
LogLevel: 2
|
|
36
|
+
});
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Example: Configuration via Fable Settings
|
|
40
|
+
|
|
41
|
+
```javascript
|
|
42
|
+
const _Fable = new libFable({
|
|
43
|
+
Product: 'MyProxyServer',
|
|
44
|
+
ServicePort: 8080,
|
|
45
|
+
OratorHTTPProxyDestinationURL: 'http://backend:3000/',
|
|
46
|
+
OratorHTTPProxyRequestPrefixList: ['/api/*'],
|
|
47
|
+
OratorHTTPProxyLogLevel: 2
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
_Fable.serviceManager.instantiateServiceProvider('OratorHTTPProxy');
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Example: JSON Configuration File
|
|
54
|
+
|
|
55
|
+
```json
|
|
56
|
+
{
|
|
57
|
+
"Product": "MyProxyServer",
|
|
58
|
+
"ServicePort": 8080,
|
|
59
|
+
"OratorHTTPProxyDestinationURL": "http://backend:3000/",
|
|
60
|
+
"OratorHTTPProxyRequestPrefixList": ["/api/*"],
|
|
61
|
+
"OratorHTTPProxyLogLevel": 0
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## HTTP Proxy Options
|
|
66
|
+
|
|
67
|
+
The `httpProxyOptions` object is passed directly to the `http-proxy` library. Some useful options:
|
|
68
|
+
|
|
69
|
+
| Option | Type | Description |
|
|
70
|
+
|--------|------|-------------|
|
|
71
|
+
| `secure` | boolean | Verify SSL certificates (default: `false` in proxy handler) |
|
|
72
|
+
| `changeOrigin` | boolean | Change the origin header to the target URL |
|
|
73
|
+
| `headers` | object | Additional headers to add to proxied requests |
|
|
74
|
+
| `ws` | boolean | Enable WebSocket proxying |
|
|
75
|
+
|
|
76
|
+
```javascript
|
|
77
|
+
_Fable.serviceManager.instantiateServiceProvider('OratorHTTPProxy',
|
|
78
|
+
{
|
|
79
|
+
DestinationURL: 'https://secure-backend:443/',
|
|
80
|
+
RequestPrefixList: ['/api/*'],
|
|
81
|
+
httpProxyOptions:
|
|
82
|
+
{
|
|
83
|
+
changeOrigin: true,
|
|
84
|
+
headers: { 'X-Proxy-Source': 'orator' }
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
```
|
package/docs/cover.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Orator HTTP Proxy <small>1</small>
|
|
2
|
+
|
|
3
|
+
> HTTP proxy pass-through for Orator service servers
|
|
4
|
+
|
|
5
|
+
- Route-based proxying to backend services
|
|
6
|
+
- Supports GET, PUT, POST, and DELETE
|
|
7
|
+
- Configurable via options or Fable settings
|
|
8
|
+
- Handles HTTP-to-HTTPS proxying
|
|
9
|
+
|
|
10
|
+
[GitHub](https://github.com/stevenvelozo/orator-http-proxy)
|
|
11
|
+
[Get Started](#orator-http-proxy)
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/* ============================================================================
|
|
2
|
+
Pict Docuserve - Base Styles
|
|
3
|
+
============================================================================ */
|
|
4
|
+
|
|
5
|
+
/* Reset and base */
|
|
6
|
+
*, *::before, *::after {
|
|
7
|
+
box-sizing: border-box;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
html, body {
|
|
11
|
+
margin: 0;
|
|
12
|
+
padding: 0;
|
|
13
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
|
14
|
+
font-size: 16px;
|
|
15
|
+
line-height: 1.5;
|
|
16
|
+
color: #423D37;
|
|
17
|
+
background-color: #fff;
|
|
18
|
+
-webkit-font-smoothing: antialiased;
|
|
19
|
+
-moz-osx-font-smoothing: grayscale;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/* Typography */
|
|
23
|
+
h1, h2, h3, h4, h5, h6 {
|
|
24
|
+
margin-top: 0;
|
|
25
|
+
line-height: 1.3;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
a {
|
|
29
|
+
color: #2E7D74;
|
|
30
|
+
text-decoration: none;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
a:hover {
|
|
34
|
+
color: #256861;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/* Application container */
|
|
38
|
+
#Docuserve-Application-Container {
|
|
39
|
+
min-height: 100vh;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/* Utility: scrollbar styling */
|
|
43
|
+
::-webkit-scrollbar {
|
|
44
|
+
width: 8px;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
::-webkit-scrollbar-track {
|
|
48
|
+
background: #F5F0E8;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
::-webkit-scrollbar-thumb {
|
|
52
|
+
background: #D4CCBE;
|
|
53
|
+
border-radius: 4px;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
::-webkit-scrollbar-thumb:hover {
|
|
57
|
+
background: #B5AA9A;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/* Responsive adjustments */
|
|
61
|
+
@media (max-width: 768px) {
|
|
62
|
+
html {
|
|
63
|
+
font-size: 14px;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
#Docuserve-Sidebar-Container {
|
|
67
|
+
display: none;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.docuserve-body {
|
|
71
|
+
flex-direction: column;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# Getting Started
|
|
2
|
+
|
|
3
|
+
## Installation
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install orator-http-proxy
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
You will also need `orator` and a service server implementation (like `orator-serviceserver-restify`):
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install fable orator orator-serviceserver-restify orator-http-proxy
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Basic Setup
|
|
16
|
+
|
|
17
|
+
```javascript
|
|
18
|
+
const libFable = require('fable');
|
|
19
|
+
const libOrator = require('orator');
|
|
20
|
+
const libOratorServiceServerRestify = require('orator-serviceserver-restify');
|
|
21
|
+
const libOratorHTTPProxy = require('orator-http-proxy');
|
|
22
|
+
|
|
23
|
+
const _Fable = new libFable({
|
|
24
|
+
Product: 'MyProxyServer',
|
|
25
|
+
ServicePort: 8080
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// Set up Orator with Restify
|
|
29
|
+
_Fable.serviceManager.addServiceType('Orator', libOrator);
|
|
30
|
+
_Fable.serviceManager.addServiceType('OratorServiceServer', libOratorServiceServerRestify);
|
|
31
|
+
_Fable.serviceManager.instantiateServiceProvider('Orator');
|
|
32
|
+
_Fable.serviceManager.instantiateServiceProvider('OratorServiceServer');
|
|
33
|
+
|
|
34
|
+
// Set up the proxy
|
|
35
|
+
_Fable.serviceManager.addServiceType('OratorHTTPProxy', libOratorHTTPProxy);
|
|
36
|
+
_Fable.serviceManager.instantiateServiceProvider('OratorHTTPProxy',
|
|
37
|
+
{
|
|
38
|
+
DestinationURL: 'http://backend-api:3000/',
|
|
39
|
+
RequestPrefixList: ['/api/v1/*']
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// Initialize and connect
|
|
43
|
+
_Fable.Orator.initialize(
|
|
44
|
+
() =>
|
|
45
|
+
{
|
|
46
|
+
_Fable.OratorHTTPProxy.connectProxyRoutes();
|
|
47
|
+
_Fable.Orator.startService();
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Multiple Proxy Prefixes
|
|
52
|
+
|
|
53
|
+
You can proxy multiple route prefixes to the same backend:
|
|
54
|
+
|
|
55
|
+
```javascript
|
|
56
|
+
_Fable.serviceManager.instantiateServiceProvider('OratorHTTPProxy',
|
|
57
|
+
{
|
|
58
|
+
DestinationURL: 'http://backend-api:3000/',
|
|
59
|
+
RequestPrefixList: ['/api/v1/*', '/api/v2/*', '/auth/*']
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Multiple Backends
|
|
64
|
+
|
|
65
|
+
To proxy different prefixes to different backends, instantiate multiple proxy services:
|
|
66
|
+
|
|
67
|
+
```javascript
|
|
68
|
+
_Fable.serviceManager.instantiateServiceProvider('OratorHTTPProxy',
|
|
69
|
+
{
|
|
70
|
+
DestinationURL: 'http://api-service:3000/',
|
|
71
|
+
RequestPrefixList: ['/api/*']
|
|
72
|
+
}, 'APIProxy');
|
|
73
|
+
|
|
74
|
+
_Fable.serviceManager.instantiateServiceProvider('OratorHTTPProxy',
|
|
75
|
+
{
|
|
76
|
+
DestinationURL: 'http://auth-service:4000/',
|
|
77
|
+
RequestPrefixList: ['/auth/*']
|
|
78
|
+
}, 'AuthProxy');
|
|
79
|
+
|
|
80
|
+
// Connect both after Orator initializes
|
|
81
|
+
_Fable.Orator.initialize(
|
|
82
|
+
() =>
|
|
83
|
+
{
|
|
84
|
+
_Fable.servicesMap['OratorHTTPProxy']['APIProxy'].connectProxyRoutes();
|
|
85
|
+
_Fable.servicesMap['OratorHTTPProxy']['AuthProxy'].connectProxyRoutes();
|
|
86
|
+
_Fable.Orator.startService();
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Combining with Static Files
|
|
91
|
+
|
|
92
|
+
A common pattern is to serve a frontend application statically while proxying API calls to a backend:
|
|
93
|
+
|
|
94
|
+
```javascript
|
|
95
|
+
_Fable.Orator.initialize(
|
|
96
|
+
() =>
|
|
97
|
+
{
|
|
98
|
+
// Proxy API calls to the backend
|
|
99
|
+
_Fable.OratorHTTPProxy.connectProxyRoutes();
|
|
100
|
+
|
|
101
|
+
// Serve static files for everything else
|
|
102
|
+
_Fable.Orator.addStaticRoute('./public/', 'index.html', '/*');
|
|
103
|
+
|
|
104
|
+
_Fable.Orator.startService();
|
|
105
|
+
});
|
|
106
|
+
```
|
package/docs/index.html
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
|
7
|
+
<meta name="description" content="Documentation powered by pict-docuserve">
|
|
8
|
+
|
|
9
|
+
<title>Documentation</title>
|
|
10
|
+
|
|
11
|
+
<!-- Application Stylesheet -->
|
|
12
|
+
<link href="css/docuserve.css" rel="stylesheet">
|
|
13
|
+
<!-- KaTeX stylesheet for LaTeX equation rendering -->
|
|
14
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.21/dist/katex.min.css">
|
|
15
|
+
<!-- PICT Dynamic View CSS Container -->
|
|
16
|
+
<style id="PICT-CSS"></style>
|
|
17
|
+
|
|
18
|
+
<!-- Load the PICT library from jsDelivr CDN -->
|
|
19
|
+
<script src="https://cdn.jsdelivr.net/npm/pict@1/dist/pict.min.js" type="text/javascript"></script>
|
|
20
|
+
<!-- Bootstrap the Application -->
|
|
21
|
+
<script type="text/javascript">
|
|
22
|
+
//<![CDATA[
|
|
23
|
+
Pict.safeOnDocumentReady(() => { Pict.safeLoadPictApplication(PictDocuserve, 2)});
|
|
24
|
+
//]]>
|
|
25
|
+
</script>
|
|
26
|
+
</head>
|
|
27
|
+
<body>
|
|
28
|
+
<!-- The root container for the Pict application -->
|
|
29
|
+
<div id="Docuserve-Application-Container"></div>
|
|
30
|
+
|
|
31
|
+
<!-- Mermaid diagram rendering -->
|
|
32
|
+
<script src="https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.min.js"></script>
|
|
33
|
+
<script>mermaid.initialize({ startOnLoad: false, theme: 'default' });</script>
|
|
34
|
+
<!-- KaTeX for LaTeX equation rendering -->
|
|
35
|
+
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.21/dist/katex.min.js"></script>
|
|
36
|
+
<!-- Load the Docuserve PICT Application Bundle from jsDelivr CDN -->
|
|
37
|
+
<script src="https://cdn.jsdelivr.net/npm/pict-docuserve@0/dist/pict-docuserve.min.js" type="text/javascript"></script>
|
|
38
|
+
</body>
|
|
39
|
+
</html>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Generated": "2026-02-18T03:42:52.610Z",
|
|
3
|
+
"GitHubOrg": "stevenvelozo",
|
|
4
|
+
"DefaultBranch": "master",
|
|
5
|
+
"Groups": [
|
|
6
|
+
{
|
|
7
|
+
"Name": "Debug",
|
|
8
|
+
"Key": "debug",
|
|
9
|
+
"Description": "",
|
|
10
|
+
"Modules": [
|
|
11
|
+
{
|
|
12
|
+
"Name": "serve",
|
|
13
|
+
"Repo": "serve",
|
|
14
|
+
"Group": "debug",
|
|
15
|
+
"Branch": "master",
|
|
16
|
+
"HasDocs": false,
|
|
17
|
+
"HasCover": false,
|
|
18
|
+
"Sidebar": [],
|
|
19
|
+
"DocFiles": []
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"Name": "Dist",
|
|
25
|
+
"Key": "dist",
|
|
26
|
+
"Description": "",
|
|
27
|
+
"Modules": [
|
|
28
|
+
{
|
|
29
|
+
"Name": "indoctrinate_content_staging",
|
|
30
|
+
"Repo": "indoctrinate_content_staging",
|
|
31
|
+
"Group": "dist",
|
|
32
|
+
"Branch": "master",
|
|
33
|
+
"HasDocs": false,
|
|
34
|
+
"HasCover": false,
|
|
35
|
+
"Sidebar": [],
|
|
36
|
+
"DocFiles": []
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Generated": "2026-02-18T03:42:52.690Z",
|
|
3
|
+
"DocumentCount": 0,
|
|
4
|
+
"LunrIndex": {
|
|
5
|
+
"version": "2.3.9",
|
|
6
|
+
"fields": [
|
|
7
|
+
"title",
|
|
8
|
+
"module",
|
|
9
|
+
"group",
|
|
10
|
+
"body"
|
|
11
|
+
],
|
|
12
|
+
"fieldVectors": [],
|
|
13
|
+
"invertedIndex": [],
|
|
14
|
+
"pipeline": [
|
|
15
|
+
"stemmer"
|
|
16
|
+
]
|
|
17
|
+
},
|
|
18
|
+
"Documents": {}
|
|
19
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "orator-http-proxy",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Orator http proxy pass-through.",
|
|
5
5
|
"main": "source/Orator-HTTP-Proxy.js",
|
|
6
6
|
"scripts": {
|
|
@@ -39,12 +39,12 @@
|
|
|
39
39
|
"homepage": "https://github.com/stevenvelozo/orator-http-proxy#readme",
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"http-proxy": "^1.18.1",
|
|
42
|
-
"orator-serviceserver-base": "^1.0.
|
|
42
|
+
"orator-serviceserver-base": "^1.0.2"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"fable": "^3.
|
|
46
|
-
"orator": "^
|
|
47
|
-
"orator-serviceserver-restify": "^2.0.
|
|
48
|
-
"quackage": "^1.0.
|
|
45
|
+
"fable": "^3.1.55",
|
|
46
|
+
"orator": "^6.0.1",
|
|
47
|
+
"orator-serviceserver-restify": "^2.0.7",
|
|
48
|
+
"quackage": "^1.0.51"
|
|
49
49
|
}
|
|
50
50
|
}
|
|
@@ -41,7 +41,7 @@ class OratorAPIProxy extends FableServiceProviderBase
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
|
-
* Create handlers for each HTTP verb on
|
|
44
|
+
* Create handlers for each HTTP verb on the request prefix list to proxy requests to the configured proxy URL.
|
|
45
45
|
*/
|
|
46
46
|
connectProxyRoutes(pRequestPrefixList, pProxyURL)
|
|
47
47
|
{
|