fluxion-ts 0.0.6 → 0.0.8

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 (44) hide show
  1. package/dist/index.d.ts +126 -0
  2. package/dist/index.mjs +2250 -0
  3. package/dist/index.mjs.map +1 -0
  4. package/package.json +9 -1
  5. package/.oxlintrc.json +0 -64
  6. package/.prettierrc +0 -6
  7. package/AGENTS.md +0 -3
  8. package/Dockerfile +0 -13
  9. package/document/index.html +0 -16
  10. package/document/src/main.tsx +0 -8
  11. package/document/src/styles.css +0 -321
  12. package/document/src/view/App.tsx +0 -304
  13. package/document/src/view/CodeBlock.tsx +0 -11
  14. package/document/src/view/Section.tsx +0 -18
  15. package/document/vite.config.ts +0 -23
  16. package/draft/vibe.md +0 -50
  17. package/rollup.config.mjs +0 -102
  18. package/scripts/build-image.ts +0 -13
  19. package/scripts/bump-version.ts +0 -12
  20. package/scripts/configs.ts +0 -79
  21. package/scripts/lines.ts +0 -54
  22. package/scripts/publish.ts +0 -6
  23. package/src/common/consts.ts +0 -30
  24. package/src/common/dtm.ts +0 -10
  25. package/src/common/logger.ts +0 -145
  26. package/src/core/meta-api.ts +0 -48
  27. package/src/core/server.ts +0 -439
  28. package/src/core/types.d.ts +0 -6
  29. package/src/core/utils/headers.ts +0 -34
  30. package/src/core/utils/request.ts +0 -145
  31. package/src/core/utils/send-json.ts +0 -21
  32. package/src/index.ts +0 -11
  33. package/src/workers/file-runtime.ts +0 -1092
  34. package/src/workers/handler-worker-pool.ts +0 -754
  35. package/src/workers/handler-worker.ts +0 -1029
  36. package/src/workers/options.ts +0 -77
  37. package/src/workers/protocol.d.ts +0 -186
  38. package/tests/core/dynamic-directory.test.ts +0 -48
  39. package/tests/core/file-runtime.test.ts +0 -374
  40. package/tests/core/server-options.test.ts +0 -204
  41. package/tests/e2e/fluxion-server.e2e-spec.ts +0 -225
  42. package/tests/helpers/test-utils.ts +0 -81
  43. package/tsconfig.json +0 -22
  44. package/vitest.config.ts +0 -24
@@ -0,0 +1,126 @@
1
+ import http from 'node:http';
2
+
3
+ type LogLevel = 'INFO' | 'WARN' | 'ERROR' | 'SUCC';
4
+ interface LogEntry {
5
+ timestamp: string;
6
+ level: LogLevel;
7
+ event: string;
8
+ message?: string;
9
+ [key: string]: unknown;
10
+ }
11
+ type LoggerMode = 'one-line' | 'json-line';
12
+ type LoggerSink = (entry: LogEntry) => void;
13
+ type LoggerOption = LoggerMode | LoggerSink;
14
+
15
+ /**
16
+ * Worker runtime tuning options.
17
+ */
18
+ interface ExecutorOptions {
19
+ /**
20
+ * Request timeout in milliseconds.
21
+ */
22
+ requestTimeoutMs: number;
23
+ /**
24
+ * Maximum concurrent requests allowed in the pool.
25
+ */
26
+ maxInflight: number;
27
+ /**
28
+ * Soft heap threshold in MB. Idle worker may restart after crossing it.
29
+ */
30
+ memorySoftLimitMb: number;
31
+ /**
32
+ * ! Hard heap threshold in MB. Worker is restarted once reached.
33
+ */
34
+ memoryHardLimitMb: number;
35
+ /**
36
+ * Memory telemetry interval in milliseconds.
37
+ */
38
+ memorySampleIntervalMs: number;
39
+ /**
40
+ * ! V8 old-generation limit per worker in MB.
41
+ */
42
+ maxOldGenerationSizeMb: number;
43
+ /**
44
+ * ! V8 young-generation limit per worker in MB.
45
+ */
46
+ maxYoungGenerationSizeMb: number;
47
+ /**
48
+ * Worker stack size in MB.
49
+ */
50
+ stackSizeMb: number;
51
+ /**
52
+ * ! Maximum response payload bytes allowed from worker to main thread.
53
+ */
54
+ maxResponseBytes: number;
55
+ }
56
+ /**
57
+ * Custom worker item used by `workerStrategy`.
58
+ */
59
+ interface WorkerStrategyCustomItem extends Partial<ExecutorOptions> {
60
+ /**
61
+ * Stable worker id.
62
+ */
63
+ id: string;
64
+ /**
65
+ * Database names this worker can access.
66
+ */
67
+ db: string[];
68
+ }
69
+ /**
70
+ * Worker strategy selector.
71
+ */
72
+ type WorkerStrategy = 'all' | WorkerStrategyCustomItem[];
73
+
74
+ /**
75
+ * Database config item accepted by server options.
76
+ */
77
+ interface FluxionDatabaseConfig {
78
+ /**
79
+ * Stable database name.
80
+ */
81
+ name: string;
82
+ }
83
+ /**
84
+ * User-provided database config input.
85
+ */
86
+ type FluxionDatabaseInput = string | FluxionDatabaseConfig;
87
+ interface FluxionOptions {
88
+ /**
89
+ * The directory where dynamic files (e.g. uploaded files) will be stored. It will be created if it doesn't exist.
90
+ * It is recommended to use an empty directory that is not used for any other purpose, to avoid potential conflicts or security issues.
91
+ */
92
+ dir: string;
93
+ host: string;
94
+ port: number;
95
+ /**
96
+ * Declared database names used by worker strategy routing.
97
+ */
98
+ databases?: FluxionDatabaseInput[];
99
+ /**
100
+ * Optional path to private db config file.
101
+ * Defaults to `./.fluxion-private/db.config.cjs`.
102
+ */
103
+ dbConfigPath?: string;
104
+ /**
105
+ * Worker routing strategy.
106
+ */
107
+ workerStrategy?: WorkerStrategy;
108
+ /**
109
+ * Base worker runtime option overrides.
110
+ */
111
+ workerOptions?: Partial<ExecutorOptions>;
112
+ /**
113
+ * Maximum request body bytes accepted by dynamic handlers.
114
+ * Requests larger than this limit will return 413.
115
+ */
116
+ maxRequestBytes?: number;
117
+ /**
118
+ * Logger output mode or custom logger sink.
119
+ * Defaults to `one-line`.
120
+ */
121
+ logger?: LoggerOption;
122
+ }
123
+ declare function fluxion(options: FluxionOptions): http.Server;
124
+
125
+ export { fluxion };
126
+ export type { FluxionOptions };