@qwickapps/server 1.2.0 → 1.3.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/README.md +238 -0
- package/dist/core/control-panel.d.ts +7 -2
- package/dist/core/control-panel.d.ts.map +1 -1
- package/dist/core/control-panel.js +92 -54
- package/dist/core/control-panel.js.map +1 -1
- package/dist/core/gateway.d.ts +159 -79
- package/dist/core/gateway.d.ts.map +1 -1
- package/dist/core/gateway.js +679 -319
- package/dist/core/gateway.js.map +1 -1
- package/dist/core/index.d.ts +3 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +2 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/plugin-registry.d.ts +271 -0
- package/dist/core/plugin-registry.d.ts.map +1 -0
- package/dist/core/plugin-registry.js +326 -0
- package/dist/core/plugin-registry.js.map +1 -0
- package/dist/core/types.d.ts +16 -33
- package/dist/core/types.d.ts.map +1 -1
- package/dist/index.d.ts +8 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -7
- package/dist/index.js.map +1 -1
- package/dist/plugins/auth/adapters/auth0-adapter.d.ts +14 -0
- package/dist/plugins/auth/adapters/auth0-adapter.d.ts.map +1 -0
- package/dist/plugins/auth/adapters/auth0-adapter.js +179 -0
- package/dist/plugins/auth/adapters/auth0-adapter.js.map +1 -0
- package/dist/plugins/auth/adapters/basic-adapter.d.ts +13 -0
- package/dist/plugins/auth/adapters/basic-adapter.d.ts.map +1 -0
- package/dist/plugins/auth/adapters/basic-adapter.js +51 -0
- package/dist/plugins/auth/adapters/basic-adapter.js.map +1 -0
- package/dist/plugins/auth/adapters/index.d.ts +9 -0
- package/dist/plugins/auth/adapters/index.d.ts.map +1 -0
- package/dist/plugins/auth/adapters/index.js +9 -0
- package/dist/plugins/auth/adapters/index.js.map +1 -0
- package/dist/plugins/auth/adapters/supabase-adapter.d.ts +13 -0
- package/dist/plugins/auth/adapters/supabase-adapter.d.ts.map +1 -0
- package/dist/plugins/auth/adapters/supabase-adapter.js +109 -0
- package/dist/plugins/auth/adapters/supabase-adapter.js.map +1 -0
- package/dist/plugins/auth/auth-plugin.d.ts +40 -0
- package/dist/plugins/auth/auth-plugin.d.ts.map +1 -0
- package/dist/plugins/auth/auth-plugin.js +255 -0
- package/dist/plugins/auth/auth-plugin.js.map +1 -0
- package/dist/plugins/auth/auth-plugin.test.d.ts +9 -0
- package/dist/plugins/auth/auth-plugin.test.d.ts.map +1 -0
- package/dist/plugins/auth/auth-plugin.test.js +147 -0
- package/dist/plugins/auth/auth-plugin.test.js.map +1 -0
- package/dist/plugins/auth/index.d.ts +12 -0
- package/dist/plugins/auth/index.d.ts.map +1 -0
- package/dist/plugins/auth/index.js +13 -0
- package/dist/plugins/auth/index.js.map +1 -0
- package/dist/plugins/auth/types.d.ts +148 -0
- package/dist/plugins/auth/types.d.ts.map +1 -0
- package/dist/plugins/auth/types.js +14 -0
- package/dist/plugins/auth/types.js.map +1 -0
- package/dist/plugins/bans/bans-plugin.d.ts +59 -0
- package/dist/plugins/bans/bans-plugin.d.ts.map +1 -0
- package/dist/plugins/bans/bans-plugin.js +428 -0
- package/dist/plugins/bans/bans-plugin.js.map +1 -0
- package/dist/plugins/bans/index.d.ts +9 -0
- package/dist/plugins/bans/index.d.ts.map +1 -0
- package/dist/plugins/bans/index.js +10 -0
- package/dist/plugins/bans/index.js.map +1 -0
- package/dist/plugins/bans/stores/index.d.ts +7 -0
- package/dist/plugins/bans/stores/index.d.ts.map +1 -0
- package/dist/plugins/bans/stores/index.js +7 -0
- package/dist/plugins/bans/stores/index.js.map +1 -0
- package/dist/plugins/bans/stores/postgres-store.d.ts +29 -0
- package/dist/plugins/bans/stores/postgres-store.d.ts.map +1 -0
- package/dist/plugins/bans/stores/postgres-store.js +132 -0
- package/dist/plugins/bans/stores/postgres-store.js.map +1 -0
- package/dist/plugins/bans/types.d.ts +128 -0
- package/dist/plugins/bans/types.d.ts.map +1 -0
- package/dist/plugins/bans/types.js +11 -0
- package/dist/plugins/bans/types.js.map +1 -0
- package/dist/plugins/cache-plugin.d.ts +14 -3
- package/dist/plugins/cache-plugin.d.ts.map +1 -1
- package/dist/plugins/cache-plugin.js +27 -7
- package/dist/plugins/cache-plugin.js.map +1 -1
- package/dist/plugins/cache-plugin.test.js +96 -32
- package/dist/plugins/cache-plugin.test.js.map +1 -1
- package/dist/plugins/config-plugin.d.ts +3 -2
- package/dist/plugins/config-plugin.d.ts.map +1 -1
- package/dist/plugins/config-plugin.js +17 -10
- package/dist/plugins/config-plugin.js.map +1 -1
- package/dist/plugins/diagnostics-plugin.d.ts +2 -2
- package/dist/plugins/diagnostics-plugin.d.ts.map +1 -1
- package/dist/plugins/diagnostics-plugin.js +17 -10
- package/dist/plugins/diagnostics-plugin.js.map +1 -1
- package/dist/plugins/entitlements/entitlements-plugin.d.ts +95 -0
- package/dist/plugins/entitlements/entitlements-plugin.d.ts.map +1 -0
- package/dist/plugins/entitlements/entitlements-plugin.js +707 -0
- package/dist/plugins/entitlements/entitlements-plugin.js.map +1 -0
- package/dist/plugins/entitlements/index.d.ts +12 -0
- package/dist/plugins/entitlements/index.d.ts.map +1 -0
- package/dist/plugins/entitlements/index.js +16 -0
- package/dist/plugins/entitlements/index.js.map +1 -0
- package/dist/plugins/entitlements/sources/index.d.ts +9 -0
- package/dist/plugins/entitlements/sources/index.d.ts.map +1 -0
- package/dist/plugins/entitlements/sources/index.js +9 -0
- package/dist/plugins/entitlements/sources/index.js.map +1 -0
- package/dist/plugins/entitlements/sources/postgres-source.d.ts +29 -0
- package/dist/plugins/entitlements/sources/postgres-source.d.ts.map +1 -0
- package/dist/plugins/entitlements/sources/postgres-source.js +169 -0
- package/dist/plugins/entitlements/sources/postgres-source.js.map +1 -0
- package/dist/plugins/entitlements/types.d.ts +232 -0
- package/dist/plugins/entitlements/types.d.ts.map +1 -0
- package/dist/plugins/entitlements/types.js +11 -0
- package/dist/plugins/entitlements/types.js.map +1 -0
- package/dist/plugins/frontend-app-plugin.d.ts +9 -3
- package/dist/plugins/frontend-app-plugin.d.ts.map +1 -1
- package/dist/plugins/frontend-app-plugin.js +14 -9
- package/dist/plugins/frontend-app-plugin.js.map +1 -1
- package/dist/plugins/health-plugin.d.ts +5 -2
- package/dist/plugins/health-plugin.d.ts.map +1 -1
- package/dist/plugins/health-plugin.js +20 -5
- package/dist/plugins/health-plugin.js.map +1 -1
- package/dist/plugins/index.d.ts +8 -2
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/index.js +8 -2
- package/dist/plugins/index.js.map +1 -1
- package/dist/plugins/logs-plugin.d.ts +3 -2
- package/dist/plugins/logs-plugin.d.ts.map +1 -1
- package/dist/plugins/logs-plugin.js +21 -12
- package/dist/plugins/logs-plugin.js.map +1 -1
- package/dist/plugins/postgres-plugin.d.ts +3 -3
- package/dist/plugins/postgres-plugin.d.ts.map +1 -1
- package/dist/plugins/postgres-plugin.js +9 -7
- package/dist/plugins/postgres-plugin.js.map +1 -1
- package/dist/plugins/postgres-plugin.test.js +47 -29
- package/dist/plugins/postgres-plugin.test.js.map +1 -1
- package/dist/plugins/users/index.d.ts +12 -0
- package/dist/plugins/users/index.d.ts.map +1 -0
- package/dist/plugins/users/index.js +13 -0
- package/dist/plugins/users/index.js.map +1 -0
- package/dist/plugins/users/stores/index.d.ts +7 -0
- package/dist/plugins/users/stores/index.d.ts.map +1 -0
- package/dist/plugins/users/stores/index.js +7 -0
- package/dist/plugins/users/stores/index.js.map +1 -0
- package/dist/plugins/users/stores/postgres-store.d.ts +28 -0
- package/dist/plugins/users/stores/postgres-store.d.ts.map +1 -0
- package/dist/plugins/users/stores/postgres-store.js +157 -0
- package/dist/plugins/users/stores/postgres-store.js.map +1 -0
- package/dist/plugins/users/types.d.ts +189 -0
- package/dist/plugins/users/types.d.ts.map +1 -0
- package/dist/plugins/users/types.js +12 -0
- package/dist/plugins/users/types.js.map +1 -0
- package/dist/plugins/users/users-plugin.d.ts +39 -0
- package/dist/plugins/users/users-plugin.d.ts.map +1 -0
- package/dist/plugins/users/users-plugin.js +242 -0
- package/dist/plugins/users/users-plugin.js.map +1 -0
- package/dist-ui/assets/index-Bsp2ntcw.js +465 -0
- package/dist-ui/assets/index-Bsp2ntcw.js.map +1 -0
- package/dist-ui/index.html +1 -1
- package/dist-ui-lib/api/controlPanelApi.d.ts +232 -0
- package/dist-ui-lib/components/ControlPanelApp.d.ts +61 -0
- package/dist-ui-lib/components/index.d.ts +18 -0
- package/dist-ui-lib/config/AppConfig.d.ts +7 -0
- package/dist-ui-lib/dashboard/DashboardWidgetRegistry.d.ts +62 -0
- package/dist-ui-lib/dashboard/DashboardWidgetRenderer.d.ts +8 -0
- package/dist-ui-lib/dashboard/PluginWidgetRenderer.d.ts +19 -0
- package/dist-ui-lib/dashboard/WidgetComponentRegistry.d.ts +44 -0
- package/dist-ui-lib/dashboard/builtInWidgets.d.ts +19 -0
- package/dist-ui-lib/dashboard/index.d.ts +13 -0
- package/dist-ui-lib/dashboard/widgets/ServiceHealthWidget.d.ts +12 -0
- package/dist-ui-lib/dashboard/widgets/index.d.ts +6 -0
- package/dist-ui-lib/index.js +6441 -0
- package/dist-ui-lib/index.js.map +1 -0
- package/dist-ui-lib/pages/ConfigPage.d.ts +1 -0
- package/dist-ui-lib/pages/DashboardPage.d.ts +1 -0
- package/dist-ui-lib/pages/DiagnosticsPage.d.ts +1 -0
- package/dist-ui-lib/pages/EntitlementsPage.d.ts +17 -0
- package/dist-ui-lib/pages/LogsPage.d.ts +1 -0
- package/dist-ui-lib/pages/NotFoundPage.d.ts +1 -0
- package/dist-ui-lib/pages/PluginPage.d.ts +15 -0
- package/dist-ui-lib/pages/SystemPage.d.ts +1 -0
- package/dist-ui-lib/pages/UsersPage.d.ts +22 -0
- package/package.json +18 -6
- package/src/core/control-panel.ts +114 -61
- package/src/core/gateway.ts +863 -403
- package/src/core/index.ts +21 -2
- package/src/core/plugin-registry.ts +653 -0
- package/src/core/types.ts +31 -37
- package/src/index.ts +118 -19
- package/src/plugins/auth/adapters/auth0-adapter.ts +214 -0
- package/src/plugins/auth/adapters/basic-adapter.ts +61 -0
- package/src/plugins/auth/adapters/index.ts +9 -0
- package/src/plugins/auth/adapters/supabase-adapter.ts +141 -0
- package/src/plugins/auth/auth-plugin.test.ts +176 -0
- package/src/plugins/auth/auth-plugin.ts +303 -0
- package/src/plugins/auth/index.ts +33 -0
- package/src/plugins/auth/types.ts +165 -0
- package/src/plugins/bans/bans-plugin.ts +485 -0
- package/src/plugins/bans/index.ts +31 -0
- package/src/plugins/bans/stores/index.ts +7 -0
- package/src/plugins/bans/stores/postgres-store.ts +195 -0
- package/src/plugins/bans/types.ts +141 -0
- package/src/plugins/cache-plugin.test.ts +105 -32
- package/src/plugins/cache-plugin.ts +40 -9
- package/src/plugins/config-plugin.ts +23 -12
- package/src/plugins/diagnostics-plugin.ts +22 -12
- package/src/plugins/entitlements/entitlements-plugin.ts +820 -0
- package/src/plugins/entitlements/index.ts +51 -0
- package/src/plugins/entitlements/sources/index.ts +9 -0
- package/src/plugins/entitlements/sources/postgres-source.ts +253 -0
- package/src/plugins/entitlements/types.ts +256 -0
- package/src/plugins/frontend-app-plugin.ts +24 -12
- package/src/plugins/health-plugin.ts +27 -7
- package/src/plugins/index.ts +106 -4
- package/src/plugins/logs-plugin.ts +28 -14
- package/src/plugins/postgres-plugin.test.ts +49 -29
- package/src/plugins/postgres-plugin.ts +11 -9
- package/src/plugins/users/index.ts +35 -0
- package/src/plugins/users/stores/index.ts +7 -0
- package/src/plugins/users/stores/postgres-store.ts +225 -0
- package/src/plugins/users/types.ts +209 -0
- package/src/plugins/users/users-plugin.ts +281 -0
- package/ui/src/App.tsx +185 -31
- package/ui/src/api/controlPanelApi.ts +354 -1
- package/ui/src/components/ControlPanelApp.tsx +209 -0
- package/ui/src/components/index.ts +62 -0
- package/ui/src/dashboard/DashboardWidgetRegistry.tsx +129 -0
- package/ui/src/dashboard/DashboardWidgetRenderer.tsx +34 -0
- package/ui/src/dashboard/PluginWidgetRenderer.tsx +115 -0
- package/ui/src/dashboard/WidgetComponentRegistry.tsx +116 -0
- package/ui/src/dashboard/builtInWidgets.tsx +29 -0
- package/ui/src/dashboard/index.ts +35 -0
- package/ui/src/dashboard/widgets/ServiceHealthWidget.tsx +140 -0
- package/ui/src/dashboard/widgets/index.ts +7 -0
- package/ui/src/pages/DashboardPage.tsx +28 -149
- package/ui/src/pages/EntitlementsPage.tsx +557 -0
- package/ui/src/pages/LogsPage.tsx +174 -8
- package/ui/src/pages/PluginPage.tsx +148 -0
- package/ui/src/pages/SystemPage.tsx +445 -0
- package/ui/src/pages/UsersPage.tsx +837 -0
- package/ui/tsconfig.lib.json +11 -0
- package/ui/vite.lib.config.ts +51 -0
- package/dist-ui/assets/index-CW1BviRn.js +0 -465
- package/dist-ui/assets/index-CW1BviRn.js.map +0 -1
- package/ui/src/pages/HealthPage.tsx +0 -204
package/dist/core/gateway.d.ts
CHANGED
|
@@ -2,63 +2,162 @@
|
|
|
2
2
|
* Gateway Server for @qwickapps/server
|
|
3
3
|
*
|
|
4
4
|
* Provides a production-ready gateway pattern that:
|
|
5
|
-
* 1.
|
|
6
|
-
* 2.
|
|
7
|
-
* 3.
|
|
5
|
+
* 1. Proxies multiple apps mounted at configurable paths
|
|
6
|
+
* 2. Each app runs at `/` on its own internal port
|
|
7
|
+
* 3. Gateway handles path rewriting automatically
|
|
8
|
+
* 4. Provides health and diagnostics endpoints
|
|
8
9
|
*
|
|
9
10
|
* Architecture:
|
|
10
|
-
* Internet → Gateway (
|
|
11
|
+
* Internet → Gateway (:3000) → [Control Panel (:3001), Admin (:3002), API (:3003), ...]
|
|
11
12
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
13
|
+
* Port Scheme:
|
|
14
|
+
* - 3000: Gateway (public)
|
|
15
|
+
* - 3001: Control Panel
|
|
16
|
+
* - 3002+: Additional apps
|
|
17
|
+
*
|
|
18
|
+
* Each app is isolated and can be served from any mount path without rebuilding.
|
|
14
19
|
*
|
|
15
20
|
* Copyright (c) 2025 QwickApps.com. All rights reserved.
|
|
16
21
|
*/
|
|
17
22
|
import type { Application } from 'express';
|
|
18
23
|
import type { Server } from 'http';
|
|
19
|
-
import type { ControlPanelConfig,
|
|
24
|
+
import type { ControlPanelConfig, Logger } from './types.js';
|
|
25
|
+
import type { Plugin, PluginConfig } from './plugin-registry.js';
|
|
20
26
|
import { createControlPanel } from './control-panel.js';
|
|
21
27
|
import { type LoggingConfig } from './logging.js';
|
|
28
|
+
/**
|
|
29
|
+
* Maintenance mode configuration for a mounted app
|
|
30
|
+
*/
|
|
31
|
+
export interface MaintenanceConfig {
|
|
32
|
+
/** Enable maintenance mode - blocks all requests with maintenance page */
|
|
33
|
+
enabled: boolean;
|
|
34
|
+
/** Custom page title (default: "Under Maintenance") */
|
|
35
|
+
title?: string;
|
|
36
|
+
/** Custom message to display */
|
|
37
|
+
message?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Expected time when service will be back.
|
|
40
|
+
* Can be ISO date string, relative time ("2 hours", "30 minutes"), or "soon"
|
|
41
|
+
*/
|
|
42
|
+
expectedBackAt?: string;
|
|
43
|
+
/** URL for support/contact (shows "Contact Support" link) */
|
|
44
|
+
contactUrl?: string;
|
|
45
|
+
/** Allow specific paths to bypass maintenance (e.g., ["/api/health", "/api/status"]) */
|
|
46
|
+
bypassPaths?: string[];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Fallback page configuration when a service is unavailable (proxy error)
|
|
50
|
+
*/
|
|
51
|
+
export interface FallbackConfig {
|
|
52
|
+
/** Custom page title (default: "Service Unavailable") */
|
|
53
|
+
title?: string;
|
|
54
|
+
/** Custom message (default: "This service is temporarily unavailable") */
|
|
55
|
+
message?: string;
|
|
56
|
+
/** Show "Try Again" button (default: true) */
|
|
57
|
+
showRetry?: boolean;
|
|
58
|
+
/** Auto-refresh interval in seconds (0 = disabled, default: 30) */
|
|
59
|
+
autoRefresh?: number;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Configuration for a mounted app
|
|
63
|
+
*/
|
|
64
|
+
export interface MountedAppConfig {
|
|
65
|
+
/** Mount path (e.g., '/admin', '/api') */
|
|
66
|
+
path: string;
|
|
67
|
+
/** Display name for the app (used in status pages) */
|
|
68
|
+
name?: string;
|
|
69
|
+
/** App source configuration */
|
|
70
|
+
source: {
|
|
71
|
+
/** Proxy to an internal service */
|
|
72
|
+
type: 'proxy';
|
|
73
|
+
/** Target URL (e.g., 'http://localhost:3002') */
|
|
74
|
+
target: string;
|
|
75
|
+
/** Enable WebSocket proxying */
|
|
76
|
+
ws?: boolean;
|
|
77
|
+
} | {
|
|
78
|
+
/** Serve static files */
|
|
79
|
+
type: 'static';
|
|
80
|
+
/** Path to static files directory */
|
|
81
|
+
directory: string;
|
|
82
|
+
/** Enable SPA mode (serve index.html for all routes) */
|
|
83
|
+
spa?: boolean;
|
|
84
|
+
};
|
|
85
|
+
/** Whether to strip the mount path prefix when proxying (default: true) */
|
|
86
|
+
stripPrefix?: boolean;
|
|
87
|
+
/** Route guard for this app */
|
|
88
|
+
guard?: ControlPanelConfig['guard'];
|
|
89
|
+
/**
|
|
90
|
+
* Maintenance mode configuration.
|
|
91
|
+
* When enabled, all requests to this app show a maintenance page.
|
|
92
|
+
*/
|
|
93
|
+
maintenance?: MaintenanceConfig;
|
|
94
|
+
/**
|
|
95
|
+
* Fallback page configuration for when the service is unavailable.
|
|
96
|
+
* Shown when proxy encounters connection errors (service down/crashed).
|
|
97
|
+
*/
|
|
98
|
+
fallback?: FallbackConfig;
|
|
99
|
+
}
|
|
22
100
|
/**
|
|
23
101
|
* Gateway configuration
|
|
24
102
|
*/
|
|
25
103
|
export interface GatewayConfig {
|
|
26
|
-
/** Port for the gateway (public-facing). Defaults to GATEWAY_PORT env or
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
servicePort?: number;
|
|
30
|
-
/** Product name for the control panel */
|
|
104
|
+
/** Port for the gateway (public-facing). Defaults to GATEWAY_PORT env or 3000 */
|
|
105
|
+
port?: number;
|
|
106
|
+
/** Product name for the gateway */
|
|
31
107
|
productName: string;
|
|
32
108
|
/** Product version */
|
|
33
109
|
version?: string;
|
|
34
110
|
/**
|
|
35
|
-
* URL to the product logo
|
|
36
|
-
* Used on
|
|
111
|
+
* URL path to the product logo icon (SVG, PNG, etc.).
|
|
112
|
+
* Used on landing pages and passed to the control panel React UI.
|
|
113
|
+
* Example: '/cpanel/logo.svg'
|
|
37
114
|
*/
|
|
38
|
-
|
|
39
|
-
/** Branding configuration */
|
|
115
|
+
logoIconUrl?: string;
|
|
116
|
+
/** Branding configuration (primaryColor, favicon) */
|
|
40
117
|
branding?: ControlPanelConfig['branding'];
|
|
41
118
|
/** CORS origins */
|
|
42
119
|
corsOrigins?: string[];
|
|
43
|
-
/** Control panel plugins */
|
|
44
|
-
plugins?: ControlPanelPlugin[];
|
|
45
|
-
/** Quick links for the control panel */
|
|
46
|
-
links?: ControlPanelConfig['links'];
|
|
47
|
-
/** Path to custom React UI dist folder for the control panel */
|
|
48
|
-
customUiPath?: string;
|
|
49
120
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
121
|
+
* Mounted apps configuration.
|
|
122
|
+
* Each app runs at `/` on its own port, gateway proxies to it at the configured path.
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```typescript
|
|
126
|
+
* apps: [
|
|
127
|
+
* { path: '/cpanel', source: { type: 'proxy', target: 'http://localhost:3001' } },
|
|
128
|
+
* { path: '/admin', source: { type: 'proxy', target: 'http://localhost:3002', ws: true } },
|
|
129
|
+
* { path: '/api', source: { type: 'proxy', target: 'http://localhost:3003' } },
|
|
130
|
+
* { path: '/docs', source: { type: 'static', directory: './dist-docs', spa: true } },
|
|
131
|
+
* ]
|
|
132
|
+
* ```
|
|
52
133
|
*/
|
|
53
|
-
|
|
134
|
+
apps?: MountedAppConfig[];
|
|
54
135
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
136
|
+
* Control panel configuration.
|
|
137
|
+
* The control panel is a special built-in app that can be enabled/disabled.
|
|
57
138
|
*/
|
|
58
|
-
|
|
139
|
+
controlPanel?: {
|
|
140
|
+
/** Enable the built-in control panel (default: true) */
|
|
141
|
+
enabled?: boolean;
|
|
142
|
+
/** Mount path for control panel (default: '/cpanel') */
|
|
143
|
+
path?: string;
|
|
144
|
+
/** Port for internal control panel server (default: 3001) */
|
|
145
|
+
port?: number;
|
|
146
|
+
/** Control panel plugins */
|
|
147
|
+
plugins?: Array<{
|
|
148
|
+
plugin: Plugin;
|
|
149
|
+
config?: PluginConfig;
|
|
150
|
+
}>;
|
|
151
|
+
/** Quick links */
|
|
152
|
+
links?: ControlPanelConfig['links'];
|
|
153
|
+
/** Custom UI path */
|
|
154
|
+
customUiPath?: string;
|
|
155
|
+
/** Route guard */
|
|
156
|
+
guard?: ControlPanelConfig['guard'];
|
|
157
|
+
};
|
|
59
158
|
/**
|
|
60
159
|
* Frontend app configuration for the root path (/).
|
|
61
|
-
* If not provided,
|
|
160
|
+
* If not provided, shows a default landing page with system status.
|
|
62
161
|
*/
|
|
63
162
|
frontendApp?: {
|
|
64
163
|
/** Redirect to another URL */
|
|
@@ -74,84 +173,65 @@ export interface GatewayConfig {
|
|
|
74
173
|
label: string;
|
|
75
174
|
url: string;
|
|
76
175
|
}>;
|
|
176
|
+
branding?: {
|
|
177
|
+
primaryColor?: string;
|
|
178
|
+
};
|
|
77
179
|
};
|
|
78
180
|
};
|
|
79
|
-
/**
|
|
80
|
-
* API paths to proxy to the internal service.
|
|
81
|
-
* Defaults to ['/api/v1'] if not specified.
|
|
82
|
-
* The gateway always proxies /health to the internal service.
|
|
83
|
-
*/
|
|
84
|
-
proxyPaths?: string[];
|
|
85
181
|
/** Logger instance */
|
|
86
182
|
logger?: Logger;
|
|
87
183
|
/** Logging configuration */
|
|
88
184
|
logging?: LoggingConfig;
|
|
89
185
|
}
|
|
90
|
-
/**
|
|
91
|
-
* Service factory function type
|
|
92
|
-
* Called with the service port, should return an object with:
|
|
93
|
-
* - app: Express application (or compatible)
|
|
94
|
-
* - server: HTTP server (created by calling listen)
|
|
95
|
-
* - shutdown: Async function to gracefully shut down the service
|
|
96
|
-
*/
|
|
97
|
-
export interface ServiceFactory {
|
|
98
|
-
(port: number): Promise<{
|
|
99
|
-
app: Application;
|
|
100
|
-
server: Server;
|
|
101
|
-
shutdown: () => Promise<void>;
|
|
102
|
-
}>;
|
|
103
|
-
}
|
|
104
186
|
/**
|
|
105
187
|
* Gateway instance returned by createGateway
|
|
106
188
|
*/
|
|
107
189
|
export interface GatewayInstance {
|
|
108
|
-
/** The
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
190
|
+
/** The gateway Express app */
|
|
191
|
+
app: Application;
|
|
192
|
+
/** HTTP server */
|
|
193
|
+
server: Server | null;
|
|
194
|
+
/** The internal control panel (if enabled) */
|
|
195
|
+
controlPanel: ReturnType<typeof createControlPanel> | null;
|
|
196
|
+
/** Mounted apps information */
|
|
197
|
+
mountedApps: Array<{
|
|
198
|
+
path: string;
|
|
199
|
+
type: 'proxy' | 'static';
|
|
200
|
+
target?: string;
|
|
201
|
+
}>;
|
|
202
|
+
/** Start the gateway */
|
|
117
203
|
start: () => Promise<void>;
|
|
118
204
|
/** Stop everything gracefully */
|
|
119
205
|
stop: () => Promise<void>;
|
|
120
206
|
/** Gateway port */
|
|
121
|
-
|
|
122
|
-
/** Service port */
|
|
123
|
-
servicePort: number;
|
|
207
|
+
port: number;
|
|
124
208
|
}
|
|
125
209
|
/**
|
|
126
|
-
* Create a gateway that proxies to
|
|
210
|
+
* Create a gateway that proxies to multiple internal services
|
|
127
211
|
*
|
|
128
212
|
* @param config - Gateway configuration
|
|
129
|
-
* @param serviceFactory - Factory function to create the internal service
|
|
130
213
|
* @returns Gateway instance
|
|
131
214
|
*
|
|
132
215
|
* @example
|
|
133
216
|
* ```typescript
|
|
134
217
|
* import { createGateway } from '@qwickapps/server';
|
|
135
218
|
*
|
|
136
|
-
* const gateway = createGateway(
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
219
|
+
* const gateway = createGateway({
|
|
220
|
+
* productName: 'My Product',
|
|
221
|
+
* port: 3000,
|
|
222
|
+
* controlPanel: {
|
|
223
|
+
* path: '/cpanel',
|
|
224
|
+
* port: 3001,
|
|
225
|
+
* plugins: [...],
|
|
141
226
|
* },
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
* server,
|
|
148
|
-
* shutdown: async () => { server.close(); },
|
|
149
|
-
* };
|
|
150
|
-
* }
|
|
151
|
-
* );
|
|
227
|
+
* apps: [
|
|
228
|
+
* { path: '/api', source: { type: 'proxy', target: 'http://localhost:3002' } },
|
|
229
|
+
* { path: '/docs', source: { type: 'static', directory: './docs' } },
|
|
230
|
+
* ],
|
|
231
|
+
* });
|
|
152
232
|
*
|
|
153
233
|
* await gateway.start();
|
|
154
234
|
* ```
|
|
155
235
|
*/
|
|
156
|
-
export declare function createGateway(config: GatewayConfig
|
|
236
|
+
export declare function createGateway(config: GatewayConfig): GatewayInstance;
|
|
157
237
|
//# sourceMappingURL=gateway.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gateway.d.ts","sourceRoot":"","sources":["../../src/core/gateway.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"gateway.d.ts","sourceRoot":"","sources":["../../src/core/gateway.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,KAAK,EAAmC,MAAM,EAAE,MAAM,MAAM,CAAC;AAGpE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM,YAAY,CA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