fluxion-ts 0.14.1 → 0.14.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 +30 -35
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,27 +23,20 @@ Fluxion is a filesystem-routing dynamic server for Node.js.
|
|
|
23
23
|
## Install
|
|
24
24
|
|
|
25
25
|
```bash
|
|
26
|
-
pnpm add fluxion
|
|
26
|
+
pnpm add fluxion-ts
|
|
27
|
+
pnom add -D tsx # Recommanded, this enables fluxion to hot reload ts files
|
|
27
28
|
```
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
**You need [tsx](https://www.npmjs.com/package/tsx) to run fluxion**
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
fluxion # loads fluxion.config.ts by default
|
|
35
|
-
fluxion --config custom-fluxion.config.ts
|
|
36
|
-
|
|
37
|
-
```
|
|
30
|
+
Fluxion is started programmatically from your own Node.js entry file. There is no built-in CLI entry anymore.
|
|
38
31
|
|
|
39
32
|
## Quick Start
|
|
40
33
|
|
|
41
|
-
Create `server.
|
|
34
|
+
Create `server.ts`:
|
|
42
35
|
|
|
43
|
-
```
|
|
44
|
-
import { fluxion } from 'fluxion';
|
|
36
|
+
```ts
|
|
37
|
+
import { fluxion } from 'fluxion-ts';
|
|
45
38
|
|
|
46
|
-
fluxion({
|
|
39
|
+
await fluxion({
|
|
47
40
|
dir: './dynamicDirectory',
|
|
48
41
|
host: '127.0.0.1',
|
|
49
42
|
port: 3000,
|
|
@@ -53,7 +46,7 @@ fluxion({
|
|
|
53
46
|
Create `dynamicDirectory/hello.ts`:
|
|
54
47
|
|
|
55
48
|
```ts
|
|
56
|
-
import { defineFluxionModule } from 'fluxion';
|
|
49
|
+
import { defineFluxionModule } from 'fluxion-ts';
|
|
57
50
|
|
|
58
51
|
export default defineFluxionModule(async (req, cx) => {
|
|
59
52
|
return {
|
|
@@ -66,7 +59,7 @@ export default defineFluxionModule(async (req, cx) => {
|
|
|
66
59
|
Run:
|
|
67
60
|
|
|
68
61
|
```bash
|
|
69
|
-
|
|
62
|
+
tsx server.ts
|
|
70
63
|
```
|
|
71
64
|
|
|
72
65
|
Request:
|
|
@@ -81,18 +74,18 @@ Response:
|
|
|
81
74
|
{"message":"hello fluxion","path":"/hello.ts"}
|
|
82
75
|
```
|
|
83
76
|
|
|
84
|
-
##
|
|
77
|
+
## Bootstrap Entry
|
|
85
78
|
|
|
86
|
-
|
|
79
|
+
Your application is responsible for creating the bootstrap file and passing options to `fluxion()`.
|
|
87
80
|
|
|
88
|
-
|
|
81
|
+
Example:
|
|
89
82
|
|
|
90
83
|
```ts
|
|
91
|
-
fluxion({
|
|
92
|
-
dir: process.env.DYNAMIC_DIRECTORY ?? 'dynamicDirectory',
|
|
93
|
-
host: process.env.HOST ?? '
|
|
94
|
-
port: Number.parseInt(process.env.PORT ?? '
|
|
95
|
-
metaPort: Number.parseInt(process.env.META_PORT ?? '
|
|
84
|
+
await fluxion({
|
|
85
|
+
dir: process.env.DYNAMIC_DIRECTORY ?? './dynamicDirectory',
|
|
86
|
+
host: process.env.HOST ?? '127.0.0.1',
|
|
87
|
+
port: Number.parseInt(process.env.PORT ?? '3000', 10),
|
|
88
|
+
metaPort: Number.parseInt(process.env.META_PORT ?? '3001', 10),
|
|
96
89
|
workerOptions: {
|
|
97
90
|
maxWorkerCount: 4,
|
|
98
91
|
},
|
|
@@ -167,7 +160,7 @@ handler(req, cx, rawReq, rawRes)
|
|
|
167
160
|
### Advanced Module Configuration
|
|
168
161
|
|
|
169
162
|
```ts
|
|
170
|
-
import { defineFluxionModule, defineFluxionMiddleware } from 'fluxion';
|
|
163
|
+
import { defineFluxionModule, defineFluxionMiddleware } from 'fluxion-ts';
|
|
171
164
|
|
|
172
165
|
const logMiddleware = defineFluxionMiddleware(async (req, cx) => {
|
|
173
166
|
cx.logger.info('Request received', { path: req.url.pathname });
|
|
@@ -200,7 +193,7 @@ interface FluxionModule {
|
|
|
200
193
|
Middleware functions execute sequentially before the handler. They can modify request parameters through side effects.
|
|
201
194
|
|
|
202
195
|
```ts
|
|
203
|
-
import { defineFluxionMiddleware, defineFluxionModule } from 'fluxion';
|
|
196
|
+
import { defineFluxionMiddleware, defineFluxionModule } from 'fluxion-ts';
|
|
204
197
|
|
|
205
198
|
const authMiddleware = defineFluxionMiddleware(async (req, cx, rawReq, rawRes) => {
|
|
206
199
|
const token = req.headers.authorization;
|
|
@@ -233,7 +226,7 @@ import {
|
|
|
233
226
|
BadRequestException,
|
|
234
227
|
UnauthorizedException,
|
|
235
228
|
NotFoundException,
|
|
236
|
-
} from 'fluxion';
|
|
229
|
+
} from 'fluxion-ts';
|
|
237
230
|
|
|
238
231
|
export default defineFluxionModule(async (req) => {
|
|
239
232
|
if (!req.query.id) {
|
|
@@ -373,16 +366,16 @@ interface FluxionOptions {
|
|
|
373
366
|
// Optional timeout configurations
|
|
374
367
|
handlerTimeoutMs?: number; // Default: 5000ms
|
|
375
368
|
middlewareTimeoutMs?: number; // Default: 3000ms
|
|
376
|
-
staticResourceTimeoutMs?: number; // Default:
|
|
369
|
+
staticResourceTimeoutMs?: number; // Default: 6000000ms (100min)
|
|
377
370
|
|
|
378
371
|
// File watching
|
|
379
372
|
reloadDelay?: number; // Default: 500ms
|
|
380
373
|
nativeWatcher?: boolean; // Use fs.watch instead of chokidar
|
|
381
374
|
|
|
382
375
|
// File registration patterns
|
|
383
|
-
include?: string[]; //
|
|
384
|
-
apiInclude?: string[]; //
|
|
385
|
-
exclude?: string[];
|
|
376
|
+
include?: string[]; // Default: ['**/*']
|
|
377
|
+
apiInclude?: string[]; // Default: ['**/*.ts']
|
|
378
|
+
exclude?: string[]; // Overrides the built-in ignore list
|
|
386
379
|
|
|
387
380
|
// Meta API
|
|
388
381
|
metaPort?: number; // Default: port + 1
|
|
@@ -402,16 +395,16 @@ interface FluxionOptions {
|
|
|
402
395
|
maxRequestBytes?: number; // Default: 8_000_000
|
|
403
396
|
|
|
404
397
|
// Logging
|
|
405
|
-
logger?: 'one-line' | 'json-line' | FluxionLoggerFn;
|
|
398
|
+
logger?: 'one-line' | 'json-line' | FluxionLoggerFn; // Default: 'one-line'
|
|
406
399
|
|
|
407
400
|
// Module system
|
|
408
401
|
moduleDir?: string; // Default: process.cwd()
|
|
409
402
|
|
|
410
403
|
// HTTPS
|
|
411
404
|
https?: {
|
|
412
|
-
key: string
|
|
413
|
-
cert: string
|
|
414
|
-
ca?: string |
|
|
405
|
+
key: string;
|
|
406
|
+
cert: string;
|
|
407
|
+
ca?: string | Array<string | Buffer> | Buffer;
|
|
415
408
|
};
|
|
416
409
|
}
|
|
417
410
|
```
|
|
@@ -469,6 +462,8 @@ fluxion({
|
|
|
469
462
|
|
|
470
463
|
Relative paths are resolved relative to `moduleDir`. PEM content can be passed directly as strings.
|
|
471
464
|
|
|
465
|
+
Default exclusions in the current implementation include `node_modules`, `.git`, `dist`, `build`, `.vscode`, `.idea`, `coverage`, `.nyc_output`, `*.log`, `*.tmp`, and `*.temp`.
|
|
466
|
+
|
|
472
467
|
## Recent Updates
|
|
473
468
|
|
|
474
469
|
### v0.11.x
|