fragment-ts 1.3.1 → 2.0.1
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/API.md +21 -0
- package/DOCS.md +6 -0
- package/SETUP.md +53 -140
- package/USAGE.md +47 -120
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/platform/cli/scaffold/init/init.scaffold.js +1 -1
- package/dist/platform/web/application.d.ts +8 -1
- package/dist/platform/web/application.d.ts.map +1 -1
- package/dist/platform/web/application.js +12 -2
- package/dist/platform/web/application.js.map +1 -1
- package/dist/platform/web/middleware/MiddlewareSetup.d.ts +14 -2
- package/dist/platform/web/middleware/MiddlewareSetup.d.ts.map +1 -1
- package/dist/platform/web/middleware/MiddlewareSetup.js +22 -6
- package/dist/platform/web/middleware/MiddlewareSetup.js.map +1 -1
- package/package.json +2 -2
package/API.md
CHANGED
|
@@ -7,6 +7,7 @@ Each item is documented on its own line for easy search and indexing.
|
|
|
7
7
|
|
|
8
8
|
- `FragmentApplication(options)` class decorator
|
|
9
9
|
- `FragmentWebApplication` bootstrap class
|
|
10
|
+
- `FragmentWebApplicationOptions` runtime middleware options
|
|
10
11
|
- `DIContainer` dependency injection container
|
|
11
12
|
- `MetadataStorage` metadata registry
|
|
12
13
|
- `ComponentScanner` manual component scanning
|
|
@@ -381,6 +382,26 @@ async function bootstrap() {
|
|
|
381
382
|
bootstrap();
|
|
382
383
|
```
|
|
383
384
|
|
|
385
|
+
### Express Configuration (CORS and Middleware)
|
|
386
|
+
|
|
387
|
+
```ts
|
|
388
|
+
import cors from "cors";
|
|
389
|
+
import { FragmentApplication, FragmentWebApplication } from "fragment-ts";
|
|
390
|
+
|
|
391
|
+
@FragmentApplication({ port: 3000 })
|
|
392
|
+
class App {}
|
|
393
|
+
|
|
394
|
+
const web = new FragmentWebApplication({
|
|
395
|
+
defaultMiddleware: { cors: false },
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
web.configureExpress((app) => {
|
|
399
|
+
app.use(cors({ origin: ["https://app.example.com"], credentials: true }));
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
await web.bootstrap(App);
|
|
403
|
+
```
|
|
404
|
+
|
|
384
405
|
### DI and Services
|
|
385
406
|
|
|
386
407
|
```ts
|
package/DOCS.md
CHANGED
|
@@ -57,6 +57,12 @@ The web pipeline is layered:
|
|
|
57
57
|
6. Interceptors
|
|
58
58
|
7. Exception filters
|
|
59
59
|
|
|
60
|
+
Fragment now exposes direct Express access in the bootstrap flow:
|
|
61
|
+
- `new FragmentWebApplication({ defaultMiddleware: { cors: false } })` disables only default CORS.
|
|
62
|
+
- `new FragmentWebApplication({ useDefaultMiddleware: false })` disables all default middleware.
|
|
63
|
+
- `configureExpress((app) => app.use(...))` lets users register middleware exactly like standard Express.
|
|
64
|
+
- `setupMiddleware((middleware) => middleware.setupBasicMiddleware(...))` keeps usage inside framework primitives while still configurable.
|
|
65
|
+
|
|
60
66
|
## Lifecycle Hooks
|
|
61
67
|
|
|
62
68
|
Lifecycle hooks are divided into:
|
package/SETUP.md
CHANGED
|
@@ -380,149 +380,25 @@ To install a plugin:
|
|
|
380
380
|
- Keep `.env.example` and `fragment.json` synchronized.
|
|
381
381
|
- Favor environment interpolation with `${VAR}` for secrets.
|
|
382
382
|
- Use `fragment env:diff` when switching environments.
|
|
383
|
-
- Note 1: Recheck configuration after major dependency upgrades.
|
|
384
|
-
- Note 2: Recheck configuration after major dependency upgrades.
|
|
385
|
-
- Note 3: Recheck configuration after major dependency upgrades.
|
|
386
|
-
- Note 4: Recheck configuration after major dependency upgrades.
|
|
387
|
-
- Note 5: Recheck configuration after major dependency upgrades.
|
|
388
|
-
- Note 6: Recheck configuration after major dependency upgrades.
|
|
389
|
-
- Note 7: Recheck configuration after major dependency upgrades.
|
|
390
|
-
- Note 8: Recheck configuration after major dependency upgrades.
|
|
391
|
-
- Note 9: Recheck configuration after major dependency upgrades.
|
|
392
|
-
- Note 10: Recheck configuration after major dependency upgrades.
|
|
393
|
-
- Note 11: Recheck configuration after major dependency upgrades.
|
|
394
|
-
- Note 12: Recheck configuration after major dependency upgrades.
|
|
395
|
-
- Note 13: Recheck configuration after major dependency upgrades.
|
|
396
|
-
- Note 14: Recheck configuration after major dependency upgrades.
|
|
397
|
-
- Note 15: Recheck configuration after major dependency upgrades.
|
|
398
|
-
- Note 16: Recheck configuration after major dependency upgrades.
|
|
399
|
-
- Note 17: Recheck configuration after major dependency upgrades.
|
|
400
|
-
- Note 18: Recheck configuration after major dependency upgrades.
|
|
401
|
-
- Note 19: Recheck configuration after major dependency upgrades.
|
|
402
|
-
- Note 20: Recheck configuration after major dependency upgrades.
|
|
403
|
-
- Note 21: Recheck configuration after major dependency upgrades.
|
|
404
|
-
- Note 22: Recheck configuration after major dependency upgrades.
|
|
405
|
-
- Note 23: Recheck configuration after major dependency upgrades.
|
|
406
|
-
- Note 24: Recheck configuration after major dependency upgrades.
|
|
407
|
-
- Note 25: Recheck configuration after major dependency upgrades.
|
|
408
|
-
- Note 26: Recheck configuration after major dependency upgrades.
|
|
409
|
-
- Note 27: Recheck configuration after major dependency upgrades.
|
|
410
|
-
- Note 28: Recheck configuration after major dependency upgrades.
|
|
411
|
-
- Note 29: Recheck configuration after major dependency upgrades.
|
|
412
|
-
- Note 30: Recheck configuration after major dependency upgrades.
|
|
413
|
-
- Note 31: Recheck configuration after major dependency upgrades.
|
|
414
|
-
- Note 32: Recheck configuration after major dependency upgrades.
|
|
415
|
-
- Note 33: Recheck configuration after major dependency upgrades.
|
|
416
|
-
- Note 34: Recheck configuration after major dependency upgrades.
|
|
417
|
-
- Note 35: Recheck configuration after major dependency upgrades.
|
|
418
|
-
- Note 36: Recheck configuration after major dependency upgrades.
|
|
419
|
-
- Note 37: Recheck configuration after major dependency upgrades.
|
|
420
|
-
- Note 38: Recheck configuration after major dependency upgrades.
|
|
421
|
-
- Note 39: Recheck configuration after major dependency upgrades.
|
|
422
|
-
- Note 40: Recheck configuration after major dependency upgrades.
|
|
423
|
-
- Note 41: Recheck configuration after major dependency upgrades.
|
|
424
|
-
- Note 42: Recheck configuration after major dependency upgrades.
|
|
425
|
-
- Note 43: Recheck configuration after major dependency upgrades.
|
|
426
|
-
- Note 44: Recheck configuration after major dependency upgrades.
|
|
427
|
-
- Note 45: Recheck configuration after major dependency upgrades.
|
|
428
|
-
- Note 46: Recheck configuration after major dependency upgrades.
|
|
429
|
-
- Note 47: Recheck configuration after major dependency upgrades.
|
|
430
|
-
- Note 48: Recheck configuration after major dependency upgrades.
|
|
431
|
-
- Note 49: Recheck configuration after major dependency upgrades.
|
|
432
|
-
- Note 50: Recheck configuration after major dependency upgrades.
|
|
433
|
-
- Note 51: Recheck configuration after major dependency upgrades.
|
|
434
|
-
- Note 52: Recheck configuration after major dependency upgrades.
|
|
435
|
-
- Note 53: Recheck configuration after major dependency upgrades.
|
|
436
|
-
- Note 54: Recheck configuration after major dependency upgrades.
|
|
437
|
-
- Note 55: Recheck configuration after major dependency upgrades.
|
|
438
|
-
- Note 56: Recheck configuration after major dependency upgrades.
|
|
439
|
-
- Note 57: Recheck configuration after major dependency upgrades.
|
|
440
|
-
- Note 58: Recheck configuration after major dependency upgrades.
|
|
441
|
-
- Note 59: Recheck configuration after major dependency upgrades.
|
|
442
|
-
- Note 60: Recheck configuration after major dependency upgrades.
|
|
443
|
-
- Note 61: Recheck configuration after major dependency upgrades.
|
|
444
|
-
- Note 62: Recheck configuration after major dependency upgrades.
|
|
445
|
-
- Note 63: Recheck configuration after major dependency upgrades.
|
|
446
|
-
- Note 64: Recheck configuration after major dependency upgrades.
|
|
447
|
-
- Note 65: Recheck configuration after major dependency upgrades.
|
|
448
|
-
- Note 66: Recheck configuration after major dependency upgrades.
|
|
449
|
-
- Note 67: Recheck configuration after major dependency upgrades.
|
|
450
|
-
- Note 68: Recheck configuration after major dependency upgrades.
|
|
451
|
-
- Note 69: Recheck configuration after major dependency upgrades.
|
|
452
|
-
- Note 70: Recheck configuration after major dependency upgrades.
|
|
453
|
-
- Note 71: Recheck configuration after major dependency upgrades.
|
|
454
|
-
- Note 72: Recheck configuration after major dependency upgrades.
|
|
455
|
-
- Note 73: Recheck configuration after major dependency upgrades.
|
|
456
|
-
- Note 74: Recheck configuration after major dependency upgrades.
|
|
457
|
-
- Note 75: Recheck configuration after major dependency upgrades.
|
|
458
|
-
- Note 76: Recheck configuration after major dependency upgrades.
|
|
459
|
-
- Note 77: Recheck configuration after major dependency upgrades.
|
|
460
|
-
- Note 78: Recheck configuration after major dependency upgrades.
|
|
461
|
-
- Note 79: Recheck configuration after major dependency upgrades.
|
|
462
|
-
- Note 80: Recheck configuration after major dependency upgrades.
|
|
463
383
|
|
|
464
384
|
## Setup FAQ
|
|
465
385
|
|
|
466
|
-
-
|
|
467
|
-
|
|
468
|
-
-
|
|
469
|
-
|
|
470
|
-
-
|
|
471
|
-
|
|
472
|
-
-
|
|
473
|
-
|
|
474
|
-
-
|
|
475
|
-
|
|
476
|
-
-
|
|
477
|
-
|
|
478
|
-
-
|
|
479
|
-
|
|
480
|
-
-
|
|
481
|
-
|
|
482
|
-
- Setup FAQ 17: Use `fragment cache:clear` if config changes are not picked up.
|
|
483
|
-
- Setup FAQ 18: Use `fragment cache:clear` if config changes are not picked up.
|
|
484
|
-
- Setup FAQ 19: Use `fragment cache:clear` if config changes are not picked up.
|
|
485
|
-
- Setup FAQ 20: Use `fragment cache:clear` if config changes are not picked up.
|
|
486
|
-
- Setup FAQ 21: Use `fragment cache:clear` if config changes are not picked up.
|
|
487
|
-
- Setup FAQ 22: Use `fragment cache:clear` if config changes are not picked up.
|
|
488
|
-
- Setup FAQ 23: Use `fragment cache:clear` if config changes are not picked up.
|
|
489
|
-
- Setup FAQ 24: Use `fragment cache:clear` if config changes are not picked up.
|
|
490
|
-
- Setup FAQ 25: Use `fragment cache:clear` if config changes are not picked up.
|
|
491
|
-
- Setup FAQ 26: Use `fragment cache:clear` if config changes are not picked up.
|
|
492
|
-
- Setup FAQ 27: Use `fragment cache:clear` if config changes are not picked up.
|
|
493
|
-
- Setup FAQ 28: Use `fragment cache:clear` if config changes are not picked up.
|
|
494
|
-
- Setup FAQ 29: Use `fragment cache:clear` if config changes are not picked up.
|
|
495
|
-
- Setup FAQ 30: Use `fragment cache:clear` if config changes are not picked up.
|
|
496
|
-
- Setup FAQ 31: Use `fragment cache:clear` if config changes are not picked up.
|
|
497
|
-
- Setup FAQ 32: Use `fragment cache:clear` if config changes are not picked up.
|
|
498
|
-
- Setup FAQ 33: Use `fragment cache:clear` if config changes are not picked up.
|
|
499
|
-
- Setup FAQ 34: Use `fragment cache:clear` if config changes are not picked up.
|
|
500
|
-
- Setup FAQ 35: Use `fragment cache:clear` if config changes are not picked up.
|
|
501
|
-
- Setup FAQ 36: Use `fragment cache:clear` if config changes are not picked up.
|
|
502
|
-
- Setup FAQ 37: Use `fragment cache:clear` if config changes are not picked up.
|
|
503
|
-
- Setup FAQ 38: Use `fragment cache:clear` if config changes are not picked up.
|
|
504
|
-
- Setup FAQ 39: Use `fragment cache:clear` if config changes are not picked up.
|
|
505
|
-
- Setup FAQ 40: Use `fragment cache:clear` if config changes are not picked up.
|
|
506
|
-
- Setup FAQ 41: Use `fragment cache:clear` if config changes are not picked up.
|
|
507
|
-
- Setup FAQ 42: Use `fragment cache:clear` if config changes are not picked up.
|
|
508
|
-
- Setup FAQ 43: Use `fragment cache:clear` if config changes are not picked up.
|
|
509
|
-
- Setup FAQ 44: Use `fragment cache:clear` if config changes are not picked up.
|
|
510
|
-
- Setup FAQ 45: Use `fragment cache:clear` if config changes are not picked up.
|
|
511
|
-
- Setup FAQ 46: Use `fragment cache:clear` if config changes are not picked up.
|
|
512
|
-
- Setup FAQ 47: Use `fragment cache:clear` if config changes are not picked up.
|
|
513
|
-
- Setup FAQ 48: Use `fragment cache:clear` if config changes are not picked up.
|
|
514
|
-
- Setup FAQ 49: Use `fragment cache:clear` if config changes are not picked up.
|
|
515
|
-
- Setup FAQ 50: Use `fragment cache:clear` if config changes are not picked up.
|
|
516
|
-
- Setup FAQ 51: Use `fragment cache:clear` if config changes are not picked up.
|
|
517
|
-
- Setup FAQ 52: Use `fragment cache:clear` if config changes are not picked up.
|
|
518
|
-
- Setup FAQ 53: Use `fragment cache:clear` if config changes are not picked up.
|
|
519
|
-
- Setup FAQ 54: Use `fragment cache:clear` if config changes are not picked up.
|
|
520
|
-
- Setup FAQ 55: Use `fragment cache:clear` if config changes are not picked up.
|
|
521
|
-
- Setup FAQ 56: Use `fragment cache:clear` if config changes are not picked up.
|
|
522
|
-
- Setup FAQ 57: Use `fragment cache:clear` if config changes are not picked up.
|
|
523
|
-
- Setup FAQ 58: Use `fragment cache:clear` if config changes are not picked up.
|
|
524
|
-
- Setup FAQ 59: Use `fragment cache:clear` if config changes are not picked up.
|
|
525
|
-
- Setup FAQ 60: Use `fragment cache:clear` if config changes are not picked up.
|
|
386
|
+
- Why are config updates not applied?
|
|
387
|
+
Run `fragment cache:clear` if `fragment.cache.json` exists and restart the app.
|
|
388
|
+
- Why are decorators not being discovered?
|
|
389
|
+
Ensure `experimentalDecorators` and `emitDecoratorMetadata` are enabled in `tsconfig.json`.
|
|
390
|
+
- Why is `frg` not found after global install?
|
|
391
|
+
Reinstall globally with `npm i -g fragment-ts` and check your npm global bin path.
|
|
392
|
+
- Why are routes missing at runtime?
|
|
393
|
+
Verify component suffixes (`.controller.ts`, `.service.ts`, etc.) and `autoScan` behavior.
|
|
394
|
+
- Why are docs routes returning 404?
|
|
395
|
+
Check `docs.enabled` and `docs.path` in `fragment.json`.
|
|
396
|
+
- Why is CORS too open by default?
|
|
397
|
+
Disable default CORS with `defaultMiddleware: { cors: false }` and register your own policy.
|
|
398
|
+
- Why are jobs not running?
|
|
399
|
+
Confirm `jobs.enabled` is true and your job class is decorated with `@Job()`.
|
|
400
|
+
- Why is mail template rendering failing?
|
|
401
|
+
Verify `mail.templatesDir` and template file paths used by `@MailTemplate`.
|
|
526
402
|
|
|
527
403
|
## Full Setup Checklist
|
|
528
404
|
|
|
@@ -593,6 +469,43 @@ MAIL_FROM=noreply@example.com
|
|
|
593
469
|
JOBS_TZ=UTC
|
|
594
470
|
```
|
|
595
471
|
|
|
472
|
+
## CORS and Express Middleware Setup
|
|
473
|
+
|
|
474
|
+
Fragment supports direct Express customization during bootstrap.
|
|
475
|
+
|
|
476
|
+
Use one of these patterns:
|
|
477
|
+
- Keep defaults but disable only CORS, then register your own CORS policy.
|
|
478
|
+
- Disable all default middleware and define the full Express chain manually.
|
|
479
|
+
|
|
480
|
+
```ts
|
|
481
|
+
import cors from "cors";
|
|
482
|
+
import express from "express";
|
|
483
|
+
import { FragmentApplication, FragmentWebApplication } from "fragment-ts";
|
|
484
|
+
|
|
485
|
+
@FragmentApplication({ port: 3000 })
|
|
486
|
+
class App {}
|
|
487
|
+
|
|
488
|
+
const web = new FragmentWebApplication({
|
|
489
|
+
defaultMiddleware: { cors: false },
|
|
490
|
+
});
|
|
491
|
+
|
|
492
|
+
web.configureExpress((app) => {
|
|
493
|
+
app.use(cors({
|
|
494
|
+
origin: ["https://app.example.com"],
|
|
495
|
+
credentials: true,
|
|
496
|
+
}));
|
|
497
|
+
});
|
|
498
|
+
|
|
499
|
+
await web.bootstrap(App);
|
|
500
|
+
|
|
501
|
+
const manual = new FragmentWebApplication({ useDefaultMiddleware: false });
|
|
502
|
+
manual.configureExpress((app) => {
|
|
503
|
+
app.use(cors({ origin: true }));
|
|
504
|
+
app.use(express.json());
|
|
505
|
+
app.use(express.urlencoded({ extended: true }));
|
|
506
|
+
});
|
|
507
|
+
```
|
|
508
|
+
|
|
596
509
|
## Linting and Formatting
|
|
597
510
|
|
|
598
511
|
When linting is enabled, the init scaffold creates ESLint and Prettier configs.
|
package/USAGE.md
CHANGED
|
@@ -19,6 +19,45 @@ async function bootstrap() {
|
|
|
19
19
|
bootstrap();
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
+
## Express Access and CORS
|
|
23
|
+
|
|
24
|
+
Use direct Express setup when you want full control over middleware order and options.
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import cors from "cors";
|
|
28
|
+
import express from "express";
|
|
29
|
+
import { FragmentApplication, FragmentWebApplication } from "fragment-ts";
|
|
30
|
+
|
|
31
|
+
@FragmentApplication({ port: 3000, autoScan: true })
|
|
32
|
+
class App {}
|
|
33
|
+
|
|
34
|
+
const web = new FragmentWebApplication({
|
|
35
|
+
defaultMiddleware: {
|
|
36
|
+
cors: false,
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
web.configureExpress((app) => {
|
|
41
|
+
app.use(
|
|
42
|
+
cors({
|
|
43
|
+
origin: ["https://app.example.com"],
|
|
44
|
+
credentials: true,
|
|
45
|
+
methods: ["GET", "POST", "PUT", "PATCH", "DELETE"],
|
|
46
|
+
}),
|
|
47
|
+
);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
await web.bootstrap(App);
|
|
51
|
+
|
|
52
|
+
// Full manual mode
|
|
53
|
+
const manual = new FragmentWebApplication({ useDefaultMiddleware: false });
|
|
54
|
+
manual.configureExpress((app) => {
|
|
55
|
+
app.use(cors({ origin: true }));
|
|
56
|
+
app.use(express.json());
|
|
57
|
+
app.use(express.urlencoded({ extended: true }));
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
22
61
|
## Controllers and Services
|
|
23
62
|
|
|
24
63
|
```ts
|
|
@@ -377,126 +416,14 @@ class MeController {
|
|
|
377
416
|
|
|
378
417
|
## Extra Usage Notes
|
|
379
418
|
|
|
380
|
-
-
|
|
381
|
-
-
|
|
382
|
-
-
|
|
383
|
-
-
|
|
384
|
-
-
|
|
385
|
-
-
|
|
386
|
-
-
|
|
387
|
-
-
|
|
388
|
-
- Note 9: Keep view models thin and stores focused.
|
|
389
|
-
- Note 10: Keep view models thin and stores focused.
|
|
390
|
-
- Note 11: Keep view models thin and stores focused.
|
|
391
|
-
- Note 12: Keep view models thin and stores focused.
|
|
392
|
-
- Note 13: Keep view models thin and stores focused.
|
|
393
|
-
- Note 14: Keep view models thin and stores focused.
|
|
394
|
-
- Note 15: Keep view models thin and stores focused.
|
|
395
|
-
- Note 16: Keep view models thin and stores focused.
|
|
396
|
-
- Note 17: Keep view models thin and stores focused.
|
|
397
|
-
- Note 18: Keep view models thin and stores focused.
|
|
398
|
-
- Note 19: Keep view models thin and stores focused.
|
|
399
|
-
- Note 20: Keep view models thin and stores focused.
|
|
400
|
-
- Note 21: Keep view models thin and stores focused.
|
|
401
|
-
- Note 22: Keep view models thin and stores focused.
|
|
402
|
-
- Note 23: Keep view models thin and stores focused.
|
|
403
|
-
- Note 24: Keep view models thin and stores focused.
|
|
404
|
-
- Note 25: Keep view models thin and stores focused.
|
|
405
|
-
- Note 26: Keep view models thin and stores focused.
|
|
406
|
-
- Note 27: Keep view models thin and stores focused.
|
|
407
|
-
- Note 28: Keep view models thin and stores focused.
|
|
408
|
-
- Note 29: Keep view models thin and stores focused.
|
|
409
|
-
- Note 30: Keep view models thin and stores focused.
|
|
410
|
-
- Note 31: Keep view models thin and stores focused.
|
|
411
|
-
- Note 32: Keep view models thin and stores focused.
|
|
412
|
-
- Note 33: Keep view models thin and stores focused.
|
|
413
|
-
- Note 34: Keep view models thin and stores focused.
|
|
414
|
-
- Note 35: Keep view models thin and stores focused.
|
|
415
|
-
- Note 36: Keep view models thin and stores focused.
|
|
416
|
-
- Note 37: Keep view models thin and stores focused.
|
|
417
|
-
- Note 38: Keep view models thin and stores focused.
|
|
418
|
-
- Note 39: Keep view models thin and stores focused.
|
|
419
|
-
- Note 40: Keep view models thin and stores focused.
|
|
420
|
-
- Note 41: Keep view models thin and stores focused.
|
|
421
|
-
- Note 42: Keep view models thin and stores focused.
|
|
422
|
-
- Note 43: Keep view models thin and stores focused.
|
|
423
|
-
- Note 44: Keep view models thin and stores focused.
|
|
424
|
-
- Note 45: Keep view models thin and stores focused.
|
|
425
|
-
- Note 46: Keep view models thin and stores focused.
|
|
426
|
-
- Note 47: Keep view models thin and stores focused.
|
|
427
|
-
- Note 48: Keep view models thin and stores focused.
|
|
428
|
-
- Note 49: Keep view models thin and stores focused.
|
|
429
|
-
- Note 50: Keep view models thin and stores focused.
|
|
430
|
-
- Note 51: Keep view models thin and stores focused.
|
|
431
|
-
- Note 52: Keep view models thin and stores focused.
|
|
432
|
-
- Note 53: Keep view models thin and stores focused.
|
|
433
|
-
- Note 54: Keep view models thin and stores focused.
|
|
434
|
-
- Note 55: Keep view models thin and stores focused.
|
|
435
|
-
- Note 56: Keep view models thin and stores focused.
|
|
436
|
-
- Note 57: Keep view models thin and stores focused.
|
|
437
|
-
- Note 58: Keep view models thin and stores focused.
|
|
438
|
-
- Note 59: Keep view models thin and stores focused.
|
|
439
|
-
- Note 60: Keep view models thin and stores focused.
|
|
440
|
-
- Note 61: Keep view models thin and stores focused.
|
|
441
|
-
- Note 62: Keep view models thin and stores focused.
|
|
442
|
-
- Note 63: Keep view models thin and stores focused.
|
|
443
|
-
- Note 64: Keep view models thin and stores focused.
|
|
444
|
-
- Note 65: Keep view models thin and stores focused.
|
|
445
|
-
- Note 66: Keep view models thin and stores focused.
|
|
446
|
-
- Note 67: Keep view models thin and stores focused.
|
|
447
|
-
- Note 68: Keep view models thin and stores focused.
|
|
448
|
-
- Note 69: Keep view models thin and stores focused.
|
|
449
|
-
- Note 70: Keep view models thin and stores focused.
|
|
450
|
-
- Note 71: Keep view models thin and stores focused.
|
|
451
|
-
- Note 72: Keep view models thin and stores focused.
|
|
452
|
-
- Note 73: Keep view models thin and stores focused.
|
|
453
|
-
- Note 74: Keep view models thin and stores focused.
|
|
454
|
-
- Note 75: Keep view models thin and stores focused.
|
|
455
|
-
- Note 76: Keep view models thin and stores focused.
|
|
456
|
-
- Note 77: Keep view models thin and stores focused.
|
|
457
|
-
- Note 78: Keep view models thin and stores focused.
|
|
458
|
-
- Note 79: Keep view models thin and stores focused.
|
|
459
|
-
- Note 80: Keep view models thin and stores focused.
|
|
460
|
-
- Note 81: Use qualifiers when two providers share a name.
|
|
461
|
-
- Note 82: Use qualifiers when two providers share a name.
|
|
462
|
-
- Note 83: Use qualifiers when two providers share a name.
|
|
463
|
-
- Note 84: Use qualifiers when two providers share a name.
|
|
464
|
-
- Note 85: Use qualifiers when two providers share a name.
|
|
465
|
-
- Note 86: Use qualifiers when two providers share a name.
|
|
466
|
-
- Note 87: Use qualifiers when two providers share a name.
|
|
467
|
-
- Note 88: Use qualifiers when two providers share a name.
|
|
468
|
-
- Note 89: Use qualifiers when two providers share a name.
|
|
469
|
-
- Note 90: Use qualifiers when two providers share a name.
|
|
470
|
-
- Note 91: Use qualifiers when two providers share a name.
|
|
471
|
-
- Note 92: Use qualifiers when two providers share a name.
|
|
472
|
-
- Note 93: Use qualifiers when two providers share a name.
|
|
473
|
-
- Note 94: Use qualifiers when two providers share a name.
|
|
474
|
-
- Note 95: Use qualifiers when two providers share a name.
|
|
475
|
-
- Note 96: Use qualifiers when two providers share a name.
|
|
476
|
-
- Note 97: Use qualifiers when two providers share a name.
|
|
477
|
-
- Note 98: Use qualifiers when two providers share a name.
|
|
478
|
-
- Note 99: Use qualifiers when two providers share a name.
|
|
479
|
-
- Note 100: Use qualifiers when two providers share a name.
|
|
480
|
-
- Note 101: Use qualifiers when two providers share a name.
|
|
481
|
-
- Note 102: Use qualifiers when two providers share a name.
|
|
482
|
-
- Note 103: Use qualifiers when two providers share a name.
|
|
483
|
-
- Note 104: Use qualifiers when two providers share a name.
|
|
484
|
-
- Note 105: Use qualifiers when two providers share a name.
|
|
485
|
-
- Note 106: Use qualifiers when two providers share a name.
|
|
486
|
-
- Note 107: Use qualifiers when two providers share a name.
|
|
487
|
-
- Note 108: Use qualifiers when two providers share a name.
|
|
488
|
-
- Note 109: Use qualifiers when two providers share a name.
|
|
489
|
-
- Note 110: Use qualifiers when two providers share a name.
|
|
490
|
-
- Note 111: Use qualifiers when two providers share a name.
|
|
491
|
-
- Note 112: Use qualifiers when two providers share a name.
|
|
492
|
-
- Note 113: Use qualifiers when two providers share a name.
|
|
493
|
-
- Note 114: Use qualifiers when two providers share a name.
|
|
494
|
-
- Note 115: Use qualifiers when two providers share a name.
|
|
495
|
-
- Note 116: Use qualifiers when two providers share a name.
|
|
496
|
-
- Note 117: Use qualifiers when two providers share a name.
|
|
497
|
-
- Note 118: Use qualifiers when two providers share a name.
|
|
498
|
-
- Note 119: Use qualifiers when two providers share a name.
|
|
499
|
-
- Note 120: Use qualifiers when two providers share a name.
|
|
419
|
+
- Keep stores small and focused; prefer one store per feature boundary.
|
|
420
|
+
- Use qualifiers when multiple plugins or providers can satisfy the same token.
|
|
421
|
+
- Use `FragmentError` subclasses for domain failures instead of generic `Error`.
|
|
422
|
+
- Keep middleware registration explicit when security behavior matters.
|
|
423
|
+
- Prefer `configureExpress()` for CORS and edge middleware setup.
|
|
424
|
+
- Keep `@Effect` methods idempotent and side-effect focused.
|
|
425
|
+
- Use `CommandRunner.run()` for automation or job-triggered CLI operations.
|
|
426
|
+
- Use docs decorators on controllers and DTOs to keep generated docs complete.
|
|
500
427
|
|
|
501
428
|
## Config Utilities
|
|
502
429
|
|
package/dist/index.d.ts
CHANGED
|
@@ -41,7 +41,7 @@ export * from "./platform/testing/runner";
|
|
|
41
41
|
export * from "./shared/errors";
|
|
42
42
|
export { FragmentLogger, type LogLevel as FragmentLogLevel, type LoggerSettings, } from "./shared/logger";
|
|
43
43
|
export { RequestContextStorage } from "./core/context/request-context";
|
|
44
|
-
export type { Application, CookieOptions, Errback, ErrorRequestHandler, Express, Handler, IRoute, IRouter, IRouterHandler, IRouterMatcher, Locals, MediaType, NextFunction, Request, RequestHandler, RequestParamHandler, Response, Router, Send, } from "express";
|
|
44
|
+
export type { Application, CookieOptions, Errback, ErrorRequestHandler, Express, Handler, IRoute, IRouter, IRouterHandler, IRouterMatcher, Locals, MediaType, NextFunction, Request, RequestHandler, RequestParamHandler, Response, Router, Send, urlencoded, json, } from "express";
|
|
45
45
|
export * from "typeorm";
|
|
46
46
|
export * from "dotenv";
|
|
47
47
|
export { ApiOperation, ApiProperty, ApiResponse, ApiTag, AutoConfiguration, Autowired, Body, Controller, Cron, Delete, FragmentApplication, FragmentRepository, Get, Header, Inject, Injectable, Job, Mail, Mailer, MailTemplate, NotificationChannel, OnPluginInit, OnPluginShutdown, OnShutdown, OnStartup, Param, Patch, Plugin, Post, Put, Qualifier, Query, Req, Res, Service, Value, } from "./core";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,kBAAkB,CAAC;AAG1B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iCAAiC,CAAC;AAChD,cAAc,yCAAyC,CAAC;AACxD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,0CAA0C,CAAC;AACzD,cAAc,wCAAwC,CAAC;AACvD,cAAc,8CAA8C,CAAC;AAC7D,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC;AAClD,cAAc,wCAAwC,CAAC;AACvD,cAAc,wCAAwC,CAAC;AACvD,cAAc,yCAAyC,CAAC;AACxD,cAAc,iCAAiC,CAAC;AAChD,cAAc,uCAAuC,CAAC;AACtD,cAAc,kCAAkC,CAAC;AACjD,cAAc,wCAAwC,CAAC;AACvD,cAAc,0CAA0C,CAAC;AACzD,cAAc,8CAA8C,CAAC;AAC7D,cAAc,oCAAoC,CAAC;AACnD,cAAc,wCAAwC,CAAC;AACvD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,qCAAqC,CAAC;AACpD,cAAc,kCAAkC,CAAC;AAGjD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAG1C,cAAc,uCAAuC,CAAC;AAGtD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC;AAChD,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAG1C,cAAc,kCAAkC,CAAC;AACjD,cAAc,+CAA+C,CAAC;AAC9D,cAAc,6CAA6C,CAAC;AAC5D,cAAc,+CAA+C,CAAC;AAC9D,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,OAAO,EACL,cAAc,EACd,KAAK,QAAQ,IAAI,gBAAgB,EACjC,KAAK,cAAc,GACpB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAGvE,YAAY,EACV,WAAW,EACX,aAAa,EACb,OAAO,EACP,mBAAmB,EACnB,OAAO,EACP,OAAO,EACP,MAAM,EACN,OAAO,EACP,cAAc,EACd,cAAc,EACd,MAAM,EACN,SAAS,EACT,YAAY,EACZ,OAAO,EACP,cAAc,EACd,mBAAmB,EACnB,QAAQ,EACR,MAAM,EACN,IAAI,GACL,MAAM,SAAS,CAAC;AAGjB,cAAc,SAAS,CAAC;AAGxB,cAAc,QAAQ,CAAC;AAGvB,OAAO,EACL,YAAY,EACZ,WAAW,EACX,WAAW,EACX,MAAM,EACN,iBAAiB,EACjB,SAAS,EACT,IAAI,EACJ,UAAU,EACV,IAAI,EACJ,MAAM,EACN,mBAAmB,EACnB,kBAAkB,EAClB,GAAG,EACH,MAAM,EACN,MAAM,EACN,UAAU,EACV,GAAG,EACH,IAAI,EACJ,MAAM,EACN,YAAY,EACZ,mBAAmB,EACnB,YAAY,EACZ,gBAAgB,EAChB,UAAU,EACV,SAAS,EACT,KAAK,EACL,KAAK,EACL,MAAM,EACN,IAAI,EACJ,GAAG,EACH,SAAS,EACT,KAAK,EACL,GAAG,EACH,GAAG,EACH,OAAO,EACP,KAAK,GACN,MAAM,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,kBAAkB,CAAC;AAG1B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iCAAiC,CAAC;AAChD,cAAc,yCAAyC,CAAC;AACxD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,0CAA0C,CAAC;AACzD,cAAc,wCAAwC,CAAC;AACvD,cAAc,8CAA8C,CAAC;AAC7D,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC;AAClD,cAAc,wCAAwC,CAAC;AACvD,cAAc,wCAAwC,CAAC;AACvD,cAAc,yCAAyC,CAAC;AACxD,cAAc,iCAAiC,CAAC;AAChD,cAAc,uCAAuC,CAAC;AACtD,cAAc,kCAAkC,CAAC;AACjD,cAAc,wCAAwC,CAAC;AACvD,cAAc,0CAA0C,CAAC;AACzD,cAAc,8CAA8C,CAAC;AAC7D,cAAc,oCAAoC,CAAC;AACnD,cAAc,wCAAwC,CAAC;AACvD,cAAc,6CAA6C,CAAC;AAC5D,cAAc,qCAAqC,CAAC;AACpD,cAAc,kCAAkC,CAAC;AAGjD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAG1C,cAAc,uCAAuC,CAAC;AAGtD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC;AAChD,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAG1C,cAAc,kCAAkC,CAAC;AACjD,cAAc,+CAA+C,CAAC;AAC9D,cAAc,6CAA6C,CAAC;AAC5D,cAAc,+CAA+C,CAAC;AAC9D,cAAc,2BAA2B,CAAC;AAC1C,cAAc,iBAAiB,CAAC;AAChC,OAAO,EACL,cAAc,EACd,KAAK,QAAQ,IAAI,gBAAgB,EACjC,KAAK,cAAc,GACpB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAGvE,YAAY,EACV,WAAW,EACX,aAAa,EACb,OAAO,EACP,mBAAmB,EACnB,OAAO,EACP,OAAO,EACP,MAAM,EACN,OAAO,EACP,cAAc,EACd,cAAc,EACd,MAAM,EACN,SAAS,EACT,YAAY,EACZ,OAAO,EACP,cAAc,EACd,mBAAmB,EACnB,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,UAAU,EACV,IAAI,GACL,MAAM,SAAS,CAAC;AAGjB,cAAc,SAAS,CAAC;AAGxB,cAAc,QAAQ,CAAC;AAGvB,OAAO,EACL,YAAY,EACZ,WAAW,EACX,WAAW,EACX,MAAM,EACN,iBAAiB,EACjB,SAAS,EACT,IAAI,EACJ,UAAU,EACV,IAAI,EACJ,MAAM,EACN,mBAAmB,EACnB,kBAAkB,EAClB,GAAG,EACH,MAAM,EACN,MAAM,EACN,UAAU,EACV,GAAG,EACH,IAAI,EACJ,MAAM,EACN,YAAY,EACZ,mBAAmB,EACnB,YAAY,EACZ,gBAAgB,EAChB,UAAU,EACV,SAAS,EACT,KAAK,EACL,KAAK,EACL,MAAM,EACN,IAAI,EACJ,GAAG,EACH,SAAS,EACT,KAAK,EACL,GAAG,EACH,GAAG,EACH,OAAO,EACP,KAAK,GACN,MAAM,QAAQ,CAAC"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,kDAAkD;;;;;;;;;;;;;;;;;AAElD,4BAA0B;AAE1B,eAAe;AACf,gEAA8C;AAC9C,kEAAgD;AAChD,0EAAwD;AACxD,iFAA+D;AAC/D,2EAAyD;AACzD,yEAAuD;AACvD,+EAA6D;AAC7D,oEAAkD;AAClD,oEAAkD;AAClD,yEAAuD;AACvD,yEAAuD;AACvD,0EAAwD;AACxD,kEAAgD;AAChD,wEAAsD;AACtD,mEAAiD;AACjD,yEAAuD;AACvD,2EAAyD;AACzD,+EAA6D;AAC7D,qEAAmD;AACnD,yEAAuD;AACvD,8EAA4D;AAC5D,sEAAoD;AACpD,mEAAiD;AAEjD,cAAc;AACd,6DAA2C;AAC3C,4DAA0C;AAE1C,kBAAkB;AAClB,wEAAsD;AAEtD,iBAAiB;AACjB,8DAA4C;AAC5C,kEAAgD;AAChD,sDAAoC;AACpC,sDAAoC;AACpC,sDAAoC;AACpC,+DAA6C;AAC7C,2DAAyC;AACzC,4DAA0C;AAE1C,iBAAiB;AACjB,mEAAiD;AACjD,gFAA8D;AAC9D,8EAA4D;AAC5D,gFAA8D;AAC9D,4DAA0C;AAC1C,kDAAgC;AAChC,0CAIyB;AAHvB,wGAAA,cAAc,OAAA;AAKhB,kBAAkB;AAClB,kEAAuE;AAA9D,wHAAA,qBAAqB,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,kDAAkD;;;;;;;;;;;;;;;;;AAElD,4BAA0B;AAE1B,eAAe;AACf,gEAA8C;AAC9C,kEAAgD;AAChD,0EAAwD;AACxD,iFAA+D;AAC/D,2EAAyD;AACzD,yEAAuD;AACvD,+EAA6D;AAC7D,oEAAkD;AAClD,oEAAkD;AAClD,yEAAuD;AACvD,yEAAuD;AACvD,0EAAwD;AACxD,kEAAgD;AAChD,wEAAsD;AACtD,mEAAiD;AACjD,yEAAuD;AACvD,2EAAyD;AACzD,+EAA6D;AAC7D,qEAAmD;AACnD,yEAAuD;AACvD,8EAA4D;AAC5D,sEAAoD;AACpD,mEAAiD;AAEjD,cAAc;AACd,6DAA2C;AAC3C,4DAA0C;AAE1C,kBAAkB;AAClB,wEAAsD;AAEtD,iBAAiB;AACjB,8DAA4C;AAC5C,kEAAgD;AAChD,sDAAoC;AACpC,sDAAoC;AACpC,sDAAoC;AACpC,+DAA6C;AAC7C,2DAAyC;AACzC,4DAA0C;AAE1C,iBAAiB;AACjB,mEAAiD;AACjD,gFAA8D;AAC9D,8EAA4D;AAC5D,gFAA8D;AAC9D,4DAA0C;AAC1C,kDAAgC;AAChC,0CAIyB;AAHvB,wGAAA,cAAc,OAAA;AAKhB,kBAAkB;AAClB,kEAAuE;AAA9D,wHAAA,qBAAqB,OAAA;AA2B9B,qBAAqB;AACrB,0CAAwB;AAExB,SAAS;AACT,yCAAuB;AAEvB,wBAAwB;AACxB,+BAqCgB;AApCd,oGAAA,YAAY,OAAA;AACZ,mGAAA,WAAW,OAAA;AACX,mGAAA,WAAW,OAAA;AACX,8FAAA,MAAM,OAAA;AACN,yGAAA,iBAAiB,OAAA;AACjB,iGAAA,SAAS,OAAA;AACT,4FAAA,IAAI,OAAA;AACJ,kGAAA,UAAU,OAAA;AACV,4FAAA,IAAI,OAAA;AACJ,8FAAA,MAAM,OAAA;AACN,2GAAA,mBAAmB,OAAA;AACnB,0GAAA,kBAAkB,OAAA;AAClB,2FAAA,GAAG,OAAA;AACH,8FAAA,MAAM,OAAA;AACN,8FAAA,MAAM,OAAA;AACN,kGAAA,UAAU,OAAA;AACV,2FAAA,GAAG,OAAA;AACH,4FAAA,IAAI,OAAA;AACJ,8FAAA,MAAM,OAAA;AACN,oGAAA,YAAY,OAAA;AACZ,2GAAA,mBAAmB,OAAA;AACnB,oGAAA,YAAY,OAAA;AACZ,wGAAA,gBAAgB,OAAA;AAChB,kGAAA,UAAU,OAAA;AACV,iGAAA,SAAS,OAAA;AACT,6FAAA,KAAK,OAAA;AACL,6FAAA,KAAK,OAAA;AACL,8FAAA,MAAM,OAAA;AACN,4FAAA,IAAI,OAAA;AACJ,2FAAA,GAAG,OAAA;AACH,iGAAA,SAAS,OAAA;AACT,6FAAA,KAAK,OAAA;AACL,2FAAA,GAAG,OAAA;AACH,2FAAA,GAAG,OAAA;AACH,+FAAA,OAAO,OAAA;AACP,6FAAA,KAAK,OAAA"}
|
|
@@ -122,7 +122,7 @@ async function createConfigFiles(projectPath, projectName, config) {
|
|
|
122
122
|
devDependencies.prettier = "^3.2.5";
|
|
123
123
|
}
|
|
124
124
|
const dependencies = {
|
|
125
|
-
"fragment-ts": "^
|
|
125
|
+
"fragment-ts": "^2.0.1",
|
|
126
126
|
"reflect-metadata": "^0.1.13",
|
|
127
127
|
sqlite3: "^5.1.7",
|
|
128
128
|
};
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import { Express } from "express";
|
|
2
|
+
import { BasicMiddlewareOptions, MiddlewareSetup } from "./middleware/MiddlewareSetup";
|
|
3
|
+
export interface FragmentWebApplicationOptions {
|
|
4
|
+
useDefaultMiddleware?: boolean;
|
|
5
|
+
defaultMiddleware?: BasicMiddlewareOptions;
|
|
6
|
+
}
|
|
2
7
|
export declare class FragmentWebApplication {
|
|
3
8
|
private app;
|
|
4
9
|
private bootstrapper;
|
|
5
10
|
private middlewareSetup;
|
|
6
|
-
constructor();
|
|
11
|
+
constructor(options?: FragmentWebApplicationOptions);
|
|
7
12
|
bootstrap(appClass: any): Promise<void>;
|
|
13
|
+
configureExpress(setup: (app: Express) => void): this;
|
|
14
|
+
setupMiddleware(setup: (middleware: MiddlewareSetup) => void): this;
|
|
8
15
|
getExpressApp(): Express;
|
|
9
16
|
}
|
|
10
17
|
//# sourceMappingURL=application.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application.d.ts","sourceRoot":"","sources":["../../../src/platform/web/application.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"application.d.ts","sourceRoot":"","sources":["../../../src/platform/web/application.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAE3C,OAAO,EACL,sBAAsB,EACtB,eAAe,EAChB,MAAM,8BAA8B,CAAC;AAEtC,MAAM,WAAW,6BAA6B;IAC5C,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,iBAAiB,CAAC,EAAE,sBAAsB,CAAC;CAC5C;AAED,qBAAa,sBAAsB;IACjC,OAAO,CAAC,GAAG,CAAU;IACrB,OAAO,CAAC,YAAY,CAA0B;IAC9C,OAAO,CAAC,eAAe,CAAkB;gBAE7B,OAAO,GAAE,6BAAkC;IAWjD,SAAS,CAAC,QAAQ,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAI7C,gBAAgB,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,GAAG,IAAI;IAKrD,eAAe,CAAC,KAAK,EAAE,CAAC,UAAU,EAAE,eAAe,KAAK,IAAI,GAAG,IAAI;IAKnE,aAAa,IAAI,OAAO;CAGzB"}
|
|
@@ -8,16 +8,26 @@ const express_1 = __importDefault(require("express"));
|
|
|
8
8
|
const ApplicationBootstrapper_1 = require("./bootstrap/ApplicationBootstrapper");
|
|
9
9
|
const MiddlewareSetup_1 = require("./middleware/MiddlewareSetup");
|
|
10
10
|
class FragmentWebApplication {
|
|
11
|
-
constructor() {
|
|
11
|
+
constructor(options = {}) {
|
|
12
12
|
this.app = (0, express_1.default)();
|
|
13
13
|
this.bootstrapper = new ApplicationBootstrapper_1.ApplicationBootstrapper(this.app);
|
|
14
14
|
this.middlewareSetup = new MiddlewareSetup_1.MiddlewareSetup(this.app);
|
|
15
15
|
// Setup basic middleware
|
|
16
|
-
|
|
16
|
+
if (options.useDefaultMiddleware !== false) {
|
|
17
|
+
this.middlewareSetup.setupBasicMiddleware(options.defaultMiddleware);
|
|
18
|
+
}
|
|
17
19
|
}
|
|
18
20
|
async bootstrap(appClass) {
|
|
19
21
|
await this.bootstrapper.bootstrap(appClass);
|
|
20
22
|
}
|
|
23
|
+
configureExpress(setup) {
|
|
24
|
+
setup(this.app);
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
setupMiddleware(setup) {
|
|
28
|
+
setup(this.middlewareSetup);
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
21
31
|
getExpressApp() {
|
|
22
32
|
return this.app;
|
|
23
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application.js","sourceRoot":"","sources":["../../../src/platform/web/application.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA2C;AAC3C,iFAA8E;AAC9E,
|
|
1
|
+
{"version":3,"file":"application.js","sourceRoot":"","sources":["../../../src/platform/web/application.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA2C;AAC3C,iFAA8E;AAC9E,kEAGsC;AAOtC,MAAa,sBAAsB;IAKjC,YAAY,UAAyC,EAAE;QACrD,IAAI,CAAC,GAAG,GAAG,IAAA,iBAAO,GAAE,CAAC;QACrB,IAAI,CAAC,YAAY,GAAG,IAAI,iDAAuB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC1D,IAAI,CAAC,eAAe,GAAG,IAAI,iCAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAErD,yBAAyB;QACzB,IAAI,OAAO,CAAC,oBAAoB,KAAK,KAAK,EAAE,CAAC;YAC3C,IAAI,CAAC,eAAe,CAAC,oBAAoB,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;QACvE,CAAC;IACH,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,QAAa;QAC3B,MAAM,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IAC9C,CAAC;IAED,gBAAgB,CAAC,KAA6B;QAC5C,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAChB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,eAAe,CAAC,KAA4C;QAC1D,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,aAAa;QACX,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;CACF;AAjCD,wDAiCC"}
|
|
@@ -1,8 +1,20 @@
|
|
|
1
|
-
import { Express } from "express";
|
|
1
|
+
import express, { Express } from "express";
|
|
2
|
+
import helmet from "helmet";
|
|
3
|
+
import cors from "cors";
|
|
4
|
+
import compression from "compression";
|
|
5
|
+
export interface BasicMiddlewareOptions {
|
|
6
|
+
helmet?: boolean | Parameters<typeof helmet>[0];
|
|
7
|
+
cors?: boolean | Parameters<typeof cors>[0];
|
|
8
|
+
compression?: boolean | Parameters<typeof compression>[0];
|
|
9
|
+
json?: boolean | Parameters<typeof express.json>[0];
|
|
10
|
+
urlencoded?: boolean | (Parameters<typeof express.urlencoded>[0] & {
|
|
11
|
+
extended?: boolean;
|
|
12
|
+
});
|
|
13
|
+
}
|
|
2
14
|
export declare class MiddlewareSetup {
|
|
3
15
|
private app;
|
|
4
16
|
constructor(app: Express);
|
|
5
|
-
setupBasicMiddleware(): void;
|
|
17
|
+
setupBasicMiddleware(options?: BasicMiddlewareOptions): void;
|
|
6
18
|
setupSecurityMiddleware(): void;
|
|
7
19
|
setupLoggingMiddleware(): void;
|
|
8
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MiddlewareSetup.d.ts","sourceRoot":"","sources":["../../../../src/platform/web/middleware/MiddlewareSetup.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"MiddlewareSetup.d.ts","sourceRoot":"","sources":["../../../../src/platform/web/middleware/MiddlewareSetup.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,WAAW,MAAM,aAAa,CAAC;AAEtC,MAAM,WAAW,sBAAsB;IACrC,MAAM,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAChD,IAAI,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5C,WAAW,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1D,IAAI,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IACpD,UAAU,CAAC,EAAE,OAAO,GAAG,CAAC,UAAU,CAAC,OAAO,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG;QACjE,QAAQ,CAAC,EAAE,OAAO,CAAC;KACpB,CAAC,CAAC;CACJ;AAED,qBAAa,eAAe;IACd,OAAO,CAAC,GAAG;gBAAH,GAAG,EAAE,OAAO;IAEhC,oBAAoB,CAAC,OAAO,GAAE,sBAA2B,GAAG,IAAI;IA4ChE,uBAAuB,IAAI,IAAI;IAI/B,sBAAsB,IAAI,IAAI;CAG/B"}
|
|
@@ -12,12 +12,28 @@ class MiddlewareSetup {
|
|
|
12
12
|
constructor(app) {
|
|
13
13
|
this.app = app;
|
|
14
14
|
}
|
|
15
|
-
setupBasicMiddleware() {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
setupBasicMiddleware(options = {}) {
|
|
16
|
+
const { helmet: helmetOptions = true, cors: corsOptions = true, compression: compressionOptions = true, json: jsonOptions = true, urlencoded: urlencodedOptions = { extended: true }, } = options;
|
|
17
|
+
if (helmetOptions !== false) {
|
|
18
|
+
this.app.use((0, helmet_1.default)(helmetOptions === true ? undefined : helmetOptions));
|
|
19
|
+
}
|
|
20
|
+
if (corsOptions !== false) {
|
|
21
|
+
this.app.use((0, cors_1.default)(corsOptions === true ? undefined : corsOptions));
|
|
22
|
+
}
|
|
23
|
+
if (compressionOptions !== false) {
|
|
24
|
+
this.app.use((0, compression_1.default)(compressionOptions === true ? undefined : compressionOptions));
|
|
25
|
+
}
|
|
26
|
+
if (jsonOptions !== false) {
|
|
27
|
+
this.app.use(express_1.default.json(jsonOptions === true ? undefined : jsonOptions));
|
|
28
|
+
}
|
|
29
|
+
if (urlencodedOptions !== false) {
|
|
30
|
+
this.app.use(express_1.default.urlencoded(urlencodedOptions === true
|
|
31
|
+
? { extended: true }
|
|
32
|
+
: {
|
|
33
|
+
extended: true,
|
|
34
|
+
...urlencodedOptions,
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
21
37
|
}
|
|
22
38
|
// You can add more middleware setup methods here
|
|
23
39
|
setupSecurityMiddleware() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MiddlewareSetup.js","sourceRoot":"","sources":["../../../../src/platform/web/middleware/MiddlewareSetup.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA2C;AAC3C,oDAA4B;AAC5B,gDAAwB;AACxB,8DAAsC;
|
|
1
|
+
{"version":3,"file":"MiddlewareSetup.js","sourceRoot":"","sources":["../../../../src/platform/web/middleware/MiddlewareSetup.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA2C;AAC3C,oDAA4B;AAC5B,gDAAwB;AACxB,8DAAsC;AAYtC,MAAa,eAAe;IAC1B,YAAoB,GAAY;QAAZ,QAAG,GAAH,GAAG,CAAS;IAAG,CAAC;IAEpC,oBAAoB,CAAC,UAAkC,EAAE;QACvD,MAAM,EACJ,MAAM,EAAE,aAAa,GAAG,IAAI,EAC5B,IAAI,EAAE,WAAW,GAAG,IAAI,EACxB,WAAW,EAAE,kBAAkB,GAAG,IAAI,EACtC,IAAI,EAAE,WAAW,GAAG,IAAI,EACxB,UAAU,EAAE,iBAAiB,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,GACnD,GAAG,OAAO,CAAC;QAEZ,IAAI,aAAa,KAAK,KAAK,EAAE,CAAC;YAC5B,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAA,gBAAM,EAAC,aAAa,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC;QAC3E,CAAC;QAED,IAAI,WAAW,KAAK,KAAK,EAAE,CAAC;YAC1B,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAA,cAAI,EAAC,WAAW,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;QACrE,CAAC;QAED,IAAI,kBAAkB,KAAK,KAAK,EAAE,CAAC;YACjC,IAAI,CAAC,GAAG,CAAC,GAAG,CACV,IAAA,qBAAW,EACT,kBAAkB,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,kBAAkB,CAC7D,CACF,CAAC;QACJ,CAAC;QAED,IAAI,WAAW,KAAK,KAAK,EAAE,CAAC;YAC1B,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,iBAAO,CAAC,IAAI,CAAC,WAAW,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;QAC7E,CAAC;QAED,IAAI,iBAAiB,KAAK,KAAK,EAAE,CAAC;YAChC,IAAI,CAAC,GAAG,CAAC,GAAG,CACV,iBAAO,CAAC,UAAU,CAChB,iBAAiB,KAAK,IAAI;gBACxB,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE;gBACpB,CAAC,CAAC;oBACE,QAAQ,EAAE,IAAI;oBACd,GAAG,iBAAiB;iBACrB,CACN,CACF,CAAC;QACJ,CAAC;IACH,CAAC;IAED,iDAAiD;IACjD,uBAAuB;QACrB,iCAAiC;IACnC,CAAC;IAED,sBAAsB;QACpB,6BAA6B;IAC/B,CAAC;CACF;AAtDD,0CAsDC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fragment-ts",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Spring Boot-style framework for TypeScript with Express and TypeORM",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -82,4 +82,4 @@
|
|
|
82
82
|
"engines": {
|
|
83
83
|
"node": ">=16.0.0"
|
|
84
84
|
}
|
|
85
|
-
}
|
|
85
|
+
}
|