@meghjs/core 0.5.5 → 0.6.0
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 +23 -126
- package/dist/common/container.js +0 -1
- package/dist/common/container.js.map +1 -1
- package/dist/common/exceptions/system-exception.d.ts +0 -10
- package/dist/common/exceptions/system-exception.js +7 -12
- package/dist/common/exceptions/system-exception.js.map +1 -1
- package/dist/common/utils/compiled-validation.js +2 -1
- package/dist/common/utils/compiled-validation.js.map +1 -1
- package/dist/config/environment-variables.js +2 -1
- package/dist/config/environment-variables.js.map +1 -1
- package/dist/core/application.d.ts +3 -8
- package/dist/core/application.js +25 -36
- package/dist/core/application.js.map +1 -1
- package/dist/core/interfaces.d.ts +0 -3
- package/dist/core/router.d.ts +0 -4
- package/dist/core/router.js +6 -20
- package/dist/core/router.js.map +1 -1
- package/dist/events/event-subscriber.js.map +1 -1
- package/dist/events/socket-dispatcher.d.ts +0 -2
- package/dist/events/socket-dispatcher.js +1 -9
- package/dist/events/socket-dispatcher.js.map +1 -1
- package/dist/http/multipart.js.map +1 -1
- package/dist/http/route-methods.js.map +1 -1
- package/dist/http/validator-extend.js +1 -1
- package/dist/http/validator-extend.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/openapi/swagger-schema.d.ts +0 -2
- package/dist/openapi/swagger-schema.js +0 -3
- package/dist/openapi/swagger-schema.js.map +1 -1
- package/dist/realtime/websocket.d.ts +1 -7
- package/dist/realtime/websocket.js +2 -18
- package/dist/realtime/websocket.js.map +1 -1
- package/dist/storage/file-storage.js +6 -4
- package/dist/storage/file-storage.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1015,8 +1015,20 @@ app.useMultipart({
|
|
|
1015
1015
|
});
|
|
1016
1016
|
```
|
|
1017
1017
|
|
|
1018
|
+
`useMultipart()` passes its options to `@fastify/multipart`. Megh sets
|
|
1019
|
+
`attachFieldsToBody: true` (needed by `@UploadFile`) and a **10 MB** per-file
|
|
1020
|
+
limit unless you pass your own `limits`. The smaller of this limit and
|
|
1021
|
+
`FileStorage`'s `maxFileSize` (50 MB) wins, so raise both for bigger files.
|
|
1022
|
+
|
|
1018
1023
|
```typescript
|
|
1019
|
-
import {
|
|
1024
|
+
import {
|
|
1025
|
+
ApiController,
|
|
1026
|
+
Post,
|
|
1027
|
+
FileStorage,
|
|
1028
|
+
UploadFile,
|
|
1029
|
+
MultipartFile,
|
|
1030
|
+
OpenApi,
|
|
1031
|
+
} from "@meghjs/core";
|
|
1020
1032
|
|
|
1021
1033
|
@ApiController("/files")
|
|
1022
1034
|
class FileController {
|
|
@@ -1078,7 +1090,7 @@ import path from "path";
|
|
|
1078
1090
|
|
|
1079
1091
|
// requires @fastify/static
|
|
1080
1092
|
app.useStaticFiles({
|
|
1081
|
-
|
|
1093
|
+
root: path.join(process.cwd(), "public"),
|
|
1082
1094
|
prefix: "/static/",
|
|
1083
1095
|
});
|
|
1084
1096
|
```
|
|
@@ -1216,7 +1228,7 @@ dispatches jobs without Redis.
|
|
|
1216
1228
|
- Set `NODE_ENV=production`. Unset also counts as production, but be explicit.
|
|
1217
1229
|
Production mode hides 5xx details, writes JSON logs, and makes
|
|
1218
1230
|
`app.isDevelopment()` false.
|
|
1219
|
-
- `app.run(port)` defaults to
|
|
1231
|
+
- `app.run(port)` defaults to `PORT`, else 4000, and listens on `HOST` or `0.0.0.0`
|
|
1220
1232
|
(`app.run(port, { host })` to change it). It handles `SIGTERM`/`SIGINT` by
|
|
1221
1233
|
stopping the scheduler, closing registered workers and the cache, and gives
|
|
1222
1234
|
up after `shutdownTimeout`.
|
|
@@ -1267,129 +1279,14 @@ These are regressions or gaps in 0.3.0 that are expected to be fixed in a patch
|
|
|
1267
1279
|
|
|
1268
1280
|
## Roadmap to 1.0.0
|
|
1269
1281
|
|
|
1270
|
-
1.0.0 is the first release with a stable API
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
- [x] Handlers receive the validated DTO; unknown properties are rejected (mass-assignment protection)
|
|
1279
|
-
- [x] File storage confines every read, write and delete to `baseDir`, including sibling-prefix and symlink escapes
|
|
1280
|
-
- [x] Uploads get random names, don't overwrite, and are checked against an extension allowlist and a size limit
|
|
1281
|
-
- [x] Path traversal in `UploadFileFromRequest` closed
|
|
1282
|
-
- [x] `Content-Disposition` header injection closed
|
|
1283
|
-
- [x] Credentials are no longer logged, and production hides 5xx details and requires `NODE_ENV=development` for dev mode
|
|
1284
|
-
- [x] Concurrent requests no longer share `FileStorage` transform settings
|
|
1285
|
-
|
|
1286
|
-
**Correctness**
|
|
1287
|
-
|
|
1288
|
-
- [x] Built-in `Validator` accepts `0` and enforces `min` / `max` / `exact` / `optional`
|
|
1289
|
-
- [x] Missing decorator metadata (tsx, esbuild, SWC) no longer crashes; `@Body({ type })` supplies the type
|
|
1290
|
-
- [x] TypeORM query operators work at runtime
|
|
1291
|
-
- [x] `MeghRepository.transaction()` runs inside the transaction, and `@InjectRepository` works after `useTypeORM()`
|
|
1292
|
-
- [x] Collection fixes: `paginate`, `min`, `findAsync`
|
|
1293
|
-
- [x] One pagination shape across Collection, TypeORM and Knex
|
|
1294
|
-
- [x] Events keyed by class, exactly-once `once` listeners, `delay` honoured when queued, failed jobs kept
|
|
1295
|
-
- [x] Scheduler decorators no longer leak into parent classes
|
|
1296
|
-
- [x] In-memory cache enforces TTL; Redis tag sets expire
|
|
1297
|
-
- [x] JSON logs in production; framework logs go through `LoggerService`
|
|
1298
|
-
- [x] OpenAPI component schemas generated without instantiating classes
|
|
1299
|
-
|
|
1300
|
-
**Features**
|
|
1301
|
-
|
|
1302
|
-
- [x] Producer-only queues (`worker: false`) and workers that no longer start on import
|
|
1303
|
-
- [x] In-memory `memory` and `sync` queue drivers for tests
|
|
1304
|
-
- [x] `Results.Created` / `NoContent` / `OkStream` and `@HttpCode` APIs (not yet applied; see below)
|
|
1305
|
-
|
|
1306
|
-
**Packaging and tooling**
|
|
1307
|
-
|
|
1308
|
-
- [x] CommonJS-only build with an `exports` map and `sideEffects`
|
|
1309
|
-
- [x] Integrations moved to optional peer dependencies
|
|
1310
|
-
- [x] Replace typedi with Megh's own container behind `MeghContainer`
|
|
1311
|
-
- [x] MIT license file matches `package.json`
|
|
1312
|
-
- [x] Build without rimraf, ESLint/Jest configs fixed, husky 9, coverage off by default
|
|
1313
|
-
- [x] CI on Node 22 and 24 (typecheck, lint, test, build) and a tag-based publish workflow
|
|
1314
|
-
- [x] Request-pipeline integration tests
|
|
1315
|
-
|
|
1316
|
-
**Docs**
|
|
1317
|
-
|
|
1318
|
-
- [x] README and docs site rewritten for the current API, with an upgrade guide
|
|
1319
|
-
- [x] New pages: authentication, file uploads, caching, logging
|
|
1320
|
-
- [x] Docs site moved to VitePress, with template links removed and typos fixed
|
|
1321
|
-
|
|
1322
|
-
### Left for 1.0.0
|
|
1323
|
-
|
|
1324
|
-
**Regressions from 0.3.0** (see [Known Issues](#known-issues-in-030))
|
|
1325
|
-
|
|
1326
|
-
- [x] `@UseMiddleware(SomeClass)` crashes boot (fixed in 0.5.2)
|
|
1327
|
-
- [ ] `@Repository` / `@Queue` classes without a constructor break under DI
|
|
1328
|
-
- [ ] Apply status codes from `Results`, `HttpResponse.Created` and `@HttpCode`
|
|
1329
|
-
- [ ] Put `@Body()` / `@Query()` DTO schemas back into the OpenAPI document
|
|
1330
|
-
- [ ] Upload policy violations should return 400 / 413, not 500
|
|
1331
|
-
|
|
1332
|
-
**Core correctness**
|
|
1333
|
-
|
|
1334
|
-
- [ ] `useScheduler({ path })` crashes `run()` (wrong `require` path)
|
|
1335
|
-
- [ ] `@UploadFile` / `@UploadFiles` don't await `saveRequestFiles()`
|
|
1336
|
-
- [ ] `@All()` crashes at registration
|
|
1337
|
-
- [ ] Respect `error.statusCode` (401, 413, 415, 429, …) for non-HTTP-exception errors
|
|
1338
|
-
- [ ] One consistent middleware order; resolve `@UseMiddleware` through DI
|
|
1339
|
-
- [ ] Route metadata cache is keyed on `constructor.name`, so same-named classes collide
|
|
1340
|
-
- [ ] Controller discovery: `_resolveControllerDir` ignores its argument and rewrites the first `src` in the path; repeated `useControllers` calls overwrite each other
|
|
1341
|
-
- [ ] Functional routes: add `mapPatch`, and run authentication, DI and the standard error shape
|
|
1342
|
-
- [ ] `run()` `host` option (default `0.0.0.0` in containers)
|
|
1343
|
-
- [ ] Graceful shutdown: `app.close()` and close TypeORM, Knex, Redis and Socket.IO with a drain timeout instead of `process.exit(0)`
|
|
1344
|
-
- [ ] `PartialType` / `OmitType` / `PickType` don't carry class-validator rules correctly
|
|
1345
|
-
- [ ] Scalar `spec.content` returns the plugin module instead of the spec
|
|
1346
|
-
- [ ] `Environment` re-reads `.env` on every `get()`, and `dotenv` loads on import
|
|
1347
|
-
- [ ] Socket handler errors become unhandled rejections
|
|
1348
|
-
- [ ] `@MeghWorker` `autoStart` is not wired to app boot
|
|
1349
|
-
- [ ] `class-validator` / `class-transformer` are loaded at import time despite being optional peers
|
|
1350
|
-
|
|
1351
|
-
**Missing features**
|
|
1352
|
-
|
|
1353
|
-
- [ ] Security headers (helmet) and rate limiting as `use*` options
|
|
1354
|
-
- [ ] Health and readiness endpoints
|
|
1355
|
-
- [ ] Request IDs in logs, and the logger wired into Fastify
|
|
1356
|
-
- [ ] Redirects and response headers from handlers
|
|
1357
|
-
- [ ] Pluggable error handler / exception filters
|
|
1358
|
-
- [x] Lifecycle hooks (`onInit`, `onReady`, `onClose`, `app.close()`)
|
|
1359
|
-
- [ ] Config schema validation at boot
|
|
1360
|
-
- [ ] Global route prefix and API versioning
|
|
1361
|
-
- [ ] Compression
|
|
1362
|
-
- [ ] Socket.IO handshake authentication and per-channel authorization
|
|
1363
|
-
|
|
1364
|
-
**API cleanup** (a 1.0 surface is a promise)
|
|
1365
|
-
|
|
1366
|
-
- [ ] Finish or remove the no-ops `useHttps()`, `useSerialization()` and `mapFeatures()`
|
|
1367
|
-
- [x] Move TypeORM and Knex to the `@meghjs/data` plugin, and remove deprecated `useDatasource()`
|
|
1368
|
-
- [ ] Remove the `MeghSocketIo` stubs and unused adapter types
|
|
1369
|
-
- [ ] Remove `KnexHooks` / `KnexHooksFactory`, `DuplicateRouteException`, `mapRoute()` and `registerMiddleware()`
|
|
1370
|
-
- [x] Stop exporting `mock-db` from the public index, and build without Jest types
|
|
1371
|
-
- [ ] Replace remaining `console.log` calls with the logger
|
|
1372
|
-
|
|
1373
|
-
**Tests**
|
|
1374
|
-
|
|
1375
|
-
- [ ] `application.ts`: `run()`, shutdown, controller auto-discovery, `useScheduler({ path })`
|
|
1376
|
-
- [ ] Events, scheduler, workers, Redis cache, `testing.ts`, `map-types.ts`, config
|
|
1377
|
-
- [ ] Fix hollow tests and `MeghTest` (`from()` race, global container mutation)
|
|
1378
|
-
- [ ] Coverage thresholds
|
|
1379
|
-
|
|
1380
|
-
**CLI** (`@meghjs/cli`, rewrite in progress)
|
|
1381
|
-
|
|
1382
|
-
- [ ] Finish the commander-based rewrite: `--help` / `--version`, consistent flags and naming, refuse to overwrite existing projects
|
|
1383
|
-
- [ ] Generated code compiles against `@meghjs/core`
|
|
1384
|
-
- [ ] CLI tests (snapshots for every `make:*` command)
|
|
1385
|
-
- [ ] Release with versions matched to core
|
|
1386
|
-
|
|
1387
|
-
**Docs and release**
|
|
1388
|
-
|
|
1389
|
-
- [ ] Pages for configuration, scheduler, testing, dependency injection, responses, deployment and security hardening
|
|
1390
|
-
- [ ] API reference and FAQ
|
|
1391
|
-
- [ ] Contributor guide: project structure, and the exports that CLI-generated code relies on
|
|
1392
|
-
- [ ] Changelog and a versioning policy across core, CLI and docs
|
|
1282
|
+
1.0.0 is the first release with a stable API. Until then, minor releases
|
|
1283
|
+
(0.6, 0.7, …) can contain breaking changes, each with an upgrade guide.
|
|
1284
|
+
|
|
1285
|
+
Work left for 1.0.0 is tracked as issues in the
|
|
1286
|
+
[`1.0.0` milestone](https://github.com/meghjs/megh/milestone/1), with an
|
|
1287
|
+
overview in [`1.0-CHECKLIST.md`](https://github.com/meghjs/megh/blob/main/1.0-CHECKLIST.md).
|
|
1288
|
+
What's left is mainly core correctness fixes, security headers, rate limiting
|
|
1289
|
+
and compression, a global route prefix, tests, and trimming the public API.
|
|
1393
1290
|
|
|
1394
1291
|
---
|
|
1395
1292
|
|
package/dist/common/container.js
CHANGED
|
@@ -26,7 +26,6 @@ exports.DATASOURCE_META_KEY = Symbol("idatasource:options");
|
|
|
26
26
|
exports.AUTHORIZATION_META_KEY = Symbol("idatasource:authorization");
|
|
27
27
|
const controllerRegistry = new Set();
|
|
28
28
|
const serviceRegistry = new Set();
|
|
29
|
-
const optionsRegistry = new Map();
|
|
30
29
|
function registerController(controller) {
|
|
31
30
|
controllerRegistry.add(controller);
|
|
32
31
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container.js","sourceRoot":"","sources":["../../src/common/container.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"container.js","sourceRoot":"","sources":["../../src/common/container.ts"],"names":[],"mappings":";;;AAsBA,gDAEC;AACD,0CAGC;AAED,sDAEC;AACD,4DAEC;AAID,0CAEC;AAzCD;;;;;GAKG;AACH,8BAAkC;AACrB,QAAA,cAAc,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAC1C,QAAA,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAC;AACpD,QAAA,cAAc,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAC1C,QAAA,cAAc,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAC1C,QAAA,qBAAqB,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;AACjD,QAAA,qBAAqB,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;AACjD,QAAA,sBAAsB,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAClD,QAAA,qBAAqB,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC;AACjD,QAAA,uBAAuB,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC;AACpD,QAAA,mBAAmB,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAC;AACpD,QAAA,sBAAsB,GAAG,MAAM,CAAC,2BAA2B,CAAC,CAAC;AAE1E,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAY,CAAC;AAC/C,MAAM,eAAe,GAAG,IAAI,GAAG,EAAY,CAAC;AAE5C,SAAgB,kBAAkB,CAAC,UAAoB;IACrD,kBAAkB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;AACrC,CAAC;AACD,SAAgB,eAAe,CAAC,OAAiB;IAC/C,cAAS,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAChC,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AAC/B,CAAC;AAED,SAAgB,qBAAqB;IACnC,OAAO,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;AACrC,CAAC;AACD,SAAgB,wBAAwB;IACtC,OAAO,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;AACxC,CAAC;AAEY,QAAA,2BAA2B,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC;AAEnE,SAAgB,eAAe,CAAC,MAAgB;IAC9C,OAAO,OAAO,CAAC,WAAW,CAAC,mCAA2B,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;AAC3E,CAAC"}
|
|
@@ -4,19 +4,9 @@
|
|
|
4
4
|
* @email xtrinsic96@gmail.com
|
|
5
5
|
* @url https://github.com/xtareq
|
|
6
6
|
*/
|
|
7
|
-
export interface IRouteDuplicateErr {
|
|
8
|
-
path: string;
|
|
9
|
-
mpath: string;
|
|
10
|
-
method: string;
|
|
11
|
-
controller: string;
|
|
12
|
-
inverseController?: string;
|
|
13
|
-
}
|
|
14
7
|
export declare class SystemUseError extends Error {
|
|
15
8
|
constructor(message: string);
|
|
16
9
|
}
|
|
17
|
-
export declare class DuplicateRouteException extends Error {
|
|
18
|
-
constructor(params: IRouteDuplicateErr);
|
|
19
|
-
}
|
|
20
10
|
export declare class EnvironmentVariableNotFound extends Error {
|
|
21
11
|
constructor(key: string);
|
|
22
12
|
}
|
|
@@ -1,23 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EnvironmentVariableNotFound = exports.
|
|
3
|
+
exports.EnvironmentVariableNotFound = exports.SystemUseError = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @copyright 2024
|
|
6
|
+
* @author Tareq Hossain
|
|
7
|
+
* @email xtrinsic96@gmail.com
|
|
8
|
+
* @url https://github.com/xtareq
|
|
9
|
+
*/
|
|
4
10
|
class SystemUseError extends Error {
|
|
5
11
|
constructor(message) {
|
|
6
12
|
super(message);
|
|
7
13
|
}
|
|
8
14
|
}
|
|
9
15
|
exports.SystemUseError = SystemUseError;
|
|
10
|
-
class DuplicateRouteException extends Error {
|
|
11
|
-
constructor(params) {
|
|
12
|
-
let sameController = params.controller == params.inverseController;
|
|
13
|
-
let message = `Duplicate route found for method ${params.method.toUpperCase()}:${params.path == "" ? "'/'" : params.path} `;
|
|
14
|
-
message += sameController
|
|
15
|
-
? `in ${params.controller}`
|
|
16
|
-
: `both in ${params.controller} and ${params.inverseController}`;
|
|
17
|
-
super(message);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
exports.DuplicateRouteException = DuplicateRouteException;
|
|
21
16
|
class EnvironmentVariableNotFound extends Error {
|
|
22
17
|
constructor(key) {
|
|
23
18
|
super(`${key} not found in environment variables.`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system-exception.js","sourceRoot":"","sources":["../../../src/common/exceptions/system-exception.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"system-exception.js","sourceRoot":"","sources":["../../../src/common/exceptions/system-exception.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,MAAa,cAAe,SAAQ,KAAK;IACvC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;CACF;AAJD,wCAIC;AACD,MAAa,2BAA4B,SAAQ,KAAK;IACpD,YAAY,GAAW;QACrB,KAAK,CAAC,GAAG,GAAG,sCAAsC,CAAC,CAAC;IACtD,CAAC;CACF;AAJD,kEAIC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.compileValidator = compileValidator;
|
|
4
|
+
const internal_logger_1 = require("../../observability/internal-logger");
|
|
4
5
|
const schema_properties_1 = require("../../openapi/schema-properties");
|
|
5
6
|
const messages_1 = require("../../validator/messages");
|
|
6
7
|
const IS_DEFINED = "isDefined";
|
|
@@ -30,7 +31,7 @@ function compileValidator(target) {
|
|
|
30
31
|
catch (error) {
|
|
31
32
|
if (!warnedUnavailable) {
|
|
32
33
|
warnedUnavailable = true;
|
|
33
|
-
|
|
34
|
+
(0, internal_logger_1.internalLogger)("validation").warn({ err: error }, "Compiled validation is unavailable, using class-validator");
|
|
34
35
|
}
|
|
35
36
|
compiled = null;
|
|
36
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compiled-validation.js","sourceRoot":"","sources":["../../../src/common/utils/compiled-validation.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"compiled-validation.js","sourceRoot":"","sources":["../../../src/common/utils/compiled-validation.ts"],"names":[],"mappings":";;AAwFA,4CAsBC;AA5ED,yEAAqE;AACrE,uEAAwE;AACxE,uDAAuE;AAWvE,MAAM,UAAU,GAAG,WAAW,CAAC;AAC/B,MAAM,iBAAiB,GAAG,kBAAkB,CAAC;AAC7C,MAAM,sBAAsB,GAAG,uBAAuB,CAAC;AACvD,MAAM,SAAS,GAAG,qBAAqB,CAAC;AAExC,qE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AO,EAAE,CAAC,CAAC;IAC5D,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC3C,wEAAwE;IACxE,wEAAwE;IACxE,IAAI,KAAK,KAAK,MAAM,CAAC,SAAS,IAAI,KAAK,KAAK,IAAI;QAAE,MAAM,IAAI,CAAC;IAC7D,2EAA2E;IAC3E,gEAAgE;IAChE,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,aAAa,CAAC;QAAE,MAAM,IAAI,CAAC;IAE3E,MAAM,GAAG,GAAwB,EAAE,CAAC;IACpC,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACrC,IAAI,GAAG,KAAK,WAAW,IAAI,GAAG,KAAK,aAAa;YAAE,SAAS;QAC3D,mDAAmD;QACnD,IAAI,mBAAmB,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,SAAS;QAC3C,GAAG,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IACnC,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -53,6 +53,7 @@ const dotenv_1 = __importDefault(require("dotenv"));
|
|
|
53
53
|
const path_1 = __importDefault(require("path"));
|
|
54
54
|
const fs_1 = __importStar(require("fs"));
|
|
55
55
|
const di_1 = require("../di");
|
|
56
|
+
const internal_logger_1 = require("../observability/internal-logger");
|
|
56
57
|
const system_exception_1 = require("../common/exceptions/system-exception");
|
|
57
58
|
// Load `.env` into process.env on import, so module-level code can read it.
|
|
58
59
|
// Set MEGH_DOTENV=false to skip this and manage the environment yourself.
|
|
@@ -84,7 +85,7 @@ let Environment = class Environment {
|
|
|
84
85
|
: {});
|
|
85
86
|
}
|
|
86
87
|
catch (error) {
|
|
87
|
-
|
|
88
|
+
(0, internal_logger_1.internalLogger)("config").error({ err: error, file: filePath }, "Error parsing .env file");
|
|
88
89
|
fileCache.set(filePath, null);
|
|
89
90
|
}
|
|
90
91
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environment-variables.js","sourceRoot":"","sources":["../../src/config/environment-variables.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,oDAA4B;AAC5B,gDAAwB;AACxB,yCAAoC;AACpC,8BAAmC;AACnC,
|
|
1
|
+
{"version":3,"file":"environment-variables.js","sourceRoot":"","sources":["../../src/config/environment-variables.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,oDAA4B;AAC5B,gDAAwB;AACxB,yCAAoC;AACpC,8BAAmC;AACnC,sEAAkE;AAClE,4EAAoF;AAEpF,4EAA4E;AAC5E,0EAA0E;AAC1E,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,KAAK,OAAO,EAAE,CAAC;IACxC,gBAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AACzE,CAAC;AAED,0EAA0E;AAC1E,MAAM,SAAS,GAAG,IAAI,GAAG,EAAyC,CAAC;AACnE;;;;;GAKG;AAEI,IAAM,WAAW,GAAjB,MAAM,WAAW;IACtB;;;;;;;OAOG;IACK,YAAY,CAAC,QAAgB;QACnC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC7B,IAAI,CAAC;gBACH,SAAS,CAAC,GAAG,CACX,QAAQ,EACR,IAAA,eAAU,EAAC,QAAQ,CAAC;oBAClB,CAAC,CAAC,gBAAM,CAAC,KAAK,CAAC,YAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;oBACj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;QACJ,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,cAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC;QACtE,OAAO,SAAc,CAAC;IACxB,CAAC;CACF,CAAA;AA5EY,kCAAW;sBAAX,WAAW;IADvB,IAAA,eAAU,GAAE;GACA,WAAW,CA4EvB"}
|
|
@@ -21,12 +21,10 @@ export declare class MeghApplication implements IMeghApplication {
|
|
|
21
21
|
private alreadyRun;
|
|
22
22
|
private hasSwagger;
|
|
23
23
|
private globalSwaggerOptions;
|
|
24
|
-
private isMapFeatures;
|
|
25
24
|
private registerControllerAuto;
|
|
26
25
|
private registerControllerPath;
|
|
27
26
|
private controllers;
|
|
28
27
|
private _hasWebsocket;
|
|
29
|
-
private io;
|
|
30
28
|
private scheduler;
|
|
31
29
|
private schedulerTasks;
|
|
32
30
|
private registerSchedulerAuto;
|
|
@@ -122,7 +120,6 @@ export declare class MeghApplication implements IMeghApplication {
|
|
|
122
120
|
* It passes unless it throws, rejects or returns `false`.
|
|
123
121
|
*/
|
|
124
122
|
addHealthCheck(name: string, check: HealthCheck): this;
|
|
125
|
-
useSerialization(): this;
|
|
126
123
|
/**
|
|
127
124
|
* Register scheduled task classes.
|
|
128
125
|
*
|
|
@@ -137,7 +134,6 @@ export declare class MeghApplication implements IMeghApplication {
|
|
|
137
134
|
}): this;
|
|
138
135
|
useControllers(controllers: Constructor[] | AutoControllerOptions): this;
|
|
139
136
|
useStaticFiles(options?: any): this;
|
|
140
|
-
useHttps(options?: any): this;
|
|
141
137
|
useGlobal(options: GlobalOptions): this;
|
|
142
138
|
useSocketIo(options?: any): this;
|
|
143
139
|
/**
|
|
@@ -154,7 +150,6 @@ export declare class MeghApplication implements IMeghApplication {
|
|
|
154
150
|
useWorker(workers: Constructor<any>[]): this;
|
|
155
151
|
/** Close every registered worker, releasing their Redis connections. */
|
|
156
152
|
private _closeWorkers;
|
|
157
|
-
mapFeatures(): this;
|
|
158
153
|
/**
|
|
159
154
|
* True only when `NODE_ENV` is exactly `"development"`. An unset
|
|
160
155
|
* `NODE_ENV` counts as production, so dev-only features (API docs,
|
|
@@ -164,7 +159,6 @@ export declare class MeghApplication implements IMeghApplication {
|
|
|
164
159
|
private _mapControllers;
|
|
165
160
|
private _resolveControllerDir;
|
|
166
161
|
private autoControllers;
|
|
167
|
-
private _mapFeatures;
|
|
168
162
|
private handleSocket;
|
|
169
163
|
mapGet<T extends (...args: any[]) => any>(path: string | undefined, fn: T): {
|
|
170
164
|
useMiddleware: (middlewares: MeghMiddleware | Constructor<MeghMiddleware> | (MeghMiddleware | Constructor<MeghMiddleware>)[]) => /*elided*/ any;
|
|
@@ -235,8 +229,9 @@ export declare class MeghApplication implements IMeghApplication {
|
|
|
235
229
|
* await app.run(3000)
|
|
236
230
|
* await app.run(3000, { host: "127.0.0.1" })
|
|
237
231
|
*
|
|
238
|
-
* The
|
|
239
|
-
*
|
|
232
|
+
* The port defaults to the `PORT` environment variable, else `4000`. The
|
|
233
|
+
* host defaults to the `HOST` environment variable, else `0.0.0.0` so the
|
|
234
|
+
* app is reachable inside containers.
|
|
240
235
|
*/
|
|
241
236
|
run(port?: number, options?: RunOptions | CallableFunction): Promise<void>;
|
|
242
237
|
}
|
package/dist/core/application.js
CHANGED
|
@@ -140,12 +140,10 @@ class MeghApplication {
|
|
|
140
140
|
alreadyRun = false;
|
|
141
141
|
hasSwagger = false;
|
|
142
142
|
globalSwaggerOptions;
|
|
143
|
-
isMapFeatures = false;
|
|
144
143
|
registerControllerAuto = false;
|
|
145
144
|
registerControllerPath = "src/controllers";
|
|
146
145
|
controllers = [];
|
|
147
146
|
_hasWebsocket = false;
|
|
148
|
-
io;
|
|
149
147
|
scheduler = new scheduler_1.MeghScheduler();
|
|
150
148
|
schedulerTasks = [];
|
|
151
149
|
registerSchedulerAuto = false;
|
|
@@ -430,9 +428,6 @@ class MeghApplication {
|
|
|
430
428
|
this.health.add(name, check);
|
|
431
429
|
return this;
|
|
432
430
|
}
|
|
433
|
-
useSerialization() {
|
|
434
|
-
return this;
|
|
435
|
-
}
|
|
436
431
|
/**
|
|
437
432
|
* Register scheduled task classes.
|
|
438
433
|
*
|
|
@@ -475,9 +470,6 @@ class MeghApplication {
|
|
|
475
470
|
this.app.register(requireStatic(), options); // ✅ lazy
|
|
476
471
|
return this;
|
|
477
472
|
}
|
|
478
|
-
useHttps(options) {
|
|
479
|
-
return this;
|
|
480
|
-
}
|
|
481
473
|
useGlobal(options) {
|
|
482
474
|
if (options.cors)
|
|
483
475
|
this.useCors(options.cors);
|
|
@@ -534,15 +526,11 @@ class MeghApplication {
|
|
|
534
526
|
await w?.close?.();
|
|
535
527
|
}
|
|
536
528
|
catch (err) {
|
|
537
|
-
|
|
529
|
+
(0, internal_logger_1.internalLogger)("queue").error({ err }, "Failed to close worker");
|
|
538
530
|
}
|
|
539
531
|
}));
|
|
540
532
|
this._workers = [];
|
|
541
533
|
}
|
|
542
|
-
mapFeatures() {
|
|
543
|
-
this.isMapFeatures = true;
|
|
544
|
-
return this;
|
|
545
|
-
}
|
|
546
534
|
/**
|
|
547
535
|
* True only when `NODE_ENV` is exactly `"development"`. An unset
|
|
548
536
|
* `NODE_ENV` counts as production, so dev-only features (API docs,
|
|
@@ -598,15 +586,7 @@ class MeghApplication {
|
|
|
598
586
|
}
|
|
599
587
|
}
|
|
600
588
|
catch (e) {
|
|
601
|
-
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
_mapFeatures() {
|
|
605
|
-
try {
|
|
606
|
-
di_1.Container.get("features");
|
|
607
|
-
}
|
|
608
|
-
catch {
|
|
609
|
-
// features token not registered — safe to ignore
|
|
589
|
+
(0, internal_logger_1.internalLogger)("app").warn({ err: e, dir: conDir }, "Could not auto-register controllers");
|
|
610
590
|
}
|
|
611
591
|
}
|
|
612
592
|
handleSocket(socket) {
|
|
@@ -614,7 +594,6 @@ class MeghApplication {
|
|
|
614
594
|
try {
|
|
615
595
|
const { SocketContextService } = require("../events/socket-dispatcher");
|
|
616
596
|
const { EventSubscriberRegistry } = require("../events/event-subscriber");
|
|
617
|
-
const { SocketIoServer } = require("../realtime/websocket");
|
|
618
597
|
const contextService = di_1.Container.get(SocketContextService);
|
|
619
598
|
const subscriberRegistry = di_1.Container.get(EventSubscriberRegistry);
|
|
620
599
|
subscriberRegistry.register(socket);
|
|
@@ -626,7 +605,7 @@ class MeghApplication {
|
|
|
626
605
|
};
|
|
627
606
|
}
|
|
628
607
|
catch (e) {
|
|
629
|
-
|
|
608
|
+
(0, internal_logger_1.internalLogger)("realtime").warn({ err: e }, "Socket handler error");
|
|
630
609
|
}
|
|
631
610
|
}
|
|
632
611
|
// ── Functional routing proxies ───────────────────────────────────────────
|
|
@@ -693,7 +672,7 @@ class MeghApplication {
|
|
|
693
672
|
await cache_1.CacheManager.close();
|
|
694
673
|
}
|
|
695
674
|
catch (err) {
|
|
696
|
-
|
|
675
|
+
(0, internal_logger_1.internalLogger)("app").error({ err }, "Closing the cache failed");
|
|
697
676
|
}
|
|
698
677
|
}
|
|
699
678
|
for (const hook of [...this.lifecycleHooks.close].reverse()) {
|
|
@@ -701,7 +680,7 @@ class MeghApplication {
|
|
|
701
680
|
await hook();
|
|
702
681
|
}
|
|
703
682
|
catch (err) {
|
|
704
|
-
|
|
683
|
+
(0, internal_logger_1.internalLogger)("app").error({ err }, "onClose hook failed");
|
|
705
684
|
}
|
|
706
685
|
}
|
|
707
686
|
}
|
|
@@ -746,7 +725,7 @@ class MeghApplication {
|
|
|
746
725
|
}
|
|
747
726
|
}
|
|
748
727
|
catch (e) {
|
|
749
|
-
|
|
728
|
+
(0, internal_logger_1.internalLogger)("scheduler").warn({ err: e, dir: resolvedDir }, "Could not auto-register tasks");
|
|
750
729
|
}
|
|
751
730
|
}
|
|
752
731
|
/**
|
|
@@ -755,22 +734,21 @@ class MeghApplication {
|
|
|
755
734
|
* await app.run(3000)
|
|
756
735
|
* await app.run(3000, { host: "127.0.0.1" })
|
|
757
736
|
*
|
|
758
|
-
* The
|
|
759
|
-
*
|
|
737
|
+
* The port defaults to the `PORT` environment variable, else `4000`. The
|
|
738
|
+
* host defaults to the `HOST` environment variable, else `0.0.0.0` so the
|
|
739
|
+
* app is reachable inside containers.
|
|
760
740
|
*/
|
|
761
|
-
async run(port
|
|
741
|
+
async run(port, options) {
|
|
762
742
|
const fn = typeof options === "function" ? options : options?.onListen;
|
|
763
743
|
const runOptions = typeof options === "object" ? options : {};
|
|
764
744
|
if (this.alreadyRun)
|
|
765
745
|
throw new system_exception_1.SystemUseError("App already running");
|
|
746
|
+
const listenPort = port ?? portFromEnv();
|
|
766
747
|
this.alreadyRun = true;
|
|
767
748
|
if (this.hasSwagger) {
|
|
768
749
|
await this.initSwagger(this.globalSwaggerOptions);
|
|
769
750
|
}
|
|
770
751
|
await this.runHooks(this.lifecycleHooks.init);
|
|
771
|
-
if (this.isMapFeatures) {
|
|
772
|
-
this._mapFeatures();
|
|
773
|
-
}
|
|
774
752
|
if (this.registerControllerAuto) {
|
|
775
753
|
await this.autoControllers();
|
|
776
754
|
}
|
|
@@ -800,7 +778,7 @@ class MeghApplication {
|
|
|
800
778
|
await this.app.io.on("connection", this.handleSocket.bind(this));
|
|
801
779
|
}
|
|
802
780
|
catch (e) {
|
|
803
|
-
|
|
781
|
+
(0, internal_logger_1.internalLogger)("realtime").warn({ err: e }, "WebSocket setup error");
|
|
804
782
|
}
|
|
805
783
|
}
|
|
806
784
|
const timeout = runOptions.shutdownTimeout ?? 10_000;
|
|
@@ -827,14 +805,25 @@ class MeghApplication {
|
|
|
827
805
|
process.once("SIGTERM", gracefulStop);
|
|
828
806
|
process.once("SIGINT", gracefulStop);
|
|
829
807
|
const host = runOptions.host ?? process.env.HOST ?? "0.0.0.0";
|
|
830
|
-
const address = await this.app.listen({ port, host });
|
|
831
|
-
|
|
808
|
+
const address = await this.app.listen({ port: listenPort, host });
|
|
809
|
+
(0, internal_logger_1.internalLogger)("app").info({ address }, `Application running on ${address}`);
|
|
832
810
|
await this.runHooks(this.lifecycleHooks.ready);
|
|
833
811
|
if (fn)
|
|
834
812
|
fn();
|
|
835
813
|
}
|
|
836
814
|
}
|
|
837
815
|
exports.MeghApplication = MeghApplication;
|
|
816
|
+
/** The port from the `PORT` environment variable, else 4000. */
|
|
817
|
+
function portFromEnv() {
|
|
818
|
+
const raw = process.env.PORT?.trim();
|
|
819
|
+
if (!raw)
|
|
820
|
+
return 4000;
|
|
821
|
+
const port = Number(raw);
|
|
822
|
+
if (!Number.isInteger(port) || port < 0 || port > 65535) {
|
|
823
|
+
throw new system_exception_1.SystemUseError(`Invalid PORT "${process.env.PORT}": expected a whole number from 0 to 65535.`);
|
|
824
|
+
}
|
|
825
|
+
return port;
|
|
826
|
+
}
|
|
838
827
|
/** The security scheme and requirement for `useOpenApi({ auth })`. */
|
|
839
828
|
function openApiSecurity(auth) {
|
|
840
829
|
if (!auth)
|