@superdangerous/app-framework 4.9.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.
Files changed (239) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +652 -0
  3. package/dist/api/logsRouter.d.ts +20 -0
  4. package/dist/api/logsRouter.d.ts.map +1 -0
  5. package/dist/api/logsRouter.js +515 -0
  6. package/dist/api/logsRouter.js.map +1 -0
  7. package/dist/cli/dev-server.d.ts +7 -0
  8. package/dist/cli/dev-server.d.ts.map +1 -0
  9. package/dist/cli/dev-server.js +640 -0
  10. package/dist/cli/dev-server.js.map +1 -0
  11. package/dist/cli/index.d.ts +7 -0
  12. package/dist/cli/index.d.ts.map +1 -0
  13. package/dist/cli/index.js +26 -0
  14. package/dist/cli/index.js.map +1 -0
  15. package/dist/core/StandardServer.d.ts +129 -0
  16. package/dist/core/StandardServer.d.ts.map +1 -0
  17. package/dist/core/StandardServer.js +453 -0
  18. package/dist/core/StandardServer.js.map +1 -0
  19. package/dist/core/apiResponse.d.ts +69 -0
  20. package/dist/core/apiResponse.d.ts.map +1 -0
  21. package/dist/core/apiResponse.js +127 -0
  22. package/dist/core/apiResponse.js.map +1 -0
  23. package/dist/core/healthCheck.d.ts +160 -0
  24. package/dist/core/healthCheck.d.ts.map +1 -0
  25. package/dist/core/healthCheck.js +398 -0
  26. package/dist/core/healthCheck.js.map +1 -0
  27. package/dist/core/index.d.ts +40 -0
  28. package/dist/core/index.d.ts.map +1 -0
  29. package/dist/core/index.js +40 -0
  30. package/dist/core/index.js.map +1 -0
  31. package/dist/core/logger.d.ts +117 -0
  32. package/dist/core/logger.d.ts.map +1 -0
  33. package/dist/core/logger.js +826 -0
  34. package/dist/core/logger.js.map +1 -0
  35. package/dist/core/portUtils.d.ts +71 -0
  36. package/dist/core/portUtils.d.ts.map +1 -0
  37. package/dist/core/portUtils.js +240 -0
  38. package/dist/core/portUtils.js.map +1 -0
  39. package/dist/core/storageService.d.ts +119 -0
  40. package/dist/core/storageService.d.ts.map +1 -0
  41. package/dist/core/storageService.js +405 -0
  42. package/dist/core/storageService.js.map +1 -0
  43. package/dist/desktop/bundler.d.ts +40 -0
  44. package/dist/desktop/bundler.d.ts.map +1 -0
  45. package/dist/desktop/bundler.js +176 -0
  46. package/dist/desktop/bundler.js.map +1 -0
  47. package/dist/desktop/index.d.ts +25 -0
  48. package/dist/desktop/index.d.ts.map +1 -0
  49. package/dist/desktop/index.js +15 -0
  50. package/dist/desktop/index.js.map +1 -0
  51. package/dist/desktop/native-modules.d.ts +66 -0
  52. package/dist/desktop/native-modules.d.ts.map +1 -0
  53. package/dist/desktop/native-modules.js +200 -0
  54. package/dist/desktop/native-modules.js.map +1 -0
  55. package/dist/index.d.ts +29 -0
  56. package/dist/index.d.ts.map +1 -0
  57. package/dist/index.js +39 -0
  58. package/dist/index.js.map +1 -0
  59. package/dist/logging/LogCategories.d.ts +87 -0
  60. package/dist/logging/LogCategories.d.ts.map +1 -0
  61. package/dist/logging/LogCategories.js +205 -0
  62. package/dist/logging/LogCategories.js.map +1 -0
  63. package/dist/middleware/aiErrorHandler.d.ts +31 -0
  64. package/dist/middleware/aiErrorHandler.d.ts.map +1 -0
  65. package/dist/middleware/aiErrorHandler.js +181 -0
  66. package/dist/middleware/aiErrorHandler.js.map +1 -0
  67. package/dist/middleware/auth.d.ts +101 -0
  68. package/dist/middleware/auth.d.ts.map +1 -0
  69. package/dist/middleware/auth.js +230 -0
  70. package/dist/middleware/auth.js.map +1 -0
  71. package/dist/middleware/cors.d.ts +56 -0
  72. package/dist/middleware/cors.d.ts.map +1 -0
  73. package/dist/middleware/cors.js +123 -0
  74. package/dist/middleware/cors.js.map +1 -0
  75. package/dist/middleware/errorHandler.d.ts +13 -0
  76. package/dist/middleware/errorHandler.d.ts.map +1 -0
  77. package/dist/middleware/errorHandler.js +85 -0
  78. package/dist/middleware/errorHandler.js.map +1 -0
  79. package/dist/middleware/fileUpload.d.ts +62 -0
  80. package/dist/middleware/fileUpload.d.ts.map +1 -0
  81. package/dist/middleware/fileUpload.js +175 -0
  82. package/dist/middleware/fileUpload.js.map +1 -0
  83. package/dist/middleware/health.d.ts +48 -0
  84. package/dist/middleware/health.d.ts.map +1 -0
  85. package/dist/middleware/health.js +143 -0
  86. package/dist/middleware/health.js.map +1 -0
  87. package/dist/middleware/index.d.ts +20 -0
  88. package/dist/middleware/index.d.ts.map +1 -0
  89. package/dist/middleware/index.js +18 -0
  90. package/dist/middleware/index.js.map +1 -0
  91. package/dist/middleware/openapi.d.ts +64 -0
  92. package/dist/middleware/openapi.d.ts.map +1 -0
  93. package/dist/middleware/openapi.js +258 -0
  94. package/dist/middleware/openapi.js.map +1 -0
  95. package/dist/middleware/requestLogging.d.ts +22 -0
  96. package/dist/middleware/requestLogging.d.ts.map +1 -0
  97. package/dist/middleware/requestLogging.js +61 -0
  98. package/dist/middleware/requestLogging.js.map +1 -0
  99. package/dist/middleware/session.d.ts +84 -0
  100. package/dist/middleware/session.d.ts.map +1 -0
  101. package/dist/middleware/session.js +189 -0
  102. package/dist/middleware/session.js.map +1 -0
  103. package/dist/middleware/validation.d.ts +1337 -0
  104. package/dist/middleware/validation.d.ts.map +1 -0
  105. package/dist/middleware/validation.js +483 -0
  106. package/dist/middleware/validation.js.map +1 -0
  107. package/dist/services/aiService.d.ts +180 -0
  108. package/dist/services/aiService.d.ts.map +1 -0
  109. package/dist/services/aiService.js +547 -0
  110. package/dist/services/aiService.js.map +1 -0
  111. package/dist/services/conversationStorage.d.ts +38 -0
  112. package/dist/services/conversationStorage.d.ts.map +1 -0
  113. package/dist/services/conversationStorage.js +158 -0
  114. package/dist/services/conversationStorage.js.map +1 -0
  115. package/dist/services/crossPlatformBuffer.d.ts +84 -0
  116. package/dist/services/crossPlatformBuffer.d.ts.map +1 -0
  117. package/dist/services/crossPlatformBuffer.js +246 -0
  118. package/dist/services/crossPlatformBuffer.js.map +1 -0
  119. package/dist/services/index.d.ts +17 -0
  120. package/dist/services/index.d.ts.map +1 -0
  121. package/dist/services/index.js +18 -0
  122. package/dist/services/index.js.map +1 -0
  123. package/dist/services/networkService.d.ts +81 -0
  124. package/dist/services/networkService.d.ts.map +1 -0
  125. package/dist/services/networkService.js +268 -0
  126. package/dist/services/networkService.js.map +1 -0
  127. package/dist/services/queueService.d.ts +112 -0
  128. package/dist/services/queueService.d.ts.map +1 -0
  129. package/dist/services/queueService.js +338 -0
  130. package/dist/services/queueService.js.map +1 -0
  131. package/dist/services/settingsService.d.ts +135 -0
  132. package/dist/services/settingsService.d.ts.map +1 -0
  133. package/dist/services/settingsService.js +425 -0
  134. package/dist/services/settingsService.js.map +1 -0
  135. package/dist/services/systemMonitor.d.ts +208 -0
  136. package/dist/services/systemMonitor.d.ts.map +1 -0
  137. package/dist/services/systemMonitor.js +693 -0
  138. package/dist/services/systemMonitor.js.map +1 -0
  139. package/dist/services/updateService.d.ts +78 -0
  140. package/dist/services/updateService.d.ts.map +1 -0
  141. package/dist/services/updateService.js +252 -0
  142. package/dist/services/updateService.js.map +1 -0
  143. package/dist/services/websocketEvents.d.ts +372 -0
  144. package/dist/services/websocketEvents.d.ts.map +1 -0
  145. package/dist/services/websocketEvents.js +338 -0
  146. package/dist/services/websocketEvents.js.map +1 -0
  147. package/dist/services/websocketServer.d.ts +80 -0
  148. package/dist/services/websocketServer.d.ts.map +1 -0
  149. package/dist/services/websocketServer.js +299 -0
  150. package/dist/services/websocketServer.js.map +1 -0
  151. package/dist/settings/SettingsSchema.d.ts +151 -0
  152. package/dist/settings/SettingsSchema.d.ts.map +1 -0
  153. package/dist/settings/SettingsSchema.js +424 -0
  154. package/dist/settings/SettingsSchema.js.map +1 -0
  155. package/dist/testing/TestServer.d.ts +69 -0
  156. package/dist/testing/TestServer.d.ts.map +1 -0
  157. package/dist/testing/TestServer.js +250 -0
  158. package/dist/testing/TestServer.js.map +1 -0
  159. package/dist/types/index.d.ts +137 -0
  160. package/dist/types/index.d.ts.map +1 -0
  161. package/dist/types/index.js +5 -0
  162. package/dist/types/index.js.map +1 -0
  163. package/dist/utils/appPaths.d.ts +74 -0
  164. package/dist/utils/appPaths.d.ts.map +1 -0
  165. package/dist/utils/appPaths.js +162 -0
  166. package/dist/utils/appPaths.js.map +1 -0
  167. package/dist/utils/fs-utils.d.ts +50 -0
  168. package/dist/utils/fs-utils.d.ts.map +1 -0
  169. package/dist/utils/fs-utils.js +114 -0
  170. package/dist/utils/fs-utils.js.map +1 -0
  171. package/dist/utils/index.d.ts +12 -0
  172. package/dist/utils/index.d.ts.map +1 -0
  173. package/dist/utils/index.js +10 -0
  174. package/dist/utils/index.js.map +1 -0
  175. package/dist/utils/standardConfig.d.ts +61 -0
  176. package/dist/utils/standardConfig.d.ts.map +1 -0
  177. package/dist/utils/standardConfig.js +109 -0
  178. package/dist/utils/standardConfig.js.map +1 -0
  179. package/dist/utils/startupBanner.d.ts +34 -0
  180. package/dist/utils/startupBanner.d.ts.map +1 -0
  181. package/dist/utils/startupBanner.js +169 -0
  182. package/dist/utils/startupBanner.js.map +1 -0
  183. package/dist/utils/startupLogger.d.ts +45 -0
  184. package/dist/utils/startupLogger.d.ts.map +1 -0
  185. package/dist/utils/startupLogger.js +200 -0
  186. package/dist/utils/startupLogger.js.map +1 -0
  187. package/package.json +151 -0
  188. package/src/api/logsRouter.ts +600 -0
  189. package/src/cli/dev-server.ts +803 -0
  190. package/src/cli/index.ts +31 -0
  191. package/src/core/StandardServer.ts +587 -0
  192. package/src/core/apiResponse.ts +202 -0
  193. package/src/core/healthCheck.ts +565 -0
  194. package/src/core/index.ts +80 -0
  195. package/src/core/logger.ts +1092 -0
  196. package/src/core/portUtils.ts +319 -0
  197. package/src/core/storageService.ts +595 -0
  198. package/src/desktop/bundler.ts +271 -0
  199. package/src/desktop/index.ts +18 -0
  200. package/src/desktop/native-modules.ts +289 -0
  201. package/src/index.ts +142 -0
  202. package/src/logging/LogCategories.ts +302 -0
  203. package/src/middleware/aiErrorHandler.ts +278 -0
  204. package/src/middleware/auth.ts +329 -0
  205. package/src/middleware/cors.ts +187 -0
  206. package/src/middleware/errorHandler.ts +103 -0
  207. package/src/middleware/fileUpload.ts +252 -0
  208. package/src/middleware/health.ts +206 -0
  209. package/src/middleware/index.ts +71 -0
  210. package/src/middleware/openapi.ts +305 -0
  211. package/src/middleware/requestLogging.ts +92 -0
  212. package/src/middleware/session.ts +238 -0
  213. package/src/middleware/validation.ts +603 -0
  214. package/src/services/aiService.ts +789 -0
  215. package/src/services/conversationStorage.ts +232 -0
  216. package/src/services/crossPlatformBuffer.ts +341 -0
  217. package/src/services/index.ts +47 -0
  218. package/src/services/networkService.ts +351 -0
  219. package/src/services/queueService.ts +446 -0
  220. package/src/services/settingsService.ts +549 -0
  221. package/src/services/systemMonitor.ts +936 -0
  222. package/src/services/updateService.ts +334 -0
  223. package/src/services/websocketEvents.ts +409 -0
  224. package/src/services/websocketServer.ts +394 -0
  225. package/src/settings/SettingsSchema.ts +664 -0
  226. package/src/testing/TestServer.ts +312 -0
  227. package/src/types/index.ts +154 -0
  228. package/src/utils/appPaths.ts +196 -0
  229. package/src/utils/fs-utils.ts +130 -0
  230. package/src/utils/index.ts +15 -0
  231. package/src/utils/standardConfig.ts +178 -0
  232. package/src/utils/startupBanner.ts +287 -0
  233. package/src/utils/startupLogger.ts +268 -0
  234. package/ui/dist/index.d.mts +1221 -0
  235. package/ui/dist/index.d.ts +1221 -0
  236. package/ui/dist/index.js +73 -0
  237. package/ui/dist/index.js.map +1 -0
  238. package/ui/dist/index.mjs +73 -0
  239. package/ui/dist/index.mjs.map +1 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 SuperDangerous
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,652 @@
1
+ # SuperDangerous App Framework
2
+
3
+ A comprehensive, production-ready framework for building enterprise internal tools and applications with TypeScript, React, and real-time capabilities.
4
+
5
+ ## ๐Ÿ“‹ Documentation
6
+
7
+ ### Core Guides
8
+
9
+ - **[API](./docs/API.md)** - Complete API documentation with best practices
10
+ - **[Development](./docs/DEVELOPMENT.md)** - How to build applications with the framework
11
+ - **[Architecture](./docs/ARCHITECTURE.md)** - System design and structure
12
+
13
+ ### Features
14
+
15
+ - **[WebSocket](./docs/WEBSOCKET.md)** - Real-time communication implementation
16
+ - **[Desktop](./docs/DESKTOP.md)** - Desktop application support with Tauri
17
+ - **[Bundling](./docs/BUNDLING.md)** - Desktop bundling guide
18
+ - **[AI](./docs/AI.md)** - AI service integration
19
+ - **[Patterns](./docs/PATTERNS.md)** - Proven architectural patterns
20
+
21
+ ### Configuration & Testing
22
+
23
+ - **[Testing](./docs/TESTING.md)** - Testing guidelines and patterns
24
+ - **[Logging](./docs/LOGGING.md)** - Logging system documentation
25
+ - **[Theme](./docs/THEME.md)** - Theme system and customization
26
+ - **[Ports](./docs/PORTS.md)** - Port configuration standards
27
+ - **[CORS](./docs/CORS.md)** - Dynamic CORS middleware
28
+
29
+ #### Test Suite Overview
30
+
31
+ The framework includes extensive test coverage:
32
+
33
+ - **Unit Tests**: 362+ tests covering all core modules
34
+ - **Integration Tests**: API and service integration testing
35
+ - **TestServer**: Built-in test server for application testing
36
+ - **Mock Services**: Comprehensive mocking utilities
37
+
38
+ #### Running Tests
39
+
40
+ ```bash
41
+ # Run all tests
42
+ npm test
43
+
44
+ # Run with coverage
45
+ npm run test:coverage
46
+
47
+ # Run specific suites
48
+ npm run test:unit
49
+ npm run test:integration
50
+
51
+ # Type checking
52
+ npm run typecheck
53
+ ```
54
+
55
+ #### Test Infrastructure
56
+
57
+ - Jest with TypeScript support
58
+ - Built-in TestServer class for app testing
59
+ - Mock implementations for all services
60
+ - Async operation handling
61
+ - Port management utilities
62
+
63
+ ## ๐Ÿš€ Quick Start
64
+
65
+ ```bash
66
+ # Install framework
67
+ npm install @superdangerous/app-framework
68
+
69
+ # Create your app
70
+ mkdir my-app && cd my-app
71
+ npm init -y
72
+ npm install @superdangerous/app-framework
73
+ ```
74
+
75
+ ### Minimal Application
76
+
77
+ ```typescript
78
+ import { StandardServer } from "@superdangerous/app-framework";
79
+
80
+ const server = new StandardServer({
81
+ appName: "My App",
82
+ appVersion: "1.0.0",
83
+ port: 8080,
84
+ enableWebSocket: true,
85
+ onInitialize: async (app) => {
86
+ app.get("/health", (req, res) => res.json({ status: "ok" }));
87
+ },
88
+ });
89
+
90
+ await server.initialize();
91
+ await server.start();
92
+ ```
93
+
94
+ ## โœจ Core Features
95
+
96
+ ### ๐Ÿ–ฅ๏ธ Server Management
97
+
98
+ - **StandardServer** - Simplified server setup with Express
99
+ - **Request Correlation** - Automatic request IDs with structured request logging
100
+ - **Safer Defaults** - Request body limits, trust proxy, and sane HTTP timeouts
101
+ - **Port Management** - Automatic port conflict resolution
102
+ - **Graceful Shutdown** - Clean resource cleanup
103
+ - **Health Checks** - Real system metrics (CPU, memory, disk) - informational only
104
+ - **Startup Banner** - Professional application startup display
105
+
106
+ ### ๐Ÿ“ Logging System
107
+
108
+ - **Dual Logger System** - Simple console + production file logging
109
+ - **Enhanced Logger** - File rotation, compression, archiving
110
+ - **Category-based Logging** - Organize logs by service/module
111
+ - **Log Management** - Statistics, cleanup, migration utilities
112
+ - **Flat Structure** - All logs in `/data/logs` for easy backup/restore
113
+
114
+ ### ๐Ÿ”Œ Real-Time Communication
115
+
116
+ - **WebSocketManager** - Unified Socket.IO management with namespace support
117
+ - **Redis Adapter** - Optional Redis adapter for scaling
118
+ - **Room Management** - Built-in room join/leave handlers
119
+ - **Client Tracking** - Track connected clients across namespaces
120
+ - **Broadcast Options** - Selective broadcasting with compression/volatile options
121
+ - **React Hooks** - `useSocketIO`, `useConnectionStatus`
122
+ - **Connection Status** - Monitor connection health
123
+
124
+ ### ๐Ÿ”’ Security & Authentication
125
+
126
+ - **Session Management** - Express sessions with Redis support
127
+ - **Authentication Middleware** - Role-based access control
128
+ - **Input Validation** - Zod/Joi schema validation
129
+ - **File Security** - Safe file operations with validation
130
+ - **CORS Configuration** - Cross-origin resource sharing
131
+
132
+ ### โš™๏ธ Configuration & Settings
133
+
134
+ - **Settings Service** - Dynamic settings with UI generation
135
+ - **Environment Merging** Automatic env variable merging
136
+ - **File Watching** Auto-reload on config file changes
137
+ - **Change Events** EventEmitter for config change tracking
138
+ - **Common Schemas** Pre-built Zod schemas for common configs
139
+
140
+ ### ๐Ÿ“Š Health Monitoring
141
+
142
+ - **HealthCheckService** Real system metrics collection
143
+ - **CPU Metrics** Real CPU usage with history tracking
144
+ - **Memory Metrics** Memory usage percentage and details
145
+ - **Disk Metrics** Disk space monitoring (platform-aware)
146
+ - **Process Metrics** Node.js process statistics
147
+ - **Custom Health Checks** Extensible health check framework
148
+ - **Dependency Checks** Monitor external service health
149
+ - **Informational Only** Never interrupts service operation
150
+
151
+ ### ๐Ÿ”ง Services & Utilities
152
+
153
+ - **Queue Service** - Background job processing with persistence
154
+ - **AI Service** - Multi-provider AI integration (OpenAI, Claude)
155
+ - **Port Utilities** - Port availability checking and management
156
+ - **File Handler** - Secure file operations with MIME validation
157
+ - **Network Service** - Network interface discovery
158
+ - **System Monitor** - System resource monitoring
159
+
160
+ ### ๐ŸŽจ UI Components Library
161
+
162
+ #### Base Components (20+)
163
+
164
+ - **Forms** - Input, Select, Checkbox, Radio, Switch, Textarea
165
+ - **Layout** - Card, Dialog, Tabs, Accordion, Separator
166
+ - **Data Display** - Table, Badge, Alert, Progress, Avatar
167
+ - **Navigation** - Button, Dropdown, Context Menu, Navigation Menu
168
+ - **Feedback** - Toast, Tooltip, Popover, Alert Dialog
169
+
170
+ #### Advanced Components
171
+
172
+ - **SettingsFramework** - Complete settings UI with validation
173
+ - **LogViewer** - Real-time log display with filtering, stack coalescing, ANSI stripping, auto-refresh, archives, and per-level badges
174
+ - **ConnectionStatus** - WebSocket connection monitoring
175
+ - **AppLayout** - Standard application layout with navigation
176
+ - **RealtimeDataTable** - Live updating data tables
177
+ - **DashboardStats** - Metric display cards
178
+ - **UpdateNotification** - Application update notifications
179
+
180
+ > UI bundle note: the UI package bundles ESM-heavy dependencies (`react-markdown`, `remark-gfm`, `react-syntax-highlighter`) for better Jest/Node compatibility. The LogViewer is now single-source and virtualized; legacy variants have been removed.
181
+
182
+ ### ๐Ÿงช Testing Utilities
183
+
184
+ - **TestServer** - Standardized test server for integration tests
185
+ - **Test Utilities** - Request helpers, WebSocket testing
186
+ - **Mock Services** - Pre-configured mocks for services
187
+
188
+ ### ๐Ÿ“Š Middleware
189
+
190
+ - **Validation** - Request/response validation
191
+ - **Error Handling** - Centralized error management
192
+ - **File Upload** - Secure file upload handling
193
+ - **OpenAPI** - Automatic API documentation
194
+ - **Health Checks** - Liveness/readiness probes
195
+ - **Rate Limiting** - API rate limiting
196
+
197
+ ## ๐Ÿ“ฆ Installation
198
+
199
+ ### Full Framework (Backend + Frontend)
200
+
201
+ ```bash
202
+ npm install @superdangerous/app-framework
203
+ ```
204
+
205
+ ### Import Examples
206
+
207
+ ```javascript
208
+ // Backend
209
+ import { StandardServer, createLogger } from "@superdangerous/app-framework";
210
+
211
+ // Frontend UI components
212
+ import {
213
+ Button,
214
+ Card,
215
+ useSocketIO,
216
+ useConnectionStatus,
217
+ } from "@superdangerous/app-framework/ui";
218
+ ```
219
+
220
+ ````
221
+
222
+ ## ๐Ÿ’ก Usage Examples
223
+
224
+ ### REST API with Database
225
+
226
+ ```typescript
227
+ import { StandardServer, validate, createLogger } from '@superdangerous/app-framework';
228
+ import { z } from 'zod';
229
+
230
+ const logger = createLogger('API');
231
+
232
+ const server = new StandardServer({
233
+ appName: 'REST API',
234
+ appVersion: '1.0.0',
235
+ onInitialize: async (app) => {
236
+ // Validation middleware
237
+ const userSchema = z.object({
238
+ name: z.string(),
239
+ email: z.string().email()
240
+ });
241
+
242
+ app.post('/api/users', validate(userSchema), async (req, res) => {
243
+ // Validated request body
244
+ const user = await createUser(req.body);
245
+ res.json({ success: true, data: user });
246
+ });
247
+ }
248
+ });
249
+ ````
250
+
251
+ ### Real-Time Dashboard
252
+
253
+ ```typescript
254
+ import { StandardServer, getWebSocketServer } from "@superdangerous/app-framework";
255
+
256
+ const server = new StandardServer({
257
+ appName: "Dashboard",
258
+ appVersion: "1.0.0",
259
+ enableWebSocket: true,
260
+ onStart: async () => {
261
+ const ws = getWebSocketServer();
262
+
263
+ // Stream metrics every second
264
+ setInterval(() => {
265
+ const metrics = collectMetrics();
266
+ ws.broadcast("metrics:update", metrics);
267
+ }, 1000);
268
+ },
269
+ });
270
+ ```
271
+
272
+ ### React WebSocket Integration
273
+
274
+ ```tsx
275
+ import { useSocketIO, useConnectionStatus } from "@superdangerous/app-framework/ui";
276
+
277
+ function Dashboard() {
278
+ const [state, actions] = useSocketIO();
279
+ const { connected } = useConnectionStatus();
280
+ const [metrics, setMetrics] = useState([]);
281
+
282
+ useEffect(() => {
283
+ if (!connected) return;
284
+ const handler = (data) => setMetrics(data);
285
+ actions.on("metrics:update", handler);
286
+ return () => actions.off("metrics:update", handler);
287
+ }, [connected, actions]);
288
+
289
+ return <MetricsDisplay data={metrics} />;
290
+ }
291
+ ```
292
+
293
+ ### Background Job Processing
294
+
295
+ ```typescript
296
+ import { QueueService } from "@superdangerous/app-framework";
297
+
298
+ const queue = new QueueService({
299
+ concurrent: 5,
300
+ persistent: true,
301
+ });
302
+
303
+ queue.registerHandler("send-email", async (job) => {
304
+ await sendEmail(job.data);
305
+ });
306
+
307
+ await queue.addJob("send-email", {
308
+ to: "user@example.com",
309
+ subject: "Welcome!",
310
+ });
311
+ ```
312
+
313
+ ### Settings Management
314
+
315
+ ```typescript
316
+ import { SettingsService } from '@superdangerous/app-framework';
317
+
318
+ const settings = new SettingsService();
319
+
320
+ settings.registerCategory({
321
+ id: 'general',
322
+ label: 'General Settings',
323
+ settings: [{
324
+ key: 'app.theme',
325
+ label: 'Theme',
326
+ type: 'select',
327
+ options: ['light', 'dark', 'auto'],
328
+ defaultValue: 'auto'
329
+ }]
330
+ });
331
+
332
+ // React component
333
+ <SettingsFramework
334
+ categories={settings.getUISchema()}
335
+ onSave={async (values) => settings.update(values)}
336
+ />
337
+ ```
338
+
339
+ ### Health Monitoring
340
+
341
+ ```typescript
342
+ import {
343
+ createHealthCheckRouter,
344
+ getHealthCheckService,
345
+ } from "@superdangerous/app-framework";
346
+
347
+ // Add health check endpoints
348
+ const healthRouter = createHealthCheckRouter({
349
+ version: "1.0.0",
350
+ customChecks: [
351
+ {
352
+ name: "database",
353
+ check: async () => ({
354
+ name: "database",
355
+ status: (await db.ping()) ? "healthy" : "unhealthy",
356
+ }),
357
+ },
358
+ ],
359
+ });
360
+
361
+ app.use("/api", healthRouter);
362
+
363
+ // Get real-time metrics
364
+ const healthService = getHealthCheckService();
365
+ const metrics = await healthService.getMetrics();
366
+ console.log(
367
+ `CPU: ${metrics.cpu.usage}%, Memory: ${metrics.memory.percentage}%`,
368
+ );
369
+ ```
370
+
371
+ ### Settings Management
372
+
373
+ ```typescript
374
+ import {
375
+ SettingsService,
376
+ CommonSettingsCategories,
377
+ } from "@superdangerous/app-framework";
378
+
379
+ // Initialize settings service
380
+ const settings = new SettingsService({
381
+ filePath: "./settings.json",
382
+ categories: CommonSettingsCategories,
383
+ onSettingChange: async (key, value) => {
384
+ console.log(`Setting ${key} changed to ${value}`);
385
+ },
386
+ });
387
+
388
+ await settings.initialize();
389
+
390
+ // Get setting value
391
+ const port = await settings.get("server.port");
392
+
393
+ // Update setting
394
+ await settings.set("server.port", 8080);
395
+ ```
396
+
397
+ ### WebSocket Manager
398
+
399
+ ```typescript
400
+ import { getWebSocketManager } from "@superdangerous/app-framework";
401
+
402
+ // Initialize WebSocket manager
403
+ const wsManager = getWebSocketManager({
404
+ cors: { origin: "http://localhost:3000" },
405
+ adapter: "redis", // Optional Redis scaling
406
+ redisUrl: process.env.REDIS_URL,
407
+ });
408
+
409
+ await wsManager.initialize(httpServer);
410
+
411
+ // Register namespace with handlers
412
+ wsManager.registerNamespace("/dashboard", {
413
+ subscribe: (socket, topic) => {
414
+ socket.join(`topic:${topic}`);
415
+ socket.emit("subscribed", { topic });
416
+ },
417
+ unsubscribe: (socket, topic) => {
418
+ socket.leave(`topic:${topic}`);
419
+ },
420
+ });
421
+
422
+ // Broadcast to specific rooms
423
+ wsManager.broadcast("update", data, {
424
+ namespace: "/dashboard",
425
+ room: "topic:metrics",
426
+ compress: true,
427
+ });
428
+
429
+ // Get connection stats
430
+ const stats = wsManager.getStats();
431
+ console.log(`Connected clients: ${stats.totalClients}`);
432
+ ```
433
+
434
+ ## ๐Ÿ—๏ธ Architecture
435
+
436
+ ```
437
+ Framework Structure:
438
+ โ”œโ”€โ”€ Core Layer
439
+ โ”‚ โ”œโ”€โ”€ StandardServer # Server management
440
+ โ”‚ โ”œโ”€โ”€ Logger System # Logging infrastructure
441
+ โ”‚ โ”œโ”€โ”€ Port Utilities # Port management
442
+ โ”‚ โ””โ”€โ”€ File Handler # Secure file operations
443
+ โ”œโ”€โ”€ Service Layer
444
+ โ”‚ โ”œโ”€โ”€ WebSocket Server # Real-time communication
445
+ โ”‚ โ”œโ”€โ”€ Configuration # Config management
446
+ โ”‚ โ”œโ”€โ”€ Queue Service # Job processing
447
+ โ”‚ โ”œโ”€โ”€ AI Service # AI integration
448
+ โ”‚ โ””โ”€โ”€ Settings Service # Settings management
449
+ โ”œโ”€โ”€ Middleware Layer
450
+ โ”‚ โ”œโ”€โ”€ Authentication # Auth & sessions
451
+ โ”‚ โ”œโ”€โ”€ Validation # Input validation
452
+ โ”‚ โ”œโ”€โ”€ Error Handling # Error management
453
+ โ”‚ โ””โ”€โ”€ Health Checks # Health monitoring
454
+ โ””โ”€โ”€ UI Layer
455
+ โ”œโ”€โ”€ Base Components # Core UI elements
456
+ โ”œโ”€โ”€ Advanced Components # Complex UI patterns
457
+ โ”œโ”€โ”€ Hooks # React hooks
458
+ โ””โ”€โ”€ Utilities # UI helpers
459
+ ```
460
+
461
+ ## ๐Ÿ”ง Configuration
462
+
463
+ ### Environment Variables
464
+
465
+ ```bash
466
+ # Server
467
+ NODE_ENV=production
468
+ PORT=8080
469
+ HOST=0.0.0.0
470
+
471
+ # Logging
472
+ LOG_LEVEL=info
473
+ LOG_DIR=./logs
474
+
475
+ # Session
476
+ SESSION_SECRET=your-secret-key
477
+
478
+ # Database
479
+ DATABASE_URL=postgresql://...
480
+
481
+ # Redis
482
+ REDIS_HOST=localhost
483
+ REDIS_PORT=6379
484
+
485
+ # AI Services (optional)
486
+ OPENAI_API_KEY=sk-...
487
+ CLAUDE_API_KEY=sk-ant-...
488
+
489
+ # WebSocket
490
+ WS_PING_INTERVAL=25000
491
+ WS_PING_TIMEOUT=60000
492
+ ```
493
+
494
+ ### Configuration Files
495
+
496
+ ```json
497
+ // data/config/app.json
498
+ {
499
+ "server": {
500
+ "port": 8080,
501
+ "cors": {
502
+ "origins": ["http://localhost:3000"]
503
+ }
504
+ },
505
+ "features": {
506
+ "enableWebSocket": true,
507
+ "enableMetrics": true
508
+ }
509
+ }
510
+ ```
511
+
512
+ ## ๐Ÿ“š TypeScript Support
513
+
514
+ Full TypeScript support with comprehensive type definitions:
515
+
516
+ ```typescript
517
+ import type {
518
+ StandardServerConfig,
519
+ Logger,
520
+ WebSocketClient,
521
+ JobStatus,
522
+ SettingType,
523
+ ApiResponse,
524
+ ValidationSchema,
525
+ } from "@superdangerous/app-framework";
526
+
527
+ import type {
528
+ ButtonProps,
529
+ TableColumn,
530
+ SettingCategory,
531
+ WebSocketHook,
532
+ } from "@superdangerous/app-framework/ui";
533
+ ```
534
+
535
+ ## ๐Ÿงช Testing
536
+
537
+ ```typescript
538
+ import { TestServer, setupTestServer } from "@superdangerous/app-framework";
539
+
540
+ describe("API Tests", () => {
541
+ let server: TestServer;
542
+
543
+ beforeAll(async () => {
544
+ server = await setupTestServer({
545
+ setupApp: (app) => {
546
+ app.get("/test", (req, res) => res.json({ ok: true }));
547
+ },
548
+ });
549
+ });
550
+
551
+ test("endpoint works", async () => {
552
+ const res = await server.request("/test");
553
+ expect(res.body.ok).toBe(true);
554
+ });
555
+ });
556
+ ```
557
+
558
+ ## ๐Ÿš€ Production Deployment
559
+
560
+ ### Docker
561
+
562
+ ```dockerfile
563
+ FROM node:18-alpine
564
+ WORKDIR /app
565
+ COPY package*.json ./
566
+ RUN npm ci --only=production
567
+ COPY dist/ ./dist/
568
+ ENV NODE_ENV=production
569
+ HEALTHCHECK CMD curl -f http://localhost:8080/health || exit 1
570
+ CMD ["node", "dist/index.js"]
571
+ ```
572
+
573
+ ### PM2
574
+
575
+ ```javascript
576
+ module.exports = {
577
+ apps: [
578
+ {
579
+ name: "my-app",
580
+ script: "./dist/index.js",
581
+ instances: "max",
582
+ exec_mode: "cluster",
583
+ env: {
584
+ NODE_ENV: "production",
585
+ },
586
+ },
587
+ ],
588
+ };
589
+ ```
590
+
591
+ ## ๐Ÿ› ๏ธ Development Tools
592
+
593
+ - **Hot Reload** - Automatic restart on changes
594
+ - **TypeScript** - Full type safety
595
+ - **ESLint** - Code quality enforcement
596
+ - **Prettier** - Code formatting
597
+ - **Jest** - Testing framework
598
+ - **Nodemon** - Development server
599
+
600
+ ## ๐Ÿ“– For AI Assistants
601
+
602
+ This framework is designed to be AI-friendly. When building applications:
603
+
604
+ 1. **Always use StandardServer** - Never use deprecated StartupOrchestrator
605
+ 2. **Validate all inputs** - Use zod schemas for validation
606
+ 3. **Handle errors properly** - Use try-catch and error middleware
607
+ 4. **Use TypeScript** - Define interfaces for all data structures
608
+ 5. **Follow the patterns** - See [Development Guide](./docs/DEVELOPMENT.md)
609
+
610
+ ## ๐Ÿ”’ Security
611
+
612
+ - Input validation on all endpoints
613
+ - Secure session management
614
+ - File upload restrictions
615
+ - Rate limiting support
616
+ - CORS configuration
617
+ - Environment variable secrets
618
+
619
+ ## ๐Ÿ› ๏ธ Development Tools
620
+
621
+ ### Node Process Monitor
622
+
623
+ Monitor and manage all your running framework apps from the macOS menu bar.
624
+
625
+ - **Real-time monitoring** of all processes started with `dev-server`
626
+ - **Grouped by app** with hierarchical view of backend/frontend/websocket processes
627
+ - **Resource tracking** - CPU, memory, uptime for each process
628
+ - **Easy management** - Kill individual processes or entire apps
629
+ - **Lightweight** - Built in Rust for minimal overhead
630
+
631
+ #### Installation
632
+
633
+ ```bash
634
+ # Quick install (macOS)
635
+ curl -sSL https://raw.githubusercontent.com/EPISENSOR/epi-node-process-monitor/main/install.sh | bash
636
+ ```
637
+
638
+ Learn more: [github.com/SuperDangerous/epi-node-process-monitor](https://github.com/SuperDangerous/epi-node-process-monitor)
639
+
640
+ ## ๐Ÿ“„ License
641
+
642
+ MIT License - see [LICENSE](./LICENSE) for details
643
+
644
+ ## ๐Ÿค Support
645
+
646
+ - **Documentation**: See `/docs` folder for all guides
647
+ - **Issues**: Internal issue tracker
648
+ - **Examples**: Check example applications using this framework
649
+
650
+ ---
651
+
652
+ Built with โค๏ธ by SuperDangerous
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Standardized Logging API Router
3
+ * Provides consistent logging endpoints for all SuperDangerous applications
4
+ */
5
+ declare const router: import("express-serve-static-core").Router;
6
+ export interface LogEntry {
7
+ timestamp: string;
8
+ level: string;
9
+ message: string;
10
+ source?: string;
11
+ metadata?: any;
12
+ }
13
+ export interface LogFile {
14
+ name: string;
15
+ size: number;
16
+ modified: string;
17
+ path?: string;
18
+ }
19
+ export default router;
20
+ //# sourceMappingURL=logsRouter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logsRouter.d.ts","sourceRoot":"","sources":["../../src/api/logsRouter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,QAAA,MAAM,MAAM,4CAAmB,CAAC;AAEhC,MAAM,WAAW,QAAQ;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,GAAG,CAAC;CAChB;AAED,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AA6jBD,eAAe,MAAM,CAAC"}