@cocreate/server 1.6.1 → 1.6.2

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 CHANGED
@@ -1,98 +1,478 @@
1
- # CoCreate-server
1
+ # CoCreate Server
2
2
 
3
- CoCreate-server is a dynamic SSL certificate manager that simplifies the process of managing and generating SSL certificates for your web applications. It supports both proxy servers like NGINX and Node.js SSL termination, making it a versatile tool for securing your connections.
3
+ A secure, stateless, clustered headless server built for high-performance multi-tenancy, real-time collaboration, dynamic process orchestration, and distributed mesh execution. This module serves as the primary orchestrator of the CoCreate ecosystem.
4
4
 
5
- ![minified](https://img.badgesize.io/https://cdn.cocreate.app/server/latest/CoCreate-server.min.js?style=flat-square&label=minified&color=orange)
6
- ![gzip](https://img.badgesize.io/https://cdn.cocreate.app/server/latest/CoCreate-server.min.js?compression=gzip&style=flat-square&label=gzip&color=yellow)
7
- ![brotli](https://img.badgesize.io/https://cdn.cocreate.app/server/latest/CoCreate-server.min.js?compression=brotli&style=flat-square&label=brotli)
8
- ![GitHub latest release](https://img.shields.io/github/v/release/CoCreate-app/CoCreate-server?style=flat-square)
9
- ![License](https://img.shields.io/github/license/CoCreate-app/CoCreate-server?style=flat-square)
10
- ![Hiring](https://img.shields.io/static/v1?style=flat-square&label=&message=Hiring&color=blueviolet)
5
+ ---
11
6
 
12
- ## Features
7
+ ## Documentation
13
8
 
14
- - **Dynamic SSL Management:** Automatically manages and renews SSL certificates.
15
- - **Proxy Support:** Designed to work with popular proxy servers like NGINX.
16
- - **Fallback to Node.js:** Can also terminate SSL directly in Node.js for environments without a proxy.
17
- - **ACME Protocol Integration:** Utilizes ACME to automate the certificate issuance process.
9
+ For a complete guide, deployment examples, and API reference, visit the **CoCreate Server Documentation**.
18
10
 
19
- ![CoCreate-server](https://cdn.cocreate.app/docs/CoCreate-server.gif)
11
+ ## Table of Contents
20
12
 
21
- ## [Docs & Demo](https://cocreate.app/docs/server)
13
+ - [Architectural Overview & Core Design](#architectural-overview--core-design)
14
+ - [Core Server Modules](#core-server-modules)
15
+ - [Component Mesh Architecture](#component-mesh-architecture)
16
+ - [Programmatic API Reference](#programmatic-api-reference)
17
+ - [Ingress & Connection Controls](#ingress--connection-controls)
18
+ - [Process & OS Lifecycle Management](#process--os-lifecycle-management)
19
+ - [IPC Transport Engine](#ipc-transport-engine)
20
+ - [Reactive Cluster Storage Manager](#reactive-cluster-storage-manager)
21
+ - [Distributed Cluster Orchestration](#distributed-cluster-orchestration)
22
+ - [Targeting Matrix & Routing Directives](#targeting-matrix--routing-directives)
23
+ - [Self-Healing & Jittered Reconnection Logic](#self-healing--jittered-reconnection-logic)
24
+ - [Dynamic Tenant Eviction & Cascading Teardown Sequence](#dynamic-tenant-eviction--cascading-teardown-sequence)
25
+ - [Security-Hardened Design](#security-hardened-design)
26
+ - [Installation](#installation)
27
+ - [Quick Start](#quick-start)
28
+ - [Announcements](#announcements)
29
+ - [Roadmap](#roadmap)
30
+ - [How to Contribute](#how-to-contribute)
31
+ - [About](#about)
32
+ - [License](#license)
22
33
 
23
- For a complete guide and working demo refer to the [doumentation](https://cocreate.app/docs/server)
34
+ ---
24
35
 
25
- ## CDN
36
+ ## Architectural Overview & Core Design
26
37
 
27
- ```html
28
- <script src="https://cdn.cocreate.app/server/latest/CoCreate-server.min.js"></script>
38
+ `@cocreate/server` is engineered to run stateless, highly available workloads across multi-core systems and distributed cloud infrastructure.
39
+
40
+ ### Clustered IPC Architecture
41
+
42
+ The server operates a single **Primary** process that forks and manages worker processes across CPU cores.
43
+
44
+ The Primary process is responsible for:
45
+
46
+ - Cluster orchestration
47
+ - Worker lifecycle management
48
+ - Fallback HTTP/HTTPS listeners
49
+ - Inter-process communication (IPC)
50
+
51
+ Each Worker runs an identical application stack handling:
52
+
53
+ - HTTP requests
54
+ - WebSocket connections
55
+ - API routing
56
+ - Database operations
57
+ - Static asset delivery
58
+
59
+ $$
60
+ \text{Primary Process}
61
+ \xrightarrow{\text{Native IPC}}
62
+ \begin{cases}
63
+ \text{Worker 1}\\
64
+ \text{Worker 2}\\
65
+ \vdots\\
66
+ \text{Worker N}
67
+ \end{cases}
68
+ $$
69
+
70
+ ### Zero Dependency Core
71
+
72
+ The server minimizes startup time, memory usage, and supply-chain risk by maintaining a lightweight dependency footprint while composing functionality through CoCreate modules.
73
+
74
+ ### Automatic Fallback & Cordoning
75
+
76
+ When every worker enters draining or cordoned mode, the Primary process automatically serves HTTP **307 Temporary Redirect** responses so incoming requests can immediately reconnect through external load balancers without downtime.
77
+
78
+ ---
79
+
80
+ ## Core Server Modules
81
+
82
+ | Module | Purpose |
83
+ | --- | --- |
84
+ | `index.js` | Primary server orchestrator |
85
+ | `ipc.js` | Inter-process communication engine |
86
+ | `storage.js` | Cluster-wide reactive storage |
87
+ | `getInfrastructure.js` | Infrastructure detection |
88
+ | `getIp.js` | Public and private IP resolution |
89
+
90
+ ---
91
+
92
+ ## Component Mesh Architecture
93
+
94
+ The server composes multiple standalone CoCreate modules into a unified runtime.
95
+
96
+ | Module | Responsibility |
97
+ | --- | --- |
98
+ | `@cocreate/acme` | TLS certificate management |
99
+ | `@cocreate/socket-server` | WebSocket server |
100
+ | `@cocreate/server-mesh` | Cluster communication |
101
+ | `@cocreate/crud-server` | Database routing |
102
+ | `@cocreate/server-autoscaler` | Automatic scaling |
103
+ | `@cocreate/server-telemetry` | Monitoring and metrics |
104
+ | `@cocreate/api` | Dynamic API execution |
105
+ | `@cocreate/file-server` | Static file serving |
106
+ | `@cocreate/lazy-loader` | Lazy loading and webhooks |
107
+
108
+ ---
109
+
110
+ ## Programmatic API Reference
111
+
112
+ Every server instance extends Node.js `EventEmitter`.
113
+
114
+ ### Instance Properties
115
+
116
+ | Property | Description |
117
+ | --- | --- |
118
+ | `id` | Unique server identifier |
119
+ | `isPrimary` | Indicates Primary process |
120
+ | `workerId` | Worker identifier |
121
+ | `totalWorkers` | Number of workers |
122
+ | `state` | Current server state |
123
+ | `storage` / `store` | Reactive cluster storage |
124
+ | `send()` | IPC message dispatcher |
125
+
126
+ ### Status Events
127
+
128
+ ```javascript
129
+ server.on("status_change", ({ oldStatus, newStatus }) => {
130
+ console.log(`State changed from ${oldStatus} to ${newStatus}`);
131
+ });
132
+ ```
133
+
134
+ ---
135
+
136
+ ## Ingress & Connection Controls
137
+
138
+ ### `server.cordon(value)`
139
+
140
+ Enable or disable maintenance mode.
141
+
142
+ ```javascript
143
+ server.cordon(true);
144
+
145
+ server.emit("cordon", {
146
+ value: true
147
+ });
148
+
149
+ server.cordon(false);
150
+ ```
151
+
152
+ ---
153
+
154
+ ### `server.shed(organizations)`
155
+
156
+ Drain selected organizations.
157
+
158
+ ```javascript
159
+ server.shed([
160
+ "org_abc123",
161
+ "org_xyz789"
162
+ ]);
163
+
164
+ server.shed(false);
165
+ ```
166
+
167
+ ---
168
+
169
+ ### `server.drain(value)`
170
+
171
+ Gracefully disconnect active clients.
172
+
173
+ ```javascript
174
+ server.drain(true);
175
+
176
+ server.drain(false);
177
+ ```
178
+
179
+ ---
180
+
181
+ ## Process & OS Lifecycle Management
182
+
183
+ ### Restart
184
+
185
+ ```javascript
186
+ server.restart();
187
+
188
+ server.restart({
189
+ isPrimary: true
190
+ });
191
+ ```
192
+
193
+ Worker restart:
194
+
195
+ - Drains connections
196
+ - Exits gracefully
197
+ - Primary automatically forks replacement
198
+
199
+ Primary restart:
200
+
201
+ - Closes cluster services
202
+ - Exits cleanly
203
+ - System service restarts application
204
+
205
+ ---
206
+
207
+ ### Reboot
208
+
209
+ ```javascript
210
+ server.reboot();
211
+ ```
212
+
213
+ Gracefully reboots the operating system after draining connections.
214
+
215
+ ---
216
+
217
+ ### Shutdown
218
+
219
+ ```javascript
220
+ server.shutdown();
29
221
  ```
30
222
 
31
- ```html
32
- <script src="https://cdn.cocreate.app/server/latest/CoCreate-server.min.css"></script>
223
+ Gracefully powers off the machine after draining connections.
224
+
225
+ ---
226
+
227
+ ## IPC Transport Engine
228
+
229
+ The IPC subsystem synchronizes Primary and Worker processes.
230
+
231
+ Broadcast:
232
+
233
+ ```javascript
234
+ server.send({
235
+ method: "custom_worker_event",
236
+ broadcast: true,
237
+ data: {
238
+ status: "ok"
239
+ }
240
+ });
33
241
  ```
34
242
 
35
- ## NPM
243
+ Target worker:
36
244
 
37
- ```shell
38
- $ npm i @cocreate/server
245
+ ```javascript
246
+ server.send({
247
+ method: "restart",
248
+ worker: 2
249
+ });
39
250
  ```
40
251
 
41
- ## yarn
252
+ Multiple workers:
42
253
 
43
- ```shell
44
- $ yarn install @cocreate/server
254
+ ```javascript
255
+ server.send({
256
+ method: "drain",
257
+ workers: [1, 3]
258
+ });
45
259
  ```
46
260
 
47
- # Table of Contents
261
+ ---
262
+
263
+ ## Reactive Cluster Storage Manager
48
264
 
49
- - [Table of Contents](#table-of-contents)
50
- - [Announcements](#announcements)
51
- - [Roadmap](#roadmap)
52
- - [How to Contribute](#how-to-contribute)
53
- - [About](#about)
54
- - [License](#license)
265
+ Cluster-wide synchronized key/value storage.
55
266
 
56
- <a name="announcements"></a>
267
+ ```javascript
268
+ await server.storage.set(
269
+ "node_capacity",
270
+ {
271
+ availableSlots: 45
272
+ }
273
+ );
57
274
 
58
- # Announcements
275
+ const capacity =
276
+ await server.storage.get(
277
+ "node_capacity"
278
+ );
59
279
 
60
- All updates to this library are documented in our [CHANGELOG](https://github.com/CoCreate-app/CoCreate-server/blob/master/CHANGELOG.md) and [releases](https://github.com/CoCreate-app/CoCreate-server/releases). You may also subscribe to email for releases and breaking changes.
280
+ const totalKeys =
281
+ await server.storage.size();
61
282
 
62
- <a name="roadmap"></a>
283
+ await server.storage.delete(
284
+ "node_capacity"
285
+ );
63
286
 
64
- # Roadmap
287
+ await server.storage.clear();
288
+ ```
65
289
 
66
- If you are interested in the future direction of this project, please take a look at our open [issues](https://github.com/CoCreate-app/CoCreate-server/issues) and [pull requests](https://github.com/CoCreate-app/CoCreate-server/pulls). We would love to hear your feedback.
290
+ Reactive listeners:
291
+
292
+ ```javascript
293
+ server.storage.on(
294
+ "change:node_capacity",
295
+ (newValue) => {
296
+ console.log(newValue);
297
+ }
298
+ );
299
+
300
+ server.storage.on(
301
+ "delete:node_capacity",
302
+ () => {
303
+ console.log("Deleted");
304
+ }
305
+ );
306
+ ```
67
307
 
68
- <a name="about"></a>
308
+ ---
69
309
 
70
- # About
310
+ ## Distributed Cluster Orchestration
311
+
312
+ Cluster communication is provided by `@cocreate/server-mesh`.
313
+
314
+ ```javascript
315
+ server.mesh.send({
316
+ method: "mesh.custom_command",
317
+ server: "server_b_id",
318
+ data: {
319
+ key: "value"
320
+ }
321
+ });
322
+ ```
71
323
 
72
- CoCreate-server is guided and supported by the CoCreate Developer Experience Team.
324
+ ---
73
325
 
74
- Please Email the Developer Experience Team [here](mailto:develop@cocreate.app) in case of any queries.
326
+ ## Targeting Matrix & Routing Directives
75
327
 
76
- CoCreate-server is maintained and funded by CoCreate. The names and logos for CoCreate are trademarks of CoCreate, LLC.
328
+ | Target | Example |
329
+ | --- | --- |
330
+ | Single server | `{ server: "server_b_id" }` |
331
+ | Multiple servers | `{ server: ["server_b_id","server_c_id"] }` |
332
+ | Worker | `{ server: "server_b_id", worker: 2 }` |
333
+ | Broadcast | `{ broadcast: true }` |
77
334
 
78
- <a name="contribute"></a>
335
+ ---
79
336
 
80
- # How to Contribute
337
+ ## Self-Healing & Jittered Reconnection Logic
81
338
 
82
- We encourage contribution to our libraries (you might even score some nifty swag), please see our [CONTRIBUTING](https://github.com/CoCreate-app/CoCreate-server/blob/master/CONTRIBUTING.md) guide for details.
339
+ Peer reconnections use exponential backoff with randomized jitter.
83
340
 
84
- We want this library to be community-driven, and CoCreate led. We need your help to realize this goal. To help make sure we are building the right things in the right order, we ask that you create [issues](https://github.com/CoCreate-app/CoCreate-server/issues) and [pull requests](https://github.com/CoCreate-app/CoCreate-server/pulls) or merely upvote or comment on existing issues or pull requests.
341
+ $$
342
+ T_{delay}
343
+ =
344
+ \min
345
+ \left(
346
+ 30000,
347
+ 1000\times1.5^{attempt}
348
+ \right)
349
+ +
350
+ random(500,4500)
351
+ $$
85
352
 
86
- We appreciate your continued support, thank you!
353
+ This prevents reconnect storms after temporary outages.
87
354
 
88
- <a name="license"></a>
355
+ ---
89
356
 
90
- # License
357
+ ## Dynamic Tenant Eviction & Cascading Teardown Sequence
358
+
359
+ Tenant lifecycle is driven by active socket connections.
360
+
361
+ $$
362
+ \text{Client Disconnect}
363
+ \rightarrow
364
+ \text{60 Second Grace Period}
365
+ \rightarrow
366
+ \text{Organization Removed}
367
+ $$
368
+
369
+ Once the final client disconnects:
370
+
371
+ 1. A 60-second timer begins.
372
+ 2. Workers release tenant resources.
373
+ 3. Peer servers receive notification.
374
+ 4. Database pools, telemetry buffers, and mesh tunnels are released.
375
+
376
+ ---
377
+
378
+ ## Security-Hardened Design
379
+
380
+ - Mutual TLS encrypted cluster communication
381
+ - Dedicated internal mesh network
382
+ - Automatic UUID generation for distributed tracing
383
+ - Ephemeral TLS certificates managed by `@cocreate/acme`
384
+
385
+ ---
386
+
387
+ ## Installation
388
+
389
+ ### NPM
390
+
391
+ ```bash
392
+ npm install @cocreate/server
393
+ ```
394
+
395
+ ### Yarn
396
+
397
+ ```bash
398
+ yarn add @cocreate/server
399
+ ```
400
+
401
+ ---
402
+
403
+ ## Quick Start
404
+
405
+ ```javascript
406
+ import CoCreateServer from "@cocreate/server";
407
+
408
+ async function startServer() {
409
+ const server =
410
+ await CoCreateServer.init();
411
+
412
+ server.on(
413
+ "status_change",
414
+ ({ oldStatus, newStatus }) => {
415
+ console.log(
416
+ `${oldStatus} -> ${newStatus}`
417
+ );
418
+ }
419
+ );
420
+ }
421
+
422
+ startServer();
423
+ ```
424
+
425
+ ---
426
+
427
+ ## Announcements
428
+
429
+ Release notes include new features, performance improvements, security updates, and compatibility changes. Follow the repository to stay informed about the latest releases.
430
+
431
+ ---
432
+
433
+ ## Roadmap
434
+
435
+ Upcoming improvements include:
436
+
437
+ - Enhanced cluster orchestration
438
+ - Improved process supervision
439
+ - Adaptive worker allocation
440
+ - Expanded telemetry integration
441
+ - Additional deployment adapters
442
+
443
+ ---
444
+
445
+ ## How to Contribute
446
+
447
+ Community contributions are welcome.
448
+
449
+ Please review:
450
+
451
+ - Documentation
452
+ - CONTRIBUTING.md
453
+ - GitHub Issues
454
+ - GitHub Discussions
455
+
456
+ Bug reports, feature requests, documentation improvements, and pull requests are appreciated.
457
+
458
+ ---
459
+
460
+ ## About
461
+
462
+ `@cocreate/server` is designed, built, and maintained by the CoCreate Developer Experience Team.
463
+
464
+ It serves as the core runtime responsible for process orchestration, clustering, networking, module composition, and lifecycle management across the CoCreate platform.
465
+
466
+ ---
467
+
468
+ ## License
91
469
 
92
470
  This software is dual-licensed under the GNU Affero General Public License version 3 (AGPLv3) and a commercial license.
93
471
 
94
- - **Open Source Use**: For open-source projects and non-commercial use, this software is available under the AGPLv3. The AGPLv3 allows you to freely use, modify, and distribute this software, provided that all modifications and derivative works are also licensed under the AGPLv3. For the full license text, see the [LICENSE file](https://github.com/CoCreate-app/CoCreate-socket-client/blob/master/LICENSE).
472
+ ### Open Source
473
+
474
+ For open-source projects and non-commercial use, this software is available under the AGPLv3. See the `LICENSE` file for complete license terms.
95
475
 
96
- - **Commercial Use**: For-profit companies and individuals intending to use this software for commercial purposes must obtain a commercial license. The commercial license is available when you sign up for an API key on our [website](https://cocreate.app). This license permits proprietary use and modification of the software without the copyleft requirements of the AGPLv3. It is ideal for integrating this software into proprietary commercial products and applications.
476
+ ### Commercial
97
477
 
98
- If you have not purchased a commercial license and intend to use this software for commercial purposes, you are required to sign up for an API key on our website.
478
+ Organizations requiring proprietary use may obtain a commercial license from CoCreate.
package/package.json CHANGED
@@ -1,17 +1,22 @@
1
1
  {
2
2
  "name": "@cocreate/server",
3
- "version": "1.6.1",
4
- "description": "A dynamic SSL certificate management and generation tool for proxies like NGINX, with a fallback to Node.js SSL termination. It seamlessly integrates HTTP, HTTPS, and ACME protocols to ensure secure, encrypted connections.",
3
+ "version": "1.6.2",
4
+ "description": "A secure, stateless, clustered headless server built for high-performance multi-tenancy, real-time collaboration, and sandboxed AST execution.",
5
5
  "keywords": [
6
- "ssl-certificate-management",
7
- "nginx",
8
- "nodejs-ssl-termination",
9
- "https",
6
+ "stateless-server",
7
+ "headless-architecture",
8
+ "realtime-collaboration",
9
+ "node-cluster",
10
+ "clustering-ipc",
11
+ "ast-flow-engine",
12
+ "multi-tenancy",
13
+ "websocket-server",
14
+ "dynamic-ssl-generation",
10
15
  "acme-protocol",
11
16
  "secure-connections",
12
- "encryption",
13
- "dynamic-ssl-generation",
14
- "proxy-security",
17
+ "zero-dependency-policy",
18
+ "byodb",
19
+ "orchestration",
15
20
  "web-security"
16
21
  ],
17
22
  "publishConfig": {