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.
- package/dist/index.d.ts +126 -0
- package/dist/index.mjs +2250 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +9 -1
- package/.oxlintrc.json +0 -64
- package/.prettierrc +0 -6
- package/AGENTS.md +0 -3
- package/Dockerfile +0 -13
- package/document/index.html +0 -16
- package/document/src/main.tsx +0 -8
- package/document/src/styles.css +0 -321
- package/document/src/view/App.tsx +0 -304
- package/document/src/view/CodeBlock.tsx +0 -11
- package/document/src/view/Section.tsx +0 -18
- package/document/vite.config.ts +0 -23
- package/draft/vibe.md +0 -50
- package/rollup.config.mjs +0 -102
- package/scripts/build-image.ts +0 -13
- package/scripts/bump-version.ts +0 -12
- package/scripts/configs.ts +0 -79
- package/scripts/lines.ts +0 -54
- package/scripts/publish.ts +0 -6
- package/src/common/consts.ts +0 -30
- package/src/common/dtm.ts +0 -10
- package/src/common/logger.ts +0 -145
- package/src/core/meta-api.ts +0 -48
- package/src/core/server.ts +0 -439
- package/src/core/types.d.ts +0 -6
- package/src/core/utils/headers.ts +0 -34
- package/src/core/utils/request.ts +0 -145
- package/src/core/utils/send-json.ts +0 -21
- package/src/index.ts +0 -11
- package/src/workers/file-runtime.ts +0 -1092
- package/src/workers/handler-worker-pool.ts +0 -754
- package/src/workers/handler-worker.ts +0 -1029
- package/src/workers/options.ts +0 -77
- package/src/workers/protocol.d.ts +0 -186
- package/tests/core/dynamic-directory.test.ts +0 -48
- package/tests/core/file-runtime.test.ts +0 -374
- package/tests/core/server-options.test.ts +0 -204
- package/tests/e2e/fluxion-server.e2e-spec.ts +0 -225
- package/tests/helpers/test-utils.ts +0 -81
- package/tsconfig.json +0 -22
- package/vitest.config.ts +0 -24
package/dist/index.d.ts
ADDED
|
@@ -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 };
|