redis-smq-web-server 9.0.0-next.8 → 9.0.0
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/CHANGELOG.md +94 -0
- package/README.md +20 -190
- package/dist/cjs/bin/cli.js +1 -5
- package/dist/cjs/bin/cli.js.map +1 -1
- package/dist/cjs/src/config/parse-config.d.ts.map +1 -1
- package/dist/cjs/src/config/parse-config.js +14 -2
- package/dist/cjs/src/config/parse-config.js.map +1 -1
- package/dist/cjs/src/config/types/index.d.ts +1 -1
- package/dist/cjs/src/config/types/index.d.ts.map +1 -1
- package/dist/cjs/src/index.d.ts +1 -0
- package/dist/cjs/src/index.d.ts.map +1 -1
- package/dist/cjs/src/index.js +54 -21
- package/dist/cjs/src/index.js.map +1 -1
- package/dist/cjs/tests/common/config.d.ts +3 -0
- package/dist/cjs/tests/common/config.d.ts.map +1 -0
- package/dist/cjs/tests/common/config.js +24 -0
- package/dist/cjs/tests/common/config.js.map +1 -0
- package/dist/cjs/tests/common/redis-client.d.ts +94 -0
- package/dist/cjs/tests/common/redis-client.d.ts.map +1 -0
- package/dist/cjs/tests/common/redis-client.js +40 -0
- package/dist/cjs/tests/common/redis-client.js.map +1 -0
- package/dist/cjs/tests/common/start-api-server.d.ts +3 -0
- package/dist/cjs/tests/common/start-api-server.d.ts.map +1 -0
- package/dist/cjs/tests/common/start-api-server.js +39 -0
- package/dist/cjs/tests/common/start-api-server.js.map +1 -0
- package/dist/cjs/tests/common/start-cli.d.ts +10 -0
- package/dist/cjs/tests/common/start-cli.d.ts.map +1 -0
- package/dist/cjs/tests/common/start-cli.js +70 -0
- package/dist/cjs/tests/common/start-cli.js.map +1 -0
- package/dist/cjs/tests/common/start-redis-server.d.ts +3 -0
- package/dist/cjs/tests/common/start-redis-server.d.ts.map +1 -0
- package/dist/cjs/tests/common/start-redis-server.js +37 -0
- package/dist/cjs/tests/common/start-redis-server.js.map +1 -0
- package/dist/cjs/tests/common/start-web-server.d.ts +3 -0
- package/dist/cjs/tests/common/start-web-server.d.ts.map +1 -0
- package/dist/cjs/tests/common/start-web-server.js +33 -0
- package/dist/cjs/tests/common/start-web-server.js.map +1 -0
- package/dist/cjs/tests/setup.d.ts +2 -0
- package/dist/cjs/tests/setup.d.ts.map +1 -0
- package/dist/cjs/tests/setup.js +27 -0
- package/dist/cjs/tests/setup.js.map +1 -0
- package/dist/cjs/tests/tests/test00001.test.d.ts +2 -0
- package/dist/cjs/tests/tests/test00001.test.d.ts.map +1 -0
- package/dist/cjs/tests/tests/test00001.test.js +114 -0
- package/dist/cjs/tests/tests/test00001.test.js.map +1 -0
- package/dist/cjs/tests/tests/test00002.test.d.ts +2 -0
- package/dist/cjs/tests/tests/test00002.test.d.ts.map +1 -0
- package/dist/cjs/tests/tests/test00002.test.js +70 -0
- package/dist/cjs/tests/tests/test00002.test.js.map +1 -0
- package/dist/cjs/tests/tests/test00003.test.d.ts +2 -0
- package/dist/cjs/tests/tests/test00003.test.d.ts.map +1 -0
- package/dist/cjs/tests/tests/test00003.test.js +119 -0
- package/dist/cjs/tests/tests/test00003.test.js.map +1 -0
- package/dist/esm/bin/cli.js +1 -5
- package/dist/esm/bin/cli.js.map +1 -1
- package/dist/esm/src/config/parse-config.d.ts.map +1 -1
- package/dist/esm/src/config/parse-config.js +16 -1
- package/dist/esm/src/config/parse-config.js.map +1 -1
- package/dist/esm/src/config/types/index.d.ts +1 -1
- package/dist/esm/src/config/types/index.d.ts.map +1 -1
- package/dist/esm/src/index.d.ts +1 -0
- package/dist/esm/src/index.d.ts.map +1 -1
- package/dist/esm/src/index.js +54 -21
- package/dist/esm/src/index.js.map +1 -1
- package/dist/esm/tests/common/config.d.ts +3 -0
- package/dist/esm/tests/common/config.d.ts.map +1 -0
- package/dist/esm/tests/common/config.js +21 -0
- package/dist/esm/tests/common/config.js.map +1 -0
- package/dist/esm/tests/common/redis-client.d.ts +94 -0
- package/dist/esm/tests/common/redis-client.d.ts.map +1 -0
- package/dist/esm/tests/common/redis-client.js +20 -0
- package/dist/esm/tests/common/redis-client.js.map +1 -0
- package/dist/esm/tests/common/start-api-server.d.ts +3 -0
- package/dist/esm/tests/common/start-api-server.d.ts.map +1 -0
- package/dist/esm/tests/common/start-api-server.js +22 -0
- package/dist/esm/tests/common/start-api-server.js.map +1 -0
- package/dist/esm/tests/common/start-cli.d.ts +10 -0
- package/dist/esm/tests/common/start-cli.d.ts.map +1 -0
- package/dist/esm/tests/common/start-cli.js +54 -0
- package/dist/esm/tests/common/start-cli.js.map +1 -0
- package/dist/esm/tests/common/start-redis-server.d.ts +3 -0
- package/dist/esm/tests/common/start-redis-server.d.ts.map +1 -0
- package/dist/esm/tests/common/start-redis-server.js +22 -0
- package/dist/esm/tests/common/start-redis-server.js.map +1 -0
- package/dist/esm/tests/common/start-web-server.d.ts +3 -0
- package/dist/esm/tests/common/start-web-server.d.ts.map +1 -0
- package/dist/esm/tests/common/start-web-server.js +16 -0
- package/dist/esm/tests/common/start-web-server.js.map +1 -0
- package/dist/esm/tests/setup.d.ts +2 -0
- package/dist/esm/tests/setup.d.ts.map +1 -0
- package/dist/esm/tests/setup.js +16 -0
- package/dist/esm/tests/setup.js.map +1 -0
- package/dist/esm/tests/tests/test00001.test.d.ts +2 -0
- package/dist/esm/tests/tests/test00001.test.d.ts.map +1 -0
- package/dist/esm/tests/tests/test00001.test.js +99 -0
- package/dist/esm/tests/tests/test00001.test.js.map +1 -0
- package/dist/esm/tests/tests/test00002.test.d.ts +2 -0
- package/dist/esm/tests/tests/test00002.test.d.ts.map +1 -0
- package/dist/esm/tests/tests/test00002.test.js +59 -0
- package/dist/esm/tests/tests/test00002.test.js.map +1 -0
- package/dist/esm/tests/tests/test00003.test.d.ts +2 -0
- package/dist/esm/tests/tests/test00003.test.d.ts.map +1 -0
- package/dist/esm/tests/tests/test00003.test.js +104 -0
- package/dist/esm/tests/tests/test00003.test.js.map +1 -0
- package/package.json +7 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,100 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [9.0.0](https://github.com/weyoss/redis-smq/compare/v9.0.0-next.18...v9.0.0) (2025-11-07)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package redis-smq-web-server
|
|
9
|
+
|
|
10
|
+
## [9.0.0-next.18](https://github.com/weyoss/redis-smq/compare/v9.0.0-next.17...v9.0.0-next.18) (2025-11-07)
|
|
11
|
+
|
|
12
|
+
### 📝 Documentation
|
|
13
|
+
|
|
14
|
+
- convert relative paths to absolute URLs in package READMEs ([ad5da5f](https://github.com/weyoss/redis-smq/commit/ad5da5f14aeb01822e560e7e15473dc27518e80a))
|
|
15
|
+
|
|
16
|
+
## [9.0.0-next.17](https://github.com/weyoss/redis-smq/compare/v9.0.0-next.16...v9.0.0-next.17) (2025-11-07)
|
|
17
|
+
|
|
18
|
+
### ⚠ BREAKING CHANGES
|
|
19
|
+
|
|
20
|
+
- **redis-smq-web-server:** remove apiServer from IRedisSMQWebServerConfig
|
|
21
|
+
|
|
22
|
+
### 📝 Documentation
|
|
23
|
+
|
|
24
|
+
- **redis-smq-web-server:** restructure README, move details to separate files ([99a5bce](https://github.com/weyoss/redis-smq/commit/99a5bce764ed7ba7568f2498ea59ce662a84d7ad))
|
|
25
|
+
- standardize documentation links to use relative paths ([fc7c474](https://github.com/weyoss/redis-smq/commit/fc7c474bffbd2160fb9bb8727cec4bbdc5a23dc8))
|
|
26
|
+
|
|
27
|
+
### ♻️ Code Refactoring
|
|
28
|
+
|
|
29
|
+
- **redis-smq-web-server:** remove apiServer from IRedisSMQWebServerConfig ([b78dea0](https://github.com/weyoss/redis-smq/commit/b78dea0def68dde6d8550b1355b98ed9aeda833c))
|
|
30
|
+
|
|
31
|
+
## [9.0.0-next.16](https://github.com/weyoss/redis-smq/compare/v9.0.0-next.15...v9.0.0-next.16) (2025-11-05)
|
|
32
|
+
|
|
33
|
+
**Note:** Version bump only for package redis-smq-web-server
|
|
34
|
+
|
|
35
|
+
## [9.0.0-next.15](https://github.com/weyoss/redis-smq/compare/v9.0.0-next.14...v9.0.0-next.15) (2025-10-31)
|
|
36
|
+
|
|
37
|
+
### 📝 Documentation
|
|
38
|
+
|
|
39
|
+
- **redis-smq-web-server:** add reverse proxy deployment guide ([c19a48c](https://github.com/weyoss/redis-smq/commit/c19a48c58c1e384a0d484cb79ee461503fa0a306))
|
|
40
|
+
|
|
41
|
+
## [9.0.0-next.14](https://github.com/weyoss/redis-smq/compare/v9.0.0-next.13...v9.0.0-next.14) (2025-10-28)
|
|
42
|
+
|
|
43
|
+
### ⚠ BREAKING CHANGES
|
|
44
|
+
|
|
45
|
+
- **redis-smq-web-server:** fix base path routing and improve middleware setup
|
|
46
|
+
|
|
47
|
+
### 🐛 Bug Fixes
|
|
48
|
+
|
|
49
|
+
- **redis-smq-web-server:** fix base path routing and improve middleware setup ([45d6c6d](https://github.com/weyoss/redis-smq/commit/45d6c6dbb35999676575f7f3373a495c9c2e3731))
|
|
50
|
+
|
|
51
|
+
## [9.0.0-next.13](https://github.com/weyoss/redis-smq/compare/v9.0.0-next.12...v9.0.0-next.13) (2025-10-28)
|
|
52
|
+
|
|
53
|
+
### 🐛 Bug Fixes
|
|
54
|
+
|
|
55
|
+
- **redis-smq-web-server:** ensure API server inherits correct base path configuration ([eaa1b7d](https://github.com/weyoss/redis-smq/commit/eaa1b7d0a40ccdf98ceecd98f37930f840407946))
|
|
56
|
+
|
|
57
|
+
### 📝 Documentation
|
|
58
|
+
|
|
59
|
+
- **redis-smq-web-server:** update apiProxyTarget notes ([692926d](https://github.com/weyoss/redis-smq/commit/692926d93a242ca58bb798b037a555d4d6e4d69d))
|
|
60
|
+
|
|
61
|
+
## [9.0.0-next.12](https://github.com/weyoss/redis-smq/compare/v9.0.0-next.11...v9.0.0-next.12) (2025-10-27)
|
|
62
|
+
|
|
63
|
+
### 🚀 Chore
|
|
64
|
+
|
|
65
|
+
- add copyright headers to source files ([771e980](https://github.com/weyoss/redis-smq/commit/771e9802ddea11abb5982c4bfdfde1bebf1c7468))
|
|
66
|
+
|
|
67
|
+
### 📝 Documentation
|
|
68
|
+
|
|
69
|
+
- fix license section formatting and standardize project names ([abbdbda](https://github.com/weyoss/redis-smq/commit/abbdbdae6fc42f0a9353b7cd786386a98e6e850d))
|
|
70
|
+
|
|
71
|
+
## [9.0.0-next.11](https://github.com/weyoss/redis-smq/compare/v9.0.0-next.10...v9.0.0-next.11) (2025-10-27)
|
|
72
|
+
|
|
73
|
+
### 🐛 Bug Fixes
|
|
74
|
+
|
|
75
|
+
- correct codecov badge URL format ([3ebb5c8](https://github.com/weyoss/redis-smq/commit/3ebb5c8ba8a7f9902de054d7aaf0c1fc572fb9a6))
|
|
76
|
+
|
|
77
|
+
### ✅ Tests
|
|
78
|
+
|
|
79
|
+
- **redis-smq-web-server:** add CLI and API proxy e2e tests ([a96ee8e](https://github.com/weyoss/redis-smq/commit/a96ee8e5a91f7a36dcd0a66082fc0b25be62350f))
|
|
80
|
+
|
|
81
|
+
## [9.0.0-next.10](https://github.com/weyoss/redis-smq/compare/v9.0.0-next.9...v9.0.0-next.10) (2025-10-26)
|
|
82
|
+
|
|
83
|
+
### 🐛 Bug Fixes
|
|
84
|
+
|
|
85
|
+
- **redis-smq-web-server:** add rate limiting middleware to prevent DoS attacks ([5c144fd](https://github.com/weyoss/redis-smq/commit/5c144fdc67007aa686bdceddc36e3d93635bcff9))
|
|
86
|
+
- **redis-smq-web-server:** improve base path handling and routing logic ([5e7ff4c](https://github.com/weyoss/redis-smq/commit/5e7ff4c46b07b29bd1328bbf9732efbd07cb60b1))
|
|
87
|
+
|
|
88
|
+
### 📝 Documentation
|
|
89
|
+
|
|
90
|
+
- **redis-smq-web-server:** add npm version/code coverage badges ([c4c76c2](https://github.com/weyoss/redis-smq/commit/c4c76c2a781ad414ae1117f9b47cdb0c4eb04fac))
|
|
91
|
+
|
|
92
|
+
### ✅ Tests
|
|
93
|
+
|
|
94
|
+
- **redis-smq-web-server:** add comprehensive E2E test suite ([d67e5c6](https://github.com/weyoss/redis-smq/commit/d67e5c6d4cfb62d6736698d5fdb158a2bebf41df))
|
|
95
|
+
|
|
96
|
+
## [9.0.0-next.9](https://github.com/weyoss/redis-smq/compare/v9.0.0-next.8...v9.0.0-next.9) (2025-10-21)
|
|
97
|
+
|
|
98
|
+
**Note:** Version bump only for package redis-smq-web-server
|
|
99
|
+
|
|
6
100
|
## [9.0.0-next.8](https://github.com/weyoss/redis-smq/compare/v9.0.0-next.7...v9.0.0-next.8) (2025-10-18)
|
|
7
101
|
|
|
8
102
|
**Note:** Version bump only for package redis-smq-web-server
|
package/README.md
CHANGED
|
@@ -1,33 +1,25 @@
|
|
|
1
1
|
# RedisSMQ Web Server
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
> For the latest stable documentation, see:
|
|
6
|
-
>
|
|
7
|
-
> - Master (stable) README: https://github.com/weyoss/redis-smq/tree/master/packages/redis-smq-web-server
|
|
8
|
-
> - Latest release notes/tags: https://github.com/weyoss/redis-smq/releases/latest
|
|
9
|
-
> - Install stable packages with @latest; pre-release with @next.
|
|
3
|
+
[](https://www.npmjs.com/package/redis-smq-web-server?activeTab=versions)
|
|
4
|
+
[](https://app.codecov.io/github/weyoss/redis-smq/tree/master/packages/redis-smq-web-server)
|
|
10
5
|
|
|
11
|
-
A lightweight
|
|
6
|
+
A lightweight server that brings the RedisSMQ management ecosystem to life. It serves the official Web UI and provides
|
|
7
|
+
the REST API through two flexible modes of operation:
|
|
12
8
|
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
- Can run the HTTP API in-process, or proxy API/docs/assets to an external `redis-smq-rest-api`.
|
|
16
|
-
- Requires only Redis connection details when hosting the API in-process; with proxying, Redis is managed by the upstream API service.
|
|
9
|
+
- **Standalone Mode:** Run the Web UI and REST API in a single process for an all-in-one setup.
|
|
10
|
+
- **Proxy Mode:** Serve the Web UI and proxy API requests to a separate redis-smq-rest-api instance for distributed deployments.
|
|
17
11
|
|
|
18
12
|
## Features
|
|
19
13
|
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
- Simple, explicit configuration via CLI or programmatic config.
|
|
24
|
-
- Sensible defaults; easily deployable behind reverse proxies.
|
|
14
|
+
- **Dual-Mode Operation:** Standalone (UI + API in one process) or Proxy (UI + proxied API).
|
|
15
|
+
- **Versatile Execution:** Start from the CLI as a standalone server or embed as a library in your Node.js app.
|
|
16
|
+
- **Consistent Ecosystem:** Works seamlessly with `redis-smq`, `redis-smq-rest-api`, and `redis-smq-web-ui`.
|
|
25
17
|
|
|
26
18
|
## Installation
|
|
27
19
|
|
|
28
20
|
```bash
|
|
29
21
|
# Using npm
|
|
30
|
-
npm install redis-smq@
|
|
22
|
+
npm install redis-smq@latest redis-smq-common@latest redis-smq-rest-api@latest redis-smq-web-ui@latest redis-smq-web-server@latest --save
|
|
31
23
|
```
|
|
32
24
|
|
|
33
25
|
Don't forget to install a Redis client. Choose either node-redis or ioredis:
|
|
@@ -38,183 +30,21 @@ npm install @redis/client --save
|
|
|
38
30
|
npm install ioredis --save
|
|
39
31
|
```
|
|
40
32
|
|
|
41
|
-
##
|
|
33
|
+
## Version Compatibility
|
|
42
34
|
|
|
43
|
-
|
|
35
|
+
Always install matching versions of RedisSMQ packages to ensure compatibility. See [version compatibility](https://github.com/weyoss/redis-smq/tree/master/packages/redis-smq/docs/version-compatibility.md) for details.
|
|
44
36
|
|
|
45
|
-
|
|
37
|
+
## Documentation
|
|
46
38
|
|
|
47
|
-
|
|
48
|
-
npx redis-smq-web-server
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
Customize host/port, UI base path, and Redis connection:
|
|
52
|
-
|
|
53
|
-
```shell
|
|
54
|
-
npx redis-smq-web-server \
|
|
55
|
-
--port 8080 \
|
|
56
|
-
--base-path / \
|
|
57
|
-
--redis-host 127.0.0.1 \
|
|
58
|
-
--redis-port 6379 \
|
|
59
|
-
--redis-db 1
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
**Common scenarios:**
|
|
63
|
-
|
|
64
|
-
- Serve under a sub-path (behind a reverse proxy):
|
|
65
|
-
|
|
66
|
-
```shell
|
|
67
|
-
npx redis-smq-web-server --base-path /redis-smq
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
UI will be available at http://localhost:8080/redis-smq and the HTTP API under http://localhost:8080/redis-smq/api.
|
|
71
|
-
|
|
72
|
-
- Use an external API (proxy mode) — useful if you run redis-smq-rest-api separately:
|
|
73
|
-
|
|
74
|
-
```shell
|
|
75
|
-
npx redis-smq-web-server \
|
|
76
|
-
--port 8080 \
|
|
77
|
-
--api-proxy-target http://127.0.0.1:7210
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
When `--api-proxy-target` is provided, requests to `<basePath>/api`, `<basePath>/docs`, and `<basePath>/assets` are forwarded
|
|
81
|
-
to the upstream. In this mode, Redis connection options on the web server are not used; the upstream API service manages Redis.
|
|
82
|
-
|
|
83
|
-
### Programmatically (optional)
|
|
84
|
-
|
|
85
|
-
If you prefer embedding the server in your app, you can pass the same configuration programmatically.
|
|
86
|
-
|
|
87
|
-
```typescript
|
|
88
|
-
import { RedisSMQWebServer } from 'redis-smq-web-server';
|
|
89
|
-
import { EConsoleLoggerLevel, ERedisConfigClient } from 'redis-smq-common';
|
|
90
|
-
|
|
91
|
-
// Run with the embedded REST API (in-process)
|
|
92
|
-
const server = new RedisSMQWebServer({
|
|
93
|
-
webServer: {
|
|
94
|
-
port: 8080,
|
|
95
|
-
basePath: '/', // UI at '/', API at '/api', docs at '/docs'
|
|
96
|
-
},
|
|
97
|
-
// The following options are used only when apiProxyTarget is NOT set
|
|
98
|
-
redis: {
|
|
99
|
-
client: ERedisConfigClient.IOREDIS,
|
|
100
|
-
options: {
|
|
101
|
-
host: '127.0.0.1',
|
|
102
|
-
port: 6379,
|
|
103
|
-
db: 1,
|
|
104
|
-
showFriendlyErrorStack: true,
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
logger: {
|
|
108
|
-
enabled: true,
|
|
109
|
-
options: {
|
|
110
|
-
level: EConsoleLoggerLevel.INFO,
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
await server.run();
|
|
116
|
-
// await server.shutdown();
|
|
117
|
-
|
|
118
|
-
// Or proxy API/docs/assets to an external service
|
|
119
|
-
const srv = new RedisSMQWebServer({
|
|
120
|
-
webServer: {
|
|
121
|
-
port: 8080,
|
|
122
|
-
basePath: '/', // or '/redis-smq'
|
|
123
|
-
apiProxyTarget: 'http://127.0.0.1:7210',
|
|
124
|
-
},
|
|
125
|
-
// No redis/logger config required in proxy mode
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
await srv.run();
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
## Routes
|
|
132
|
-
|
|
133
|
-
- UI: served from the configured base path
|
|
134
|
-
- Example: basePath = / → UI at /
|
|
135
|
-
- Example: basePath = /redis-smq → UI at /redis-smq
|
|
136
|
-
- HTTP API: mounted under <basePath>/api
|
|
137
|
-
|
|
138
|
-
- Example: basePath = / → API at /api
|
|
139
|
-
- Example: basePath = /redis-smq → API at /redis-smq/api
|
|
140
|
-
|
|
141
|
-
- Swagger UI: mounted under <basePath>/docs
|
|
142
|
-
- Example: basePath = / → Swagger UI at /docs
|
|
143
|
-
- Example: basePath = /redis-smq → Swagger UI at /redis-smq/docs
|
|
144
|
-
|
|
145
|
-
Proxying behavior:
|
|
146
|
-
|
|
147
|
-
- When apiProxyTarget is set, the server forwards:
|
|
148
|
-
- <basePath>/api → ${apiProxyTarget}
|
|
149
|
-
- <basePath>/docs → ${apiProxyTarget}
|
|
150
|
-
- <basePath>/assets → ${apiProxyTarget}
|
|
151
|
-
- When apiProxyTarget is not set, the server hosts the embedded REST API in-process.
|
|
152
|
-
|
|
153
|
-
## Configuration
|
|
154
|
-
|
|
155
|
-
Configuration can be provided programmatically or via CLI arguments. The core interface is:
|
|
156
|
-
|
|
157
|
-
```typescript
|
|
158
|
-
import type { IRedisSMQRestApiConfig } from 'redis-smq-rest-api';
|
|
159
|
-
|
|
160
|
-
interface IRedisSMQWebServerConfig extends IRedisSMQRestApiConfig {
|
|
161
|
-
webServer?: {
|
|
162
|
-
/**
|
|
163
|
-
* HTTP port to run the web server on.
|
|
164
|
-
* Default: 8080
|
|
165
|
-
*/
|
|
166
|
-
port?: number;
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Base public path for the RedisSMQ Web UI and the local API/docs when embedded.
|
|
170
|
-
* Default: '/'
|
|
171
|
-
*/
|
|
172
|
-
basePath?: string;
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Optional target for proxying (/api, /docs, /assets).
|
|
176
|
-
* If provided, the embedded REST API is not mounted and requests are forwarded to the target.
|
|
177
|
-
* Example: 'http://127.0.0.1:7210'
|
|
178
|
-
*/
|
|
179
|
-
apiProxyTarget?: string;
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
Notes:
|
|
185
|
-
|
|
186
|
-
- When `webServer.apiProxyTarget` is set, the server proxies `<basePath>/api`, `<basePath>/docs`, and
|
|
187
|
-
`<basePath>/assets` to the target. In this mode, redis and logger options are not used by the web server (they are
|
|
188
|
-
handled by the upstream API service).
|
|
189
|
-
|
|
190
|
-
- When `webServer.apiProxyTarget` is not set, the web server mounts the embedded `redis-smq-rest-api` using the provided
|
|
191
|
-
`IRedisSMQRestApiConfig` (redis, logger, etc.).
|
|
192
|
-
|
|
193
|
-
### ClI flags
|
|
194
|
-
|
|
195
|
-
```shell
|
|
196
|
-
-p, --port <number> Port to run the server on (default: "8080")
|
|
197
|
-
-b, --base-path <string> Base public path for the RedisSMQ Web UI SPA (default: "/")
|
|
198
|
-
-t, --api-proxy-target <string> Proxy target for API (/api, /docs, /assets). Example: http://127.0.0.1:6000
|
|
199
|
-
-c, --redis-client <ioredis|redis> Redis client. Valid options are: ioredis, redis. (default: "ioredis")
|
|
200
|
-
-r, --redis-host <string> Redis server host (default: "127.0.0.1")
|
|
201
|
-
-o, --redis-port <number> Redis server port (default: "6379")
|
|
202
|
-
-d, --redis-db <number> Redis database number (default: "0")
|
|
203
|
-
-e, --enable-log <0|1> Enable console logging. Valid options are: 0, 1 (default: "0")
|
|
204
|
-
-v, --log-level <0|1|2|3> Log level. Numbers: 0=DEBUG, 1=INFO, 2=WARN, 3=ERROR (default: "1")
|
|
205
|
-
-h, --help display help for command
|
|
206
|
-
```
|
|
39
|
+
For in-depth guides and API references, see [the documentation page](https://github.com/weyoss/redis-smq/tree/master/packages/redis-smq-web-server/docs/README.md).
|
|
207
40
|
|
|
208
|
-
##
|
|
41
|
+
## Related packages
|
|
209
42
|
|
|
210
|
-
-
|
|
211
|
-
-
|
|
212
|
-
|
|
213
|
-
-
|
|
214
|
-
- If you also proxy the API to an external service, combine with `--api-proxy-target`:
|
|
215
|
-
- Client → reverse proxy → web server (/redis-smq)
|
|
216
|
-
- Web server proxies /redis-smq/api, /redis-smq/docs, /redis-smq/assets → external API
|
|
43
|
+
- [redis-smq](https://github.com/weyoss/redis-smq/tree/master/packages/redis-smq/README.md): Core message queue
|
|
44
|
+
- [redis-smq-common](https://github.com/weyoss/redis-smq/tree/master/packages/redis-smq-common/README.md): Shared components/utilities
|
|
45
|
+
- [redis-smq-rest-api](https://github.com/weyoss/redis-smq/tree/master/packages/redis-smq-rest-api/README.md): REST API with OpenAPI v3 and Swagger UI
|
|
46
|
+
- [redis-smq-web-ui](https://github.com/weyoss/redis-smq/tree/master/packages/redis-smq-web-ui/README.md): SPA for monitoring and managing RedisSMQ
|
|
217
47
|
|
|
218
48
|
## License
|
|
219
49
|
|
|
220
|
-
RedisSMQ Web Server is
|
|
50
|
+
RedisSMQ Web Server is released under the [MIT License](https://github.com/weyoss/redis-smq/tree/master/LICENSE).
|
package/dist/cjs/bin/cli.js
CHANGED
|
@@ -17,7 +17,7 @@ program
|
|
|
17
17
|
program
|
|
18
18
|
.option('-p, --port <number>', 'Port to run the server on', String((_a = parse_config_js_1.defaultConfig.webServer) === null || _a === void 0 ? void 0 : _a.port))
|
|
19
19
|
.option('-b, --base-path <string>', 'Base public path for the RedisSMQ Web UI SPA', (_b = parse_config_js_1.defaultConfig.webServer) === null || _b === void 0 ? void 0 : _b.basePath)
|
|
20
|
-
.option('-t, --api-proxy-target <string>', 'Proxy target for API (/api, /
|
|
20
|
+
.option('-t, --api-proxy-target <string>', 'Proxy target for API (/api, /swagger). Example: http://127.0.0.1:6000', (_c = parse_config_js_1.defaultConfig.webServer) === null || _c === void 0 ? void 0 : _c.apiProxyTarget)
|
|
21
21
|
.option('-c, --redis-client <ioredis|redis>', 'Redis client. Valid options are: ioredis, redis.', redis_smq_1.defaultConfig.redis.client)
|
|
22
22
|
.option('-r, --redis-host <string>', 'Redis server host', redis_smq_1.defaultConfig.redis.options.host)
|
|
23
23
|
.option('-o, --redis-port <number>', 'Redis server port', String(redis_smq_1.defaultConfig.redis.options.port))
|
|
@@ -32,10 +32,6 @@ const config = {
|
|
|
32
32
|
basePath: options.basePath,
|
|
33
33
|
apiProxyTarget: options.apiProxyTarget,
|
|
34
34
|
},
|
|
35
|
-
apiServer: {
|
|
36
|
-
port: Number(options.port),
|
|
37
|
-
basePath: options.basePath,
|
|
38
|
-
},
|
|
39
35
|
redis: {
|
|
40
36
|
client: options.redisClient,
|
|
41
37
|
options: {
|
package/dist/cjs/bin/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../bin/cli.ts"],"names":[],"mappings":";;;;AAWA,yCAAoC;AACpC,8CAAoD;AAKpD,mEAA8D;AAC9D,uDAAuD;AACvD,yCAAmE;AAEnE,MAAM,eAAe,GACnB,OAAO,yBAAqB,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,KAAK,QA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OAAO,CAAC,SAAS;YACvB,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC;YAC/B,EAAE,EAAE,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;SAC5B;KACF;IACD,MAAM,EAAE;QACN,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAC3C,OAAO,EAAE;YACP,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC;SACnC;KACF;CACF,CAAC;AAEF,MAAM,MAAM,GAAG,IAAI,4BAAiB,CAAC,MAAM,CAAC,CAAC;AAC7C,MAAM,CAAC,GAAG,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-config.d.ts","sourceRoot":"","sources":["../../../../src/config/parse-config.ts"],"names":[],"mappings":"AASA,OAAO,EACL,wBAAwB,EACxB,8BAA8B,EAC/B,MAAM,kBAAkB,CAAC;AAG1B,eAAO,MAAM,aAAa,EAAE,wBAM3B,CAAC;AAMF,wBAAgB,WAAW,CACzB,MAAM,GAAE,OAAO,CAAC,wBAAwB,CAAM,GAC7C,8BAA8B,
|
|
1
|
+
{"version":3,"file":"parse-config.d.ts","sourceRoot":"","sources":["../../../../src/config/parse-config.ts"],"names":[],"mappings":"AASA,OAAO,EACL,wBAAwB,EACxB,8BAA8B,EAC/B,MAAM,kBAAkB,CAAC;AAG1B,eAAO,MAAM,aAAa,EAAE,wBAM3B,CAAC;AAMF,wBAAgB,WAAW,CACzB,MAAM,GAAE,OAAO,CAAC,wBAAwB,CAAM,GAC7C,8BAA8B,CA0ChC"}
|
|
@@ -11,11 +11,23 @@ exports.defaultConfig = {
|
|
|
11
11
|
},
|
|
12
12
|
};
|
|
13
13
|
function parseConfig(config = {}) {
|
|
14
|
+
var _a;
|
|
14
15
|
const restApiParsedConfig = (0, redis_smq_rest_api_1.parseConfig)(config);
|
|
16
|
+
const normalizePath = (path) => {
|
|
17
|
+
const s = path
|
|
18
|
+
.split('/')
|
|
19
|
+
.map((i) => i.trim())
|
|
20
|
+
.filter((i) => !!i)
|
|
21
|
+
.join('/');
|
|
22
|
+
return `/${s}`;
|
|
23
|
+
};
|
|
24
|
+
const basePath = ((_a = config.webServer) === null || _a === void 0 ? void 0 : _a.basePath) !== undefined
|
|
25
|
+
? normalizePath(config.webServer.basePath)
|
|
26
|
+
: restApiParsedConfig.apiServer.basePath;
|
|
15
27
|
const webServer = Object.assign(Object.assign({}, exports.defaultConfig.webServer), config.webServer);
|
|
16
|
-
return Object.assign(Object.assign({}, restApiParsedConfig), { webServer: {
|
|
28
|
+
return Object.assign(Object.assign({}, restApiParsedConfig), { apiServer: Object.assign(Object.assign({}, restApiParsedConfig.apiServer), { basePath: basePath }), webServer: {
|
|
17
29
|
port: Number(webServer.port),
|
|
18
|
-
basePath:
|
|
30
|
+
basePath: basePath,
|
|
19
31
|
apiProxyTarget: webServer.apiProxyTarget
|
|
20
32
|
? String(webServer.apiProxyTarget)
|
|
21
33
|
: undefined,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-config.js","sourceRoot":"","sources":["../../../../src/config/parse-config.ts"],"names":[],"mappings":";;;AA2BA,
|
|
1
|
+
{"version":3,"file":"parse-config.js","sourceRoot":"","sources":["../../../../src/config/parse-config.ts"],"names":[],"mappings":";;;AA2BA,kCA4CC;AA1DD,2DAAuE;AAE1D,QAAA,aAAa,GAA6B;IACrD,SAAS,EAAE;QACT,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE,GAAG;QACb,cAAc,EAAE,SAAS;KAC1B;CACF,CAAC;AAMF,SAAgB,WAAW,CACzB,SAA4C,EAAE;;IAE9C,MAAM,mBAAmB,GAAG,IAAA,gCAAkB,EAAC,MAAM,CAAC,CAAC;IAIvD,MAAM,aAAa,GAAG,CAAC,IAAY,EAAU,EAAE;QAC7C,MAAM,CAAC,GAAG,IAAI;aACX,KAAK,CAAC,GAAG,CAAC;aACV,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;aACpB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;aAClB,IAAI,CAAC,GAAG,CAAC,CAAC;QACb,OAAO,IAAI,CAAC,EAAE,CAAC;IACjB,CAAC,CAAC;IAKF,MAAM,QAAQ,GACZ,CAAA,MAAA,MAAM,CAAC,SAAS,0CAAE,QAAQ,MAAK,SAAS;QACtC,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC;QAC1C,CAAC,CAAC,mBAAmB,CAAC,SAAS,CAAC,QAAQ,CAAC;IAG7C,MAAM,SAAS,mCACV,qBAAa,CAAC,SAAS,GACvB,MAAM,CAAC,SAAS,CACpB,CAAC;IAEF,uCACK,mBAAmB,KACtB,SAAS,kCACJ,mBAAmB,CAAC,SAAS,KAChC,QAAQ,EAAE,QAAQ,KAEpB,SAAS,EAAE;YACT,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC;YAC5B,QAAQ,EAAE,QAAQ;YAClB,cAAc,EAAE,SAAS,CAAC,cAAc;gBACtC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC;gBAClC,CAAC,CAAC,SAAS;SACd,IACD;AACJ,CAAC"}
|
|
@@ -11,7 +11,7 @@ export interface IRedisSMQWebServerCliOptions {
|
|
|
11
11
|
logLevel: EConsoleLoggerLevel;
|
|
12
12
|
apiProxyTarget?: string;
|
|
13
13
|
}
|
|
14
|
-
export interface IRedisSMQWebServerConfig extends IRedisSMQRestApiConfig {
|
|
14
|
+
export interface IRedisSMQWebServerConfig extends Omit<IRedisSMQRestApiConfig, 'apiServer'> {
|
|
15
15
|
webServer?: {
|
|
16
16
|
port?: number;
|
|
17
17
|
basePath?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/config/types/index.ts"],"names":[],"mappings":"AASA,OAAO,EACL,sBAAsB,EACtB,4BAA4B,EAC7B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/config/types/index.ts"],"names":[],"mappings":"AASA,OAAO,EACL,sBAAsB,EACtB,4BAA4B,EAC7B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAK3E,MAAM,WAAW,4BAA4B;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,kBAAkB,CAAC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,mBAAmB,CAAC;IAK9B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAWD,MAAM,WAAW,wBACf,SAAQ,IAAI,CAAC,sBAAsB,EAAE,WAAW,CAAC;IACjD,SAAS,CAAC,EAAE;QAKV,IAAI,CAAC,EAAE,MAAM,CAAC;QAQd,QAAQ,CAAC,EAAE,MAAM,CAAC;QASlB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;CACH;AAMD,MAAM,WAAW,8BACf,SAAQ,4BAA4B;IACpC,SAAS,EAAE;QACT,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QAKjB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;CACH"}
|
package/dist/cjs/src/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAcA,OAAO,EACL,wBAAwB,EAEzB,MAAM,yBAAyB,CAAC;AAKjC,OAAO,EAAgB,OAAO,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAcA,OAAO,EACL,wBAAwB,EAEzB,MAAM,yBAAyB,CAAC;AAKjC,OAAO,EAAgB,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAMzD,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAa;IACjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiC;IACxD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAuB;IACnD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAuB;IACtD,OAAO,CAAC,OAAO,CAAgC;IAC/C,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,UAAU,CAA4B;IAC9C,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC;gBAEd,MAAM,GAAE,wBAA6B;YAYnC,eAAe;YA0Bf,QAAQ;IAsCtB,OAAO,CAAC,aAAa;YAeP,WAAW;YA6BX,SAAS;IAQV,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAepB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAgBvC"}
|
package/dist/cjs/src/index.js
CHANGED
|
@@ -32,7 +32,7 @@ class RedisSMQWebServer {
|
|
|
32
32
|
this.config = (0, parse_config_js_1.parseConfig)(config);
|
|
33
33
|
this.webUIConfig = {
|
|
34
34
|
BASE_PATH: this.config.webServer.basePath,
|
|
35
|
-
API_URL:
|
|
35
|
+
API_URL: this.config.webServer.basePath,
|
|
36
36
|
};
|
|
37
37
|
this.apiProxyTarget = (_a = this.config.webServer.apiProxyTarget) !== null && _a !== void 0 ? _a : null;
|
|
38
38
|
this.webUIPath = (0, redis_smq_web_ui_1.getDistPath)();
|
|
@@ -40,12 +40,15 @@ class RedisSMQWebServer {
|
|
|
40
40
|
}
|
|
41
41
|
setupMiddleware() {
|
|
42
42
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
-
this.
|
|
43
|
+
const { basePath } = this.config.webServer;
|
|
44
|
+
this.app.set('trust proxy', true);
|
|
45
|
+
this.logger.info('Trusting reverse proxy headers.');
|
|
46
|
+
this.app.use(basePath, express_1.default.static(this.webUIPath, {
|
|
44
47
|
etag: true,
|
|
45
48
|
lastModified: true,
|
|
46
49
|
index: false,
|
|
47
50
|
setHeaders: (res, filePath) => {
|
|
48
|
-
if (filePath.match(/\.(
|
|
51
|
+
if (filePath.match(/\.(png|jpg|jpeg|gif|ico|svg|css|js)$/)) {
|
|
49
52
|
res.setHeader('Cache-Control', 'public, max-age=86400');
|
|
50
53
|
}
|
|
51
54
|
else {
|
|
@@ -57,38 +60,67 @@ class RedisSMQWebServer {
|
|
|
57
60
|
}
|
|
58
61
|
setupApi() {
|
|
59
62
|
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
const basePath = this.config.webServer.basePath;
|
|
64
|
+
const apiPath = path_1.default.posix.join(basePath, 'api');
|
|
65
|
+
const swaggerPath = path_1.default.posix.join(basePath, 'swagger');
|
|
66
|
+
const apiBasePaths = [apiPath, swaggerPath];
|
|
67
|
+
const isApiRequest = (path) => apiBasePaths.some((base) => path === base || path.startsWith(`${base}/`));
|
|
60
68
|
const target = this.config.webServer.apiProxyTarget;
|
|
61
69
|
if (target) {
|
|
62
|
-
const
|
|
70
|
+
const proxy = (0, http_proxy_middleware_1.createProxyMiddleware)({
|
|
63
71
|
target,
|
|
64
72
|
changeOrigin: true,
|
|
65
73
|
ws: true,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
74
|
+
});
|
|
75
|
+
this.app.use((req, res, next) => {
|
|
76
|
+
if (isApiRequest(req.path)) {
|
|
77
|
+
return proxy(req, res, next);
|
|
78
|
+
}
|
|
79
|
+
next();
|
|
80
|
+
});
|
|
71
81
|
return;
|
|
72
82
|
}
|
|
73
83
|
this.restApi = new redis_smq_rest_api_1.RedisSMQRestApi(this.config, false);
|
|
74
84
|
const restApiCallback = yield this.restApi.getApplication();
|
|
75
|
-
this.app.use(
|
|
85
|
+
this.app.use((req, res, next) => {
|
|
86
|
+
if (isApiRequest(req.path)) {
|
|
87
|
+
return restApiCallback(req, res);
|
|
88
|
+
}
|
|
89
|
+
next();
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
sendIndexHtml(res) {
|
|
94
|
+
const indexPath = path_1.default.join(this.webUIPath, 'index.html');
|
|
95
|
+
fs_1.default.readFile(indexPath, 'utf8', (err, data) => {
|
|
96
|
+
if (err) {
|
|
97
|
+
this.logger.error('Error reading index.html:', err);
|
|
98
|
+
return res.status(500).send('Error loading application');
|
|
99
|
+
}
|
|
100
|
+
const configScript = `<script>window.configs = ${JSON.stringify(this.webUIConfig)};</script>`;
|
|
101
|
+
const modifiedHtml = data.replace('</head>', `${configScript}</head>`);
|
|
102
|
+
res.send(modifiedHtml);
|
|
76
103
|
});
|
|
77
104
|
}
|
|
78
105
|
setupRoutes() {
|
|
79
106
|
return __awaiter(this, void 0, void 0, function* () {
|
|
80
107
|
yield this.setupApi();
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
108
|
+
const { basePath } = this.config.webServer;
|
|
109
|
+
if (basePath !== '/') {
|
|
110
|
+
this.app.get('/', (_req, res) => res.redirect(basePath));
|
|
111
|
+
}
|
|
112
|
+
this.app.get('*', (req, res, next) => {
|
|
113
|
+
if (req.path.startsWith(path_1.default.posix.join(basePath, 'api')) ||
|
|
114
|
+
req.path.startsWith(path_1.default.posix.join(basePath, 'swagger'))) {
|
|
115
|
+
return next();
|
|
116
|
+
}
|
|
117
|
+
if (path_1.default.extname(req.path)) {
|
|
118
|
+
return next();
|
|
119
|
+
}
|
|
120
|
+
if (req.headers.accept && !req.headers.accept.includes('text/html')) {
|
|
121
|
+
return next();
|
|
122
|
+
}
|
|
123
|
+
this.sendIndexHtml(res);
|
|
92
124
|
});
|
|
93
125
|
});
|
|
94
126
|
}
|
|
@@ -114,6 +146,7 @@ class RedisSMQWebServer {
|
|
|
114
146
|
this.logger.info(`Embedded Redis SMQ REST API is mounted`);
|
|
115
147
|
}
|
|
116
148
|
this.logger.info(`Serving static assets from: ${this.webUIPath}`);
|
|
149
|
+
this.logger.info(`Base path: ${this.config.webServer.basePath || '/'}`);
|
|
117
150
|
});
|
|
118
151
|
});
|
|
119
152
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AASA,sDAA8B;AAC9B,gDAAwB;AACxB,4CAAoB;AAEpB,uDAA+C;AAK/C,2DAAqD;AACrD,8DAAuD;AAEvD,iEAA8D;AAC9D,uDAAyD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AASA,sDAA8B;AAC9B,gDAAwB;AACxB,4CAAoB;AAEpB,uDAA+C;AAK/C,2DAAqD;AACrD,8DAAuD;AAEvD,iEAA8D;AAC9D,uDAAyD;AAMzD,MAAa,iBAAiB;IAW5B,YAAY,SAAmC,EAAE;;QAVhC,QAAG,GAAG,IAAA,iBAAO,GAAE,CAAC;QAIhB,mBAAc,GAAkB,IAAI,CAAC;QAC9C,YAAO,GAA2B,IAAI,CAAC;QACvC,iBAAY,GAAG,KAAK,CAAC;QACrB,eAAU,GAAuB,IAAI,CAAC;QAK5C,IAAI,CAAC,MAAM,GAAG,IAAA,6BAAW,EAAC,MAAM,CAAC,CAAC;QAClC,IAAI,CAAC,WAAW,GAAG;YACjB,SAAS,EA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3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../tests/common/config.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAE3E,eAAO,MAAM,MAAM,EAAE,wBAkBpB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.config = void 0;
|
|
4
|
+
const redis_smq_common_1 = require("redis-smq-common");
|
|
5
|
+
exports.config = {
|
|
6
|
+
redis: {
|
|
7
|
+
client: redis_smq_common_1.ERedisConfigClient.IOREDIS,
|
|
8
|
+
options: {
|
|
9
|
+
host: '127.0.0.1',
|
|
10
|
+
port: 0,
|
|
11
|
+
showFriendlyErrorStack: true,
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
logger: {
|
|
15
|
+
enabled: false,
|
|
16
|
+
options: {
|
|
17
|
+
logLevel: 'DEBUG',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
webServer: {
|
|
21
|
+
port: 8080,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../tests/common/config.ts"],"names":[],"mappings":";;;AASA,uDAAsD;AAGzC,QAAA,MAAM,GAA6B;IAC9C,KAAK,EAAE;QACL,MAAM,EAAE,qCAAkB,CAAC,OAAO;QAClC,OAAO,EAAE;YACP,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,CAAC;YACP,sBAAsB,EAAE,IAAI;SAC7B;KACF;IACD,MAAM,EAAE;QACN,OAAO,EAAE,KAAK;QACd,OAAO,EAAE;YACP,QAAQ,EAAE,OAAO;SAClB;KACF;IACD,SAAS,EAAE;QACT,IAAI,EAAE,IAAI;KACX;CACF,CAAC"}
|