@venizia/ignis 0.4.7-0 → 0.4.7-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/LICENSE.md +1 -4
- package/README.md +2 -2
- package/dist/esm/base/applications/base.d.ts.map +1 -1
- package/dist/esm/base/applications/base.js +25 -18
- package/dist/esm/base/applications/base.js.map +1 -1
- package/dist/esm/base/applications/common/index.d.ts +1 -0
- package/dist/esm/base/applications/common/index.d.ts.map +1 -1
- package/dist/esm/base/applications/common/index.js +1 -0
- package/dist/esm/base/applications/common/index.js.map +1 -1
- package/dist/esm/base/applications/common/logger-startup.d.ts +11 -0
- package/dist/esm/base/applications/common/logger-startup.d.ts.map +1 -0
- package/dist/esm/base/applications/common/logger-startup.js +29 -0
- package/dist/esm/base/applications/common/logger-startup.js.map +1 -0
- package/dist/esm/base/applications/server.d.ts +14 -9
- package/dist/esm/base/applications/server.d.ts.map +1 -1
- package/dist/esm/base/applications/server.js +36 -29
- package/dist/esm/base/applications/server.js.map +1 -1
- package/dist/esm/common/constants.d.ts.map +1 -1
- package/dist/esm/common/constants.js +2 -2
- package/dist/esm/common/constants.js.map +1 -1
- package/dist/esm/components/auth/authenticate/component.js +2 -2
- package/dist/esm/components/auth/authenticate/component.js.map +1 -1
- package/dist/esm/components/auth/authenticate/controllers/factory.d.ts +139 -136
- package/dist/esm/components/auth/authenticate/controllers/factory.d.ts.map +1 -1
- package/dist/esm/components/auth/authenticate/controllers/factory.js +175 -172
- package/dist/esm/components/auth/authenticate/controllers/factory.js.map +1 -1
- package/dist/esm/components/auth/authenticate/controllers/jwks/definitions.js +2 -2
- package/dist/esm/components/auth/authenticate/controllers/jwks/definitions.js.map +1 -1
- package/dist/esm/components/auth/authenticate/controllers/service-certs/definitions.js +2 -2
- package/dist/esm/components/auth/authenticate/controllers/service-certs/definitions.js.map +1 -1
- package/dist/esm/components/auth/authorize/adapters/base-filtered.js +2 -2
- package/dist/esm/components/auth/authorize/adapters/base-filtered.js.map +1 -1
- package/dist/esm/components/auth/authorize/adapters/custom-grant-expander.d.ts.map +1 -1
- package/dist/esm/components/auth/authorize/adapters/custom-grant-expander.js +2 -2
- package/dist/esm/components/auth/authorize/adapters/custom-grant-expander.js.map +1 -1
- package/dist/esm/components/auth/models/entities/columns.d.ts +99 -0
- package/dist/esm/components/auth/models/entities/columns.d.ts.map +1 -0
- package/dist/esm/components/auth/models/entities/columns.js +133 -0
- package/dist/esm/components/auth/models/entities/columns.js.map +1 -0
- package/dist/esm/components/auth/models/entities/index.d.ts +1 -2
- package/dist/esm/components/auth/models/entities/index.d.ts.map +1 -1
- package/dist/esm/components/auth/models/entities/index.js +1 -2
- package/dist/esm/components/auth/models/entities/index.js.map +1 -1
- package/dist/esm/components/auth/models/entities/permission.model.d.ts +1 -12
- package/dist/esm/components/auth/models/entities/permission.model.d.ts.map +1 -1
- package/dist/esm/components/auth/models/entities/permission.model.js +1 -36
- package/dist/esm/components/auth/models/entities/permission.model.js.map +1 -1
- package/dist/esm/components/auth/models/entities/policy-definition.model.d.ts +1 -49
- package/dist/esm/components/auth/models/entities/policy-definition.model.d.ts.map +1 -1
- package/dist/esm/components/auth/models/entities/policy-definition.model.js +1 -69
- package/dist/esm/components/auth/models/entities/policy-definition.model.js.map +1 -1
- package/dist/esm/components/controller/grpc/grpc.component.js +2 -2
- package/dist/esm/components/controller/grpc/grpc.component.js.map +1 -1
- package/dist/esm/components/health-check/controller.js +5 -5
- package/dist/esm/components/health-check/controller.js.map +1 -1
- package/dist/esm/components/index.d.ts +0 -1
- package/dist/esm/components/index.d.ts.map +1 -1
- package/dist/esm/components/index.js +0 -1
- package/dist/esm/components/index.js.map +1 -1
- package/dist/esm/components/mail/helpers/transporters/amazon-ses-transporter.helper.d.ts.map +1 -1
- package/dist/esm/components/mail/helpers/transporters/amazon-ses-transporter.helper.js +13 -9
- package/dist/esm/components/mail/helpers/transporters/amazon-ses-transporter.helper.js.map +1 -1
- package/dist/esm/components/mail/helpers/transporters/mailgun-transporter.helper.d.ts.map +1 -1
- package/dist/esm/components/mail/helpers/transporters/mailgun-transporter.helper.js +5 -3
- package/dist/esm/components/mail/helpers/transporters/mailgun-transporter.helper.js.map +1 -1
- package/dist/esm/components/mail/helpers/transporters/nodemail-transporter.helper.d.ts.map +1 -1
- package/dist/esm/components/mail/helpers/transporters/nodemail-transporter.helper.js +5 -5
- package/dist/esm/components/mail/helpers/transporters/nodemail-transporter.helper.js.map +1 -1
- package/dist/esm/components/mail/services/generators/verification-data.d.ts.map +1 -1
- package/dist/esm/components/mail/services/generators/verification-data.js +7 -3
- package/dist/esm/components/mail/services/generators/verification-data.js.map +1 -1
- package/dist/esm/components/mail/services/mail.service.js +7 -7
- package/dist/esm/components/mail/services/mail.service.js.map +1 -1
- package/dist/esm/components/mail/utilities/address.utility.d.ts +12 -8
- package/dist/esm/components/mail/utilities/address.utility.d.ts.map +1 -1
- package/dist/esm/components/mail/utilities/address.utility.js +30 -27
- package/dist/esm/components/mail/utilities/address.utility.js.map +1 -1
- package/dist/esm/components/mail/utilities/attachment.utility.d.ts +31 -29
- package/dist/esm/components/mail/utilities/attachment.utility.d.ts.map +1 -1
- package/dist/esm/components/mail/utilities/attachment.utility.js +97 -86
- package/dist/esm/components/mail/utilities/attachment.utility.js.map +1 -1
- package/dist/esm/components/mail/utilities/body.utility.d.ts +6 -4
- package/dist/esm/components/mail/utilities/body.utility.d.ts.map +1 -1
- package/dist/esm/components/mail/utilities/body.utility.js +14 -12
- package/dist/esm/components/mail/utilities/body.utility.js.map +1 -1
- package/dist/esm/components/mail/utilities/mime.utility.d.ts +23 -17
- package/dist/esm/components/mail/utilities/mime.utility.d.ts.map +1 -1
- package/dist/esm/components/mail/utilities/mime.utility.js +109 -102
- package/dist/esm/components/mail/utilities/mime.utility.js.map +1 -1
- package/dist/esm/components/mail/utilities/verification.utility.d.ts +8 -2
- package/dist/esm/components/mail/utilities/verification.utility.d.ts.map +1 -1
- package/dist/esm/components/mail/utilities/verification.utility.js +7 -5
- package/dist/esm/components/mail/utilities/verification.utility.js.map +1 -1
- package/dist/esm/components/socket-io/component.js +3 -3
- package/dist/esm/components/socket-io/component.js.map +1 -1
- package/dist/esm/components/socket-io/handlers/bun.handler.d.ts +13 -11
- package/dist/esm/components/socket-io/handlers/bun.handler.d.ts.map +1 -1
- package/dist/esm/components/socket-io/handlers/bun.handler.js +32 -30
- package/dist/esm/components/socket-io/handlers/bun.handler.js.map +1 -1
- package/dist/esm/components/static-asset/common/commit-token.d.ts +21 -16
- package/dist/esm/components/static-asset/common/commit-token.d.ts.map +1 -1
- package/dist/esm/components/static-asset/common/commit-token.js +35 -28
- package/dist/esm/components/static-asset/common/commit-token.js.map +1 -1
- package/dist/esm/components/static-asset/common/constants.d.ts +0 -2
- package/dist/esm/components/static-asset/common/constants.d.ts.map +1 -1
- package/dist/esm/components/static-asset/common/constants.js +1 -3
- package/dist/esm/components/static-asset/common/constants.js.map +1 -1
- package/dist/esm/components/static-asset/common/types.d.ts +0 -4
- package/dist/esm/components/static-asset/common/types.d.ts.map +1 -1
- package/dist/esm/components/static-asset/common/types.js.map +1 -1
- package/dist/esm/components/static-asset/component.js +2 -2
- package/dist/esm/components/static-asset/component.js.map +1 -1
- package/dist/esm/components/static-asset/controller/base.definition.d.ts +6 -6
- package/dist/esm/components/static-asset/controller/base.definition.d.ts.map +1 -1
- package/dist/esm/components/static-asset/controller/base.definition.js +224 -224
- package/dist/esm/components/static-asset/controller/base.definition.js.map +1 -1
- package/dist/esm/components/static-asset/controller/factory.d.ts +23 -23
- package/dist/esm/components/static-asset/controller/factory.d.ts.map +1 -1
- package/dist/esm/components/static-asset/controller/factory.js +105 -76
- package/dist/esm/components/static-asset/controller/factory.js.map +1 -1
- package/dist/esm/components/static-asset/controller/key-scope.d.ts +28 -26
- package/dist/esm/components/static-asset/controller/key-scope.d.ts.map +1 -1
- package/dist/esm/components/static-asset/controller/key-scope.js +34 -30
- package/dist/esm/components/static-asset/controller/key-scope.js.map +1 -1
- package/dist/esm/components/static-asset/controller/meta-link.d.ts +37 -33
- package/dist/esm/components/static-asset/controller/meta-link.d.ts.map +1 -1
- package/dist/esm/components/static-asset/controller/meta-link.js +86 -84
- package/dist/esm/components/static-asset/controller/meta-link.js.map +1 -1
- package/dist/esm/components/static-asset/controller/route-options.d.ts +18 -16
- package/dist/esm/components/static-asset/controller/route-options.d.ts.map +1 -1
- package/dist/esm/components/static-asset/controller/route-options.js +28 -26
- package/dist/esm/components/static-asset/controller/route-options.js.map +1 -1
- package/dist/esm/components/static-asset/models/base.model.js +3 -3
- package/dist/esm/components/static-asset/models/base.model.js.map +1 -1
- package/dist/esm/components/websocket/component.js +2 -2
- package/dist/esm/components/websocket/component.js.map +1 -1
- package/dist/esm/components/websocket/handlers/bun.handler.d.ts +6 -4
- package/dist/esm/components/websocket/handlers/bun.handler.d.ts.map +1 -1
- package/dist/esm/components/websocket/handlers/bun.handler.js +21 -19
- package/dist/esm/components/websocket/handlers/bun.handler.js.map +1 -1
- package/dist/esm/testing/assert-application-boots.d.ts +6 -1
- package/dist/esm/testing/assert-application-boots.d.ts.map +1 -1
- package/dist/esm/testing/assert-application-boots.js +139 -136
- package/dist/esm/testing/assert-application-boots.js.map +1 -1
- package/dist/esm/utilities/drizzle-result.utility.d.ts +6 -8
- package/dist/esm/utilities/drizzle-result.utility.d.ts.map +1 -1
- package/dist/esm/utilities/drizzle-result.utility.js +23 -49
- package/dist/esm/utilities/drizzle-result.utility.js.map +1 -1
- package/dist/esm/utilities/network.utility.d.ts.map +1 -1
- package/dist/esm/utilities/network.utility.js +2 -2
- package/dist/esm/utilities/network.utility.js.map +1 -1
- package/dist/presets/app/files/src/boot.test.ts +2 -2
- package/dist/presets/app/files/src/controllers/hello.controller.ts +2 -2
- package/dist/presets/app/preset.json +4 -4
- package/dist/presets/lib/preset.json +4 -4
- package/dist/presets/shared/files/.configs/formatters/.ignore +4 -0
- package/dist/presets/shared/files/.configs/lints/.ignore +4 -0
- package/dist/presets/shared/files/.configs/lints/eslint.config.mjs +4 -0
- package/dist/presets/shared/files/.configs/lints/oxlint.config.mts +4 -0
- package/dist/presets/shared/files/README.md +15 -0
- package/dist/presets/shared/files/src/index.test.ts +8 -0
- package/dist/presets/shared/files/src/index.ts +8 -0
- package/dist/presets/shared/files/tsconfig.json +20 -0
- package/dist/presets/shared/preset.json +35 -0
- package/package.json +11 -11
- package/dist/esm/components/auth/models/entities/role.model.d.ts +0 -10
- package/dist/esm/components/auth/models/entities/role.model.d.ts.map +0 -1
- package/dist/esm/components/auth/models/entities/role.model.js +0 -15
- package/dist/esm/components/auth/models/entities/role.model.js.map +0 -1
- package/dist/esm/components/auth/models/entities/user.model.d.ts +0 -28
- package/dist/esm/components/auth/models/entities/user.model.d.ts.map +0 -1
- package/dist/esm/components/auth/models/entities/user.model.js +0 -17
- package/dist/esm/components/auth/models/entities/user.model.js.map +0 -1
- package/dist/esm/components/controller/index.d.ts +0 -2
- package/dist/esm/components/controller/index.d.ts.map +0 -1
- package/dist/esm/components/controller/index.js +0 -7
- package/dist/esm/components/controller/index.js.map +0 -1
package/LICENSE.md
CHANGED
|
@@ -37,7 +37,7 @@ This monorepo contains the following packages, all licensed under MIT:
|
|
|
37
37
|
| `@venizia/ignis-helpers` | Utility helpers - logging, cron, Redis, queues, storage |
|
|
38
38
|
| `@venizia/ignis-inversion` | Dependency Injection & IoC container |
|
|
39
39
|
| `@venizia/dev-configs` | Shared oxlint, ESLint, TypeScript configurations |
|
|
40
|
-
| `@venizia/ignis-docs` | Documentation
|
|
40
|
+
| `@venizia/ignis-docs` | Documentation site content |
|
|
41
41
|
|
|
42
42
|
---
|
|
43
43
|
|
|
@@ -73,15 +73,12 @@ Ignis uses the following open-source libraries. We are grateful to the authors a
|
|
|
73
73
|
| Library | License | Description |
|
|
74
74
|
|---------|---------|-------------|
|
|
75
75
|
| [reflect-metadata](https://github.com/rbuckton/reflect-metadata) | Apache-2.0 | Metadata reflection API |
|
|
76
|
-
| [glob](https://github.com/isaacs/node-glob) | ISC | File pattern matching (used by boot) |
|
|
77
76
|
|
|
78
77
|
### Documentation Dependencies
|
|
79
78
|
|
|
80
79
|
| Library | License | Description |
|
|
81
80
|
|---------|---------|-------------|
|
|
82
81
|
| [VitePress](https://github.com/vuejs/vitepress) | MIT | Static site generator |
|
|
83
|
-
| [Fuse.js](https://github.com/krisk/fuse) | Apache-2.0 | Fuzzy search library |
|
|
84
|
-
| [gray-matter](https://github.com/jonschlinkert/gray-matter) | MIT | Front-matter parser |
|
|
85
82
|
|
|
86
83
|
---
|
|
87
84
|
|
package/README.md
CHANGED
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
BaseRestController,
|
|
39
39
|
controller,
|
|
40
40
|
get,
|
|
41
|
-
|
|
41
|
+
OpenApiResponses,
|
|
42
42
|
} from '@venizia/ignis';
|
|
43
43
|
import type { Context } from 'hono';
|
|
44
44
|
|
|
@@ -53,7 +53,7 @@ class HelloController extends BaseRestController {
|
|
|
53
53
|
@get({
|
|
54
54
|
configs: {
|
|
55
55
|
path: '/',
|
|
56
|
-
responses: jsonResponse({ schema: z.object({ message: z.string() }) }),
|
|
56
|
+
responses: OpenApiResponses.jsonResponse({ schema: z.object({ message: z.string() }) }),
|
|
57
57
|
},
|
|
58
58
|
})
|
|
59
59
|
sayHello(context: Context) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../src/base/applications/base.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,KAAK,EACV,mBAAmB,EAEnB,cAAc,EACd,oBAAoB,EACrB,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../../src/base/applications/base.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,OAAO,EAAE,M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EAAE;QAAE,KAAK,EAAE,mBAAmB,CAAA;KAAE,GAAG,OAAO;IAQlF,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAkB3C,MAAM,CAAC,IAAI,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE;IAiBtD;;;;OAIG;IACH,SAAS,CAAC,gBAAgB,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE;IAgClD,kGAAkG;cAC/E,oBAAoB,IAAI,kBAAkB;IAO7D,gKAAgK;cACvI,0BAA0B;IA4BnD,8MAA8M;IAC9M,SAAS,CAAC,YAAY;IAmDtB;;;OAGG;IACY,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;cAKvB,eAAe,IAAI,iBAAiB,EAAE;IAyCzD;;;OAGG;IACH,SAAS,CAAC,0BAA0B,IAAI,IAAI;CAK7C"}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ScopeFilterUtility } from '@venizia/ignis-connectors';
|
|
2
2
|
import { ControllerTransports } from '@venizia/ignis-kernel';
|
|
3
3
|
import { BindingNamespaces, CoreBindings } from '@venizia/ignis-kernel';
|
|
4
4
|
import { EnvironmentKeys } from '../../common/environments.js';
|
|
5
5
|
import { RequestTrackerComponent } from '../../components/index.js';
|
|
6
6
|
import { GrpcComponent } from '../../components/controller/grpc/index.js';
|
|
7
7
|
import { BindingScopes, BindingValueTypes, BootSequence, MetadataRegistry, RequestContextRegistry, } from '@venizia/ignis-kernel';
|
|
8
|
-
import {
|
|
9
|
-
import { HTTP,
|
|
10
|
-
import { applicationEnvironment,
|
|
8
|
+
import { ParseUtility, getError } from '@venizia/ignis-helpers/core';
|
|
9
|
+
import { HTTP, ObjectUtility } from '@venizia/ignis-helpers/common';
|
|
10
|
+
import { applicationEnvironment, SecretsHelperFactory, PerformanceUtility, Environment, SecretProviders, } from '@venizia/ignis-helpers';
|
|
11
11
|
import { contextStorage, tryGetContext } from 'hono/context-storage';
|
|
12
|
-
import { AppErrorMiddleware,
|
|
12
|
+
import { AppErrorMiddleware, EmojiFaviconMiddleware } from '../middlewares/index.js';
|
|
13
13
|
import { serveStatic } from 'hono/bun';
|
|
14
|
+
import { ServerLoggerStartup } from './common/index.js';
|
|
14
15
|
import { ServerBootSteps } from './boot-steps.js';
|
|
15
16
|
import { ServerApplication } from './server.js';
|
|
16
17
|
/** Maps a secret bundle to env names: the explicit `keys` mapping when present, otherwise every bundle key under `prefix`. */
|
|
@@ -42,7 +43,7 @@ export class BaseApplication extends ServerApplication {
|
|
|
42
43
|
/** Adds the gRPC branch the kernel cannot own: `GrpcComponent` needs `AbstractGrpcController`, core-only code that reaches `node:module`. */
|
|
43
44
|
async registerControllers() {
|
|
44
45
|
await super.registerControllers();
|
|
45
|
-
await
|
|
46
|
+
await PerformanceUtility.executeWithMeasure({
|
|
46
47
|
logger: this.logger,
|
|
47
48
|
description: 'Register application gRPC controllers',
|
|
48
49
|
scope: this.registerControllers.name,
|
|
@@ -91,7 +92,7 @@ export class BaseApplication extends ServerApplication {
|
|
|
91
92
|
let provider;
|
|
92
93
|
const emptyHydrations = [];
|
|
93
94
|
try {
|
|
94
|
-
const result = await
|
|
95
|
+
const result = await SecretsHelperFactory.create({ ...registration, identifier: 'app' });
|
|
95
96
|
provider = result;
|
|
96
97
|
await provider.configure();
|
|
97
98
|
await this.hydrateSecretEntries({ provider, registration, emptyHydrations, logger });
|
|
@@ -109,11 +110,14 @@ export class BaseApplication extends ServerApplication {
|
|
|
109
110
|
}
|
|
110
111
|
logger.warn('Secret provider failed; falling back to system-envs | env: %s | error: %s', env, error);
|
|
111
112
|
if (provider) {
|
|
112
|
-
|
|
113
|
-
.shutdown()
|
|
114
|
-
|
|
113
|
+
try {
|
|
114
|
+
await provider.shutdown();
|
|
115
|
+
}
|
|
116
|
+
catch (shutdownError) {
|
|
117
|
+
logger.error('Failed to shut down partially-built provider during fallback | error: %s', shutdownError);
|
|
118
|
+
}
|
|
115
119
|
}
|
|
116
|
-
const result2 = await
|
|
120
|
+
const result2 = await SecretsHelperFactory.create({
|
|
117
121
|
provider: SecretProviders.SYSTEM_ENVS,
|
|
118
122
|
identifier: 'app',
|
|
119
123
|
});
|
|
@@ -206,7 +210,7 @@ export class BaseApplication extends ServerApplication {
|
|
|
206
210
|
*/
|
|
207
211
|
printStartUpInfo(opts) {
|
|
208
212
|
const { scope } = opts;
|
|
209
|
-
const read = (key, fallback) => blankToUndefined(process.env[key]) ?? fallback;
|
|
213
|
+
const read = (key, fallback) => ParseUtility.blankToUndefined({ input: process.env[key] }) ?? fallback;
|
|
210
214
|
const divider = '------------------------------------------------------------------------';
|
|
211
215
|
this.logger.for(scope).info(divider);
|
|
212
216
|
this.logger
|
|
@@ -233,7 +237,7 @@ export class BaseApplication extends ServerApplication {
|
|
|
233
237
|
}
|
|
234
238
|
/** Adds what only a listening server has, on top of the kernel's three - which stay in `RestApplication` so a browser Worker answers with the same envelope. */
|
|
235
239
|
async registerDefaultMiddlewares() {
|
|
236
|
-
await
|
|
240
|
+
await PerformanceUtility.executeWithMeasure({
|
|
237
241
|
logger: this.logger,
|
|
238
242
|
scope: this.registerDefaultMiddlewares.name,
|
|
239
243
|
description: 'Register default application server handler',
|
|
@@ -250,7 +254,7 @@ export class BaseApplication extends ServerApplication {
|
|
|
250
254
|
// Request-body parsing and the access log; the request id it reads is already installed
|
|
251
255
|
// above (also works around the Bun + Hono body-parsing bug: https://github.com/honojs/middleware/issues/81).
|
|
252
256
|
this.component(RequestTrackerComponent);
|
|
253
|
-
server.use(
|
|
257
|
+
server.use(EmojiFaviconMiddleware.create({ icon: this.configs.favicon ?? '🔥' }));
|
|
254
258
|
},
|
|
255
259
|
});
|
|
256
260
|
}
|
|
@@ -263,8 +267,8 @@ export class BaseApplication extends ServerApplication {
|
|
|
263
267
|
// reader rather than helping it. Set ALLOW_EMPTY_ENV_VALUE to `false` or `0` to turn the check
|
|
264
268
|
// on. Read once rather than per key, and a blank value reads as unset - the same rule every
|
|
265
269
|
// other env read follows.
|
|
266
|
-
const configured = blankToUndefined(process.env.ALLOW_EMPTY_ENV_VALUE);
|
|
267
|
-
const allowsEmpty = configured === undefined || toBoolean(configured);
|
|
270
|
+
const configured = ParseUtility.blankToUndefined({ input: process.env.ALLOW_EMPTY_ENV_VALUE });
|
|
271
|
+
const allowsEmpty = configured === undefined || ParseUtility.toBoolean({ input: configured });
|
|
268
272
|
this.logger
|
|
269
273
|
.for(this.initialize.name)
|
|
270
274
|
.info('Envs: %s | START Validating application environments | Empty values: %s', envKeys.length, allowsEmpty ? 'ALLOWED (default)' : 'REJECTED');
|
|
@@ -276,7 +280,7 @@ export class BaseApplication extends ServerApplication {
|
|
|
276
280
|
}
|
|
277
281
|
for (const argKey of envKeys) {
|
|
278
282
|
const argValue = applicationEnvironment.get(argKey);
|
|
279
|
-
if (!isEmpty({ value: argValue })) {
|
|
283
|
+
if (!ObjectUtility.isEmpty({ value: argValue })) {
|
|
280
284
|
continue;
|
|
281
285
|
}
|
|
282
286
|
throw getError({
|
|
@@ -292,6 +296,7 @@ export class BaseApplication extends ServerApplication {
|
|
|
292
296
|
* `getBootSequence()`/`runBootSequence()` throws here before any socket binds.
|
|
293
297
|
*/
|
|
294
298
|
async initialize() {
|
|
299
|
+
await ServerLoggerStartup.selectDefault();
|
|
295
300
|
await this.runBootSequence({ steps: this.getBootSequence() });
|
|
296
301
|
}
|
|
297
302
|
getBootSequence() {
|
|
@@ -336,7 +341,9 @@ export class BaseApplication extends ServerApplication {
|
|
|
336
341
|
* silent at runtime and opposite: a search-backed model returns too many rows, a context-less one none.
|
|
337
342
|
*/
|
|
338
343
|
validateScopeFilterSupport() {
|
|
339
|
-
assertScopeFilterSupported({
|
|
344
|
+
ScopeFilterUtility.assertScopeFilterSupported({
|
|
345
|
+
asyncContextEnabled: this.configs.asyncContext?.enable ?? false,
|
|
346
|
+
});
|
|
340
347
|
}
|
|
341
348
|
}
|
|
342
349
|
//# sourceMappingURL=base.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../src/base/applications/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAS/B,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAC9D,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,WAAW,EACX,6BAA6B,EAC7B,eAAe,EACf,SAAS,GACV,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAI7C,8HAA8H;AAC9H,MAAM,mBAAmB,GAAG,CAAC,IAG5B,EAA0B,EAAE;IAC3B,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;IAC/B,MAAM,MAAM,GAA2B,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AE,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE;YACvE;gBACE,IAAI,EAAE,eAAe,CAAC,4BAA4B;gBAClD,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,0BAA0B,EAAE;aAC7C;YACD,GAAG,KAAK,CAAC,eAAe,EAAE;SAC3B,CAAC;QAEF,MAAM,WAAW,GAAG,YAAY,CAAC,WAAW,CAAC;YAC3C,KAAK;YACL,MAAM,EAAE,eAAe,CAAC,aAAa;YACrC,IAAI,EAAE,EAAE,IAAI,EAAE,eAAe,CAAC,eAAe,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE;SAClF,CAAC,CAAC;QAEH,+FAA+F;QAC/F,iGAAiG;QACjG,MAAM,cAAc,GAAG,YAAY,CAAC,WAAW,CAAC;YAC9C,KAAK,EAAE,WAAW;YAClB,MAAM,EAAE,eAAe,CAAC,iCAAiC;YACzD,IAAI,EAAE;gBACJ,IAAI,EAAE,eAAe,CAAC,sBAAsB;gBAC5C,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,oBAAoB,EAAE;aACvC;SACF,CAAC,CAAC;QAEH,OAAO;YACL,GAAG,cAAc;YACjB,6DAA6D;YAC7D;gBACE,IAAI,EAAE,eAAe,CAAC,6BAA6B;gBACnD,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,0BAA0B,EAAE;aAC7C;SACF,CAAC;IACJ,CAAC;IAED;;;OAGG;IACO,0BAA0B;QAClC,0BAA0B,CAAC,EAAE,mBAAmB,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,IAAI,KAAK,EAAE,CAAC,CAAC;IAClG,CAAC;CACF","sourcesContent":["import { assertScopeFilterSupported } from '@venizia/ignis-connectors';\nimport { ControllerTransports } from '@venizia/ignis-kernel';\nimport { BindingNamespaces, CoreBindings } from '@venizia/ignis-kernel';\nimport { EnvironmentKeys } from '@/common/environments';\nimport { RequestTrackerComponent } from '@/components';\nimport { GrpcComponent } from '@/components/controller/grpc';\nimport {\n BindingScopes,\n BindingValueTypes,\n BootSequence,\n MetadataRegistry,\n RequestContextRegistry,\n} from '@venizia/ignis-kernel';\nimport type { ILogger } from '@venizia/ignis-helpers/core';\nimport type { ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport type {\n ISecretHydrateEntry,\n ISecretRotatable,\n ISecretsHelper,\n ISecretsRegistration,\n} from '@venizia/ignis-helpers';\nimport { blankToUndefined, getError } from '@venizia/ignis-helpers/core';\nimport { HTTP, isEmpty } from '@venizia/ignis-helpers/common';\nimport {\n applicationEnvironment,\n createSecretsHelper,\n Environment,\n executeWithPerformanceMeasure,\n SecretProviders,\n toBoolean,\n} from '@venizia/ignis-helpers';\nimport { contextStorage, tryGetContext } from 'hono/context-storage';\nimport { AppErrorMiddleware, emojiFavicon } from '../middlewares';\nimport { serveStatic } from 'hono/bun';\nimport { ServerBootSteps } from './boot-steps';\nimport { ServerApplication } from './server';\nimport type { IRestApplication } from '@venizia/ignis-kernel';\nimport type { IBootSequenceStep } from '@venizia/ignis-kernel';\n\n/** Maps a secret bundle to env names: the explicit `keys` mapping when present, otherwise every bundle key under `prefix`. */\nconst selectSecretEnvKeys = (opts: {\n bundle: Record<string, string>;\n entry: ISecretHydrateEntry;\n}): Record<string, string> => {\n const { bundle, entry } = opts;\n const merged: Record<string, string> = {};\n\n if (!entry.keys) {\n const bundleEntries = Object.entries(bundle);\n for (const [rawKey, value] of bundleEntries) {\n merged[`${entry.prefix ?? ''}${rawKey}`] = value;\n }\n\n return merged;\n }\n\n const entryKeysEntries = Object.entries(entry.keys);\n for (const [rawKey, envKey] of entryKeysEntries) {\n const value = bundle[rawKey];\n if (value === undefined) {\n continue;\n }\n\n merged[envKey] = value;\n }\n\n return merged;\n};\n\nexport abstract class BaseApplication extends ServerApplication implements IRestApplication {\n protected secretsProvider?: ISecretsHelper;\n protected secretsRegistration?: ISecretsRegistration;\n\n protected normalizePath(...segments: string[]): string {\n const joined = segments.join('/').replace(/\\/+/g, '/').replace(/\\/$/, '');\n return joined || '/';\n }\n\n /** Adds the gRPC branch the kernel cannot own: `GrpcComponent` needs `AbstractGrpcController`, core-only code that reaches `node:module`. */\n override async registerControllers(): Promise<void> {\n await super.registerControllers();\n\n await executeWithPerformanceMeasure({\n logger: this.logger,\n description: 'Register application gRPC controllers',\n scope: this.registerControllers.name,\n task: async () => {\n const transports = this.configs.transports ?? [ControllerTransports.REST];\n\n for (const transport of transports) {\n if (transport === ControllerTransports.REST) {\n continue;\n }\n\n if (transport !== ControllerTransports.GRPC) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: `[registerControllers] Unsupported transport: '${transport}'`,\n });\n }\n\n const grpcComponent = new GrpcComponent(this);\n await grpcComponent.configure();\n }\n\n // Warn if gRPC controllers exist but gRPC transport is not enabled\n if (transports.includes(ControllerTransports.GRPC)) {\n return;\n }\n\n const allBindings = this.findByTag({ tag: BindingNamespaces.CONTROLLER });\n for (const binding of allBindings) {\n const target = binding.getBindingMeta({ type: BindingValueTypes.CLASS });\n if (!target) {\n continue;\n }\n\n const metadata = MetadataRegistry.getInstance().getControllerMetadata({ target });\n if (metadata?.transport !== ControllerTransports.GRPC) {\n continue;\n }\n\n this.logger\n .for(this.registerControllers.name)\n .error(\n 'gRPC controller \"%s\" discovered but gRPC transport is not enabled. Add \"%s\" to transports config.',\n binding.key,\n ControllerTransports.GRPC,\n );\n }\n },\n });\n }\n\n registerSecrets(): ValueOrPromise<ISecretsRegistration> {\n return { provider: SecretProviders.SYSTEM_ENVS };\n }\n\n async hydrateSecrets(): Promise<void> {\n const logger = this.logger.for(this.hydrateSecrets.name);\n const registration = await this.registerSecrets();\n\n let provider: ISecretsHelper | undefined;\n const emptyHydrations: string[] = [];\n try {\n const result = await createSecretsHelper({ ...registration, identifier: 'app' });\n provider = result;\n await provider.configure();\n\n await this.hydrateSecretEntries({ provider, registration, emptyHydrations, logger });\n\n const registrationLease = registration.lease ?? [];\n for (const entry of registrationLease) {\n await provider.lease({ path: entry.path, key: entry.key });\n }\n } catch (error) {\n const env = Environment.current;\n if (!Environment.DEVELOPMENT_ENVS.has(env.toLowerCase())) {\n throw getError({\n message: `[hydrateSecrets] Secret provider failed in non-development environment | env: ${env}`,\n });\n }\n logger.warn(\n 'Secret provider failed; falling back to system-envs | env: %s | error: %s',\n env,\n error,\n );\n\n if (provider) {\n await provider\n .shutdown()\n .catch((shutdownError) =>\n logger.error(\n 'Failed to shut down partially-built provider during fallback | error: %s',\n shutdownError,\n ),\n );\n }\n const result2 = await createSecretsHelper({\n provider: SecretProviders.SYSTEM_ENVS,\n identifier: 'app',\n });\n provider = result2;\n }\n\n if (!provider) {\n throw getError({ message: '[hydrateSecrets] No secrets provider resolved' });\n }\n\n if (emptyHydrations.length > 0) {\n const env = Environment.current;\n if (!Environment.DEVELOPMENT_ENVS.has(env.toLowerCase())) {\n throw getError({\n message: `[hydrateSecrets] Hydrate entries resolved to an empty secret bundle in non-development environment | env: ${env} | paths: ${emptyHydrations.join(', ')}`,\n });\n }\n logger.warn(\n 'Hydrate entries resolved to an empty secret bundle; continuing in development | env: %s | paths: %s',\n env,\n emptyHydrations.join(', '),\n );\n }\n\n this.bind<ISecretsHelper>({ key: CoreBindings.APPLICATION_CONFIG })\n .toProvider(() => provider)\n .setScope(BindingScopes.SINGLETON);\n\n this.registerPostStopHook({ identifier: 'secrets.shutdown', hook: () => provider.shutdown() });\n this.secretsProvider = provider;\n this.secretsRegistration = registration;\n }\n\n /** Applies each hydrate entry in declaration order; paths that resolve empty while declaring an expectation are collected in `emptyHydrations` rather than failing here. */\n protected async hydrateSecretEntries(opts: {\n provider: ISecretsHelper;\n registration: ISecretsRegistration;\n emptyHydrations: string[];\n logger: ILogger;\n }): Promise<void> {\n const { provider, registration, emptyHydrations, logger } = opts;\n\n const registrationHydrate = registration.hydrate ?? [];\n for (const entry of registrationHydrate) {\n const bundle = await provider.getBundle({ path: entry.path });\n const merged = this.mergeSecretsIntoEnv({ bundle, entry });\n if (Object.keys(merged).length > 0) {\n continue;\n }\n\n if (this.hydrateEntryDeclaresExpectation({ entry })) {\n emptyHydrations.push(entry.path);\n continue;\n }\n\n logger.warn(\n 'Hydrate entry resolved to an empty bundle and declares no expected keys | path: %s',\n entry.path,\n );\n }\n }\n\n protected mergeSecretsIntoEnv(opts: {\n bundle: Record<string, string>;\n entry: ISecretHydrateEntry;\n }): Record<string, string> {\n const { bundle, entry } = opts;\n const merged = selectSecretEnvKeys({ bundle, entry });\n\n const mergedEntries = Object.entries(merged);\n for (const [key, value] of mergedEntries) {\n process.env[key] = value;\n }\n applicationEnvironment.merge({ envs: merged });\n return merged;\n }\n\n /** A hydrate entry declares an expectation only via explicit `keys` or a non-empty `prefix`; such an entry resolving to zero env values is a misconfiguration boot must not silently absorb. */\n protected hydrateEntryDeclaresExpectation(opts: { entry: ISecretHydrateEntry }): boolean {\n const { entry } = opts;\n if (entry.keys && Object.keys(entry.keys).length > 0) {\n return true;\n }\n return typeof entry.prefix === 'string' && entry.prefix.length > 0;\n }\n\n async wireSecretRotatables(): Promise<void> {\n const logger = this.logger.for(this.wireSecretRotatables.name);\n const provider = this.secretsProvider;\n const registration = this.secretsRegistration;\n if (!provider || !registration?.lease?.length) {\n return;\n }\n for (const entry of registration.lease) {\n const instance = this.get<ISecretRotatable>({ key: entry.key, isOptional: true });\n if (instance && typeof instance.onSecretRotated === 'function') {\n provider.registerRotatable({ key: entry.key, target: instance });\n logger.info('Wired rotatable | key: %s', entry.key);\n continue;\n }\n logger.debug('Lease key has no rotatable consumer | key: %s', entry.key);\n }\n }\n\n static(opts: { restPath?: string; folderPath: string }) {\n const { restPath = '*', folderPath } = opts;\n const server = this.getServer();\n\n server.use(restPath, serveStatic({ root: folderPath }));\n\n this.logger\n .for(this.static.name)\n .debug(\n 'Registered static files | runtime: %s | path: %s | folder: %s',\n this.runtime,\n restPath,\n folderPath,\n );\n return this;\n }\n\n /**\n * Every value is read HERE, not destructured at module load: an application that loads its\n * `.env` in its own entrypoint does so after this module is imported, and a module-load snapshot\n * would print the defaults for a host that configured everything correctly.\n */\n protected printStartUpInfo(opts: { scope: string }) {\n const { scope } = opts;\n const read = (key: string, fallback: string): string =>\n blankToUndefined(process.env[key]) ?? fallback;\n const divider = '------------------------------------------------------------------------';\n\n this.logger.for(scope).info(divider);\n this.logger\n .for(scope)\n .info(\n 'Starting application... | Name: %s | Env: %s | Runtime: %s',\n read(EnvironmentKeys.APP_ENV_APPLICATION_NAME, 'PNT'),\n Environment.ambient,\n this.runtime,\n );\n this.logger\n .for(scope)\n .info(\n 'AllowEmptyEnv: %s | Prefix: %s',\n read('ALLOW_EMPTY_ENV_VALUE', 'true'),\n read('APPLICATION_ENV_PREFIX', 'APP_ENV'),\n );\n this.logger.for(scope).info('RunMode: %s', process.env.RUN_MODE);\n this.logger\n .for(scope)\n .info('Timezone: %s', read(EnvironmentKeys.APP_ENV_APPLICATION_TIMEZONE, 'Asia/Ho_Chi_Minh'));\n this.logger\n .for(scope)\n .info('LogPath: %s', read(EnvironmentKeys.APP_ENV_LOGGER_FOLDER_PATH, './'));\n this.logger.for(scope).info(divider);\n }\n\n /** Swaps in the `ErrorPrettier`-backed formatter - `node:util`, so the kernel cannot build it. */\n protected override buildErrorMiddleware(): AppErrorMiddleware {\n return new AppErrorMiddleware({\n logger: this.logger,\n rootKey: this.configs.error?.rootKey ?? undefined,\n });\n }\n\n /** Adds what only a listening server has, on top of the kernel's three - which stay in `RestApplication` so a browser Worker answers with the same envelope. */\n protected override async registerDefaultMiddlewares() {\n await executeWithPerformanceMeasure({\n logger: this.logger,\n scope: this.registerDefaultMiddlewares.name,\n description: 'Register default application server handler',\n task: async () => {\n const server = this.getServer();\n\n await super.registerDefaultMiddlewares();\n\n // Always installed, not only under `asyncContext.enable`: `tryGetContext()` answers \"no context\"\n // without a store, and a `contextStorage()` the application registered itself stays visible to\n // the enrichers. Inside a method body because every package declares `sideEffects: false`.\n RequestContextRegistry.setResolver({ resolver: () => tryGetContext() });\n\n if (this.configs.asyncContext?.enable) {\n server.use(contextStorage());\n }\n\n // Request-body parsing and the access log; the request id it reads is already installed\n // above (also works around the Bun + Hono body-parsing bug: https://github.com/honojs/middleware/issues/81).\n this.component(RequestTrackerComponent);\n\n server.use(emojiFavicon({ icon: this.configs.favicon ?? '🔥' }));\n },\n });\n }\n\n /** Lives here rather than on `AbstractApplication` - `applicationEnvironment` reads `process.env` at module load, so a kernel-pure ancestor cannot carry it; this is the layer that already depends on it. */\n protected validateEnvs() {\n const t = performance.now();\n const envKeys = applicationEnvironment.keys();\n\n // Permissive by DEFAULT: a name a host leaves empty is the host's business, and an empty value\n // already falls back to `defaultValue` at read time, so refusing to boot over one fights the\n // reader rather than helping it. Set ALLOW_EMPTY_ENV_VALUE to `false` or `0` to turn the check\n // on. Read once rather than per key, and a blank value reads as unset - the same rule every\n // other env read follows.\n const configured = blankToUndefined(process.env.ALLOW_EMPTY_ENV_VALUE);\n const allowsEmpty = configured === undefined || toBoolean(configured);\n\n this.logger\n .for(this.initialize.name)\n .info(\n 'Envs: %s | START Validating application environments | Empty values: %s',\n envKeys.length,\n allowsEmpty ? 'ALLOWED (default)' : 'REJECTED',\n );\n\n if (allowsEmpty) {\n this.logger\n .for(this.validateEnvs.name)\n .info(\n 'Envs: %s | SKIPPED - set ALLOW_EMPTY_ENV_VALUE=false to reject empty values',\n envKeys.length,\n );\n return;\n }\n\n for (const argKey of envKeys) {\n const argValue = applicationEnvironment.get<string | number>(argKey);\n\n if (!isEmpty({ value: argValue })) {\n continue;\n }\n\n throw getError({\n message: `[validateEnvs] Invalid Application Environment! Key: ${argKey} | Value: ${argValue}`,\n });\n }\n\n this.logger\n .for(this.validateEnvs.name)\n .info(\n 'Envs: %s | DONE Validating application environments | Took: %s (ms)',\n envKeys.length,\n performance.now() - t,\n );\n }\n\n /**\n * Version tripwire, body identical to `RestApplication.initialize()`: a stale kernel without\n * `getBootSequence()`/`runBootSequence()` throws here before any socket binds.\n */\n override async initialize(): Promise<void> {\n await this.runBootSequence({ steps: this.getBootSequence() });\n }\n\n protected override getBootSequence(): IBootSequenceStep[] {\n const steps: IBootSequenceStep[] = [\n {\n name: ServerBootSteps.PRINT_START_UP_INFO,\n run: () => this.printStartUpInfo({ scope: this.initialize.name }),\n },\n { name: ServerBootSteps.VALIDATE_ENVS, run: () => this.validateEnvs() },\n {\n name: ServerBootSteps.REGISTER_DEFAULT_MIDDLEWARES,\n run: () => this.registerDefaultMiddlewares(),\n },\n ...super.getBootSequence(),\n ];\n\n const withHydrate = BootSequence.insertAfter({\n steps,\n target: ServerBootSteps.PRE_CONFIGURE,\n step: { name: ServerBootSteps.HYDRATE_SECRETS, run: () => this.hydrateSecrets() },\n });\n\n // Components can contribute datasources, so wire rotatables only after the contributed sweep -\n // a lease key pointing at a component-contributed datasource would otherwise resolve to nothing.\n const withRotatables = BootSequence.insertAfter({\n steps: withHydrate,\n target: ServerBootSteps.REGISTER_CONTRIBUTED_DATA_SOURCES,\n step: {\n name: ServerBootSteps.WIRE_SECRET_ROTATABLES,\n run: () => this.wireSecretRotatables(),\n },\n });\n\n return [\n ...withRotatables,\n // Last, so a model registered by a component is covered too.\n {\n name: ServerBootSteps.VALIDATE_SCOPE_FILTER_SUPPORT,\n run: () => this.validateScopeFilterSupport(),\n },\n ];\n }\n\n /**\n * Refuses to start when a model's `settings.access` cannot take effect. Both failures are\n * silent at runtime and opposite: a search-backed model returns too many rows, a context-less one none.\n */\n protected validateScopeFilterSupport(): void {\n assertScopeFilterSupported({ asyncContextEnabled: this.configs.asyncContext?.enable ?? false });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../../../src/base/applications/base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,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izia/ignis-kernel';\nimport { BindingNamespaces, CoreBindings } from '@venizia/ignis-kernel';\nimport { EnvironmentKeys } from '@/common/environments';\nimport { RequestTrackerComponent } from '@/components';\nimport { GrpcComponent } from '@/components/controller/grpc';\nimport {\n BindingScopes,\n BindingValueTypes,\n BootSequence,\n MetadataRegistry,\n RequestContextRegistry,\n} from '@venizia/ignis-kernel';\nimport type { ILogger } from '@venizia/ignis-helpers/core';\nimport type { ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport type {\n ISecretHydrateEntry,\n ISecretRotatable,\n ISecretsHelper,\n ISecretsRegistration,\n} from '@venizia/ignis-helpers';\nimport { ParseUtility, getError } from '@venizia/ignis-helpers/core';\nimport { HTTP, ObjectUtility } from '@venizia/ignis-helpers/common';\nimport {\n applicationEnvironment,\n SecretsHelperFactory,\n PerformanceUtility,\n Environment,\n SecretProviders,\n} from '@venizia/ignis-helpers';\nimport { contextStorage, tryGetContext } from 'hono/context-storage';\nimport { AppErrorMiddleware, EmojiFaviconMiddleware } from '../middlewares';\nimport { serveStatic } from 'hono/bun';\nimport { ServerLoggerStartup } from './common';\nimport { ServerBootSteps } from './boot-steps';\nimport { ServerApplication } from './server';\nimport type { IRestApplication } from '@venizia/ignis-kernel';\nimport type { IBootSequenceStep } from '@venizia/ignis-kernel';\n\n/** Maps a secret bundle to env names: the explicit `keys` mapping when present, otherwise every bundle key under `prefix`. */\nconst selectSecretEnvKeys = (opts: {\n bundle: Record<string, string>;\n entry: ISecretHydrateEntry;\n}): Record<string, string> => {\n const { bundle, entry } = opts;\n const merged: Record<string, string> = {};\n\n if (!entry.keys) {\n const bundleEntries = Object.entries(bundle);\n for (const [rawKey, value] of bundleEntries) {\n merged[`${entry.prefix ?? ''}${rawKey}`] = value;\n }\n\n return merged;\n }\n\n const entryKeysEntries = Object.entries(entry.keys);\n for (const [rawKey, envKey] of entryKeysEntries) {\n const value = bundle[rawKey];\n if (value === undefined) {\n continue;\n }\n\n merged[envKey] = value;\n }\n\n return merged;\n};\n\nexport abstract class BaseApplication extends ServerApplication implements IRestApplication {\n protected secretsProvider?: ISecretsHelper;\n protected secretsRegistration?: ISecretsRegistration;\n\n protected normalizePath(...segments: string[]): string {\n const joined = segments.join('/').replace(/\\/+/g, '/').replace(/\\/$/, '');\n return joined || '/';\n }\n\n /** Adds the gRPC branch the kernel cannot own: `GrpcComponent` needs `AbstractGrpcController`, core-only code that reaches `node:module`. */\n override async registerControllers(): Promise<void> {\n await super.registerControllers();\n\n await PerformanceUtility.executeWithMeasure({\n logger: this.logger,\n description: 'Register application gRPC controllers',\n scope: this.registerControllers.name,\n task: async () => {\n const transports = this.configs.transports ?? [ControllerTransports.REST];\n\n for (const transport of transports) {\n if (transport === ControllerTransports.REST) {\n continue;\n }\n\n if (transport !== ControllerTransports.GRPC) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: `[registerControllers] Unsupported transport: '${transport}'`,\n });\n }\n\n const grpcComponent = new GrpcComponent(this);\n await grpcComponent.configure();\n }\n\n // Warn if gRPC controllers exist but gRPC transport is not enabled\n if (transports.includes(ControllerTransports.GRPC)) {\n return;\n }\n\n const allBindings = this.findByTag({ tag: BindingNamespaces.CONTROLLER });\n for (const binding of allBindings) {\n const target = binding.getBindingMeta({ type: BindingValueTypes.CLASS });\n if (!target) {\n continue;\n }\n\n const metadata = MetadataRegistry.getInstance().getControllerMetadata({ target });\n if (metadata?.transport !== ControllerTransports.GRPC) {\n continue;\n }\n\n this.logger\n .for(this.registerControllers.name)\n .error(\n 'gRPC controller \"%s\" discovered but gRPC transport is not enabled. Add \"%s\" to transports config.',\n binding.key,\n ControllerTransports.GRPC,\n );\n }\n },\n });\n }\n\n registerSecrets(): ValueOrPromise<ISecretsRegistration> {\n return { provider: SecretProviders.SYSTEM_ENVS };\n }\n\n async hydrateSecrets(): Promise<void> {\n const logger = this.logger.for(this.hydrateSecrets.name);\n const registration = await this.registerSecrets();\n\n let provider: ISecretsHelper | undefined;\n const emptyHydrations: string[] = [];\n try {\n const result = await SecretsHelperFactory.create({ ...registration, identifier: 'app' });\n provider = result;\n await provider.configure();\n\n await this.hydrateSecretEntries({ provider, registration, emptyHydrations, logger });\n\n const registrationLease = registration.lease ?? [];\n for (const entry of registrationLease) {\n await provider.lease({ path: entry.path, key: entry.key });\n }\n } catch (error) {\n const env = Environment.current;\n if (!Environment.DEVELOPMENT_ENVS.has(env.toLowerCase())) {\n throw getError({\n message: `[hydrateSecrets] Secret provider failed in non-development environment | env: ${env}`,\n });\n }\n logger.warn(\n 'Secret provider failed; falling back to system-envs | env: %s | error: %s',\n env,\n error,\n );\n\n if (provider) {\n try {\n await provider.shutdown();\n } catch (shutdownError) {\n logger.error(\n 'Failed to shut down partially-built provider during fallback | error: %s',\n shutdownError,\n );\n }\n }\n const result2 = await SecretsHelperFactory.create({\n provider: SecretProviders.SYSTEM_ENVS,\n identifier: 'app',\n });\n provider = result2;\n }\n\n if (!provider) {\n throw getError({ message: '[hydrateSecrets] No secrets provider resolved' });\n }\n\n if (emptyHydrations.length > 0) {\n const env = Environment.current;\n if (!Environment.DEVELOPMENT_ENVS.has(env.toLowerCase())) {\n throw getError({\n message: `[hydrateSecrets] Hydrate entries resolved to an empty secret bundle in non-development environment | env: ${env} | paths: ${emptyHydrations.join(', ')}`,\n });\n }\n logger.warn(\n 'Hydrate entries resolved to an empty secret bundle; continuing in development | env: %s | paths: %s',\n env,\n emptyHydrations.join(', '),\n );\n }\n\n this.bind<ISecretsHelper>({ key: CoreBindings.APPLICATION_CONFIG })\n .toProvider(() => provider)\n .setScope(BindingScopes.SINGLETON);\n\n this.registerPostStopHook({ identifier: 'secrets.shutdown', hook: () => provider.shutdown() });\n this.secretsProvider = provider;\n this.secretsRegistration = registration;\n }\n\n /** Applies each hydrate entry in declaration order; paths that resolve empty while declaring an expectation are collected in `emptyHydrations` rather than failing here. */\n protected async hydrateSecretEntries(opts: {\n provider: ISecretsHelper;\n registration: ISecretsRegistration;\n emptyHydrations: string[];\n logger: ILogger;\n }): Promise<void> {\n const { provider, registration, emptyHydrations, logger } = opts;\n\n const registrationHydrate = registration.hydrate ?? [];\n for (const entry of registrationHydrate) {\n const bundle = await provider.getBundle({ path: entry.path });\n const merged = this.mergeSecretsIntoEnv({ bundle, entry });\n if (Object.keys(merged).length > 0) {\n continue;\n }\n\n if (this.hydrateEntryDeclaresExpectation({ entry })) {\n emptyHydrations.push(entry.path);\n continue;\n }\n\n logger.warn(\n 'Hydrate entry resolved to an empty bundle and declares no expected keys | path: %s',\n entry.path,\n );\n }\n }\n\n protected mergeSecretsIntoEnv(opts: {\n bundle: Record<string, string>;\n entry: ISecretHydrateEntry;\n }): Record<string, string> {\n const { bundle, entry } = opts;\n const merged = selectSecretEnvKeys({ bundle, entry });\n\n const mergedEntries = Object.entries(merged);\n for (const [key, value] of mergedEntries) {\n process.env[key] = value;\n }\n applicationEnvironment.merge({ envs: merged });\n return merged;\n }\n\n /** A hydrate entry declares an expectation only via explicit `keys` or a non-empty `prefix`; such an entry resolving to zero env values is a misconfiguration boot must not silently absorb. */\n protected hydrateEntryDeclaresExpectation(opts: { entry: ISecretHydrateEntry }): boolean {\n const { entry } = opts;\n if (entry.keys && Object.keys(entry.keys).length > 0) {\n return true;\n }\n return typeof entry.prefix === 'string' && entry.prefix.length > 0;\n }\n\n async wireSecretRotatables(): Promise<void> {\n const logger = this.logger.for(this.wireSecretRotatables.name);\n const provider = this.secretsProvider;\n const registration = this.secretsRegistration;\n if (!provider || !registration?.lease?.length) {\n return;\n }\n for (const entry of registration.lease) {\n const instance = this.get<ISecretRotatable>({ key: entry.key, isOptional: true });\n if (instance && typeof instance.onSecretRotated === 'function') {\n provider.registerRotatable({ key: entry.key, target: instance });\n logger.info('Wired rotatable | key: %s', entry.key);\n continue;\n }\n logger.debug('Lease key has no rotatable consumer | key: %s', entry.key);\n }\n }\n\n static(opts: { restPath?: string; folderPath: string }) {\n const { restPath = '*', folderPath } = opts;\n const server = this.getServer();\n\n server.use(restPath, serveStatic({ root: folderPath }));\n\n this.logger\n .for(this.static.name)\n .debug(\n 'Registered static files | runtime: %s | path: %s | folder: %s',\n this.runtime,\n restPath,\n folderPath,\n );\n return this;\n }\n\n /**\n * Every value is read HERE, not destructured at module load: an application that loads its\n * `.env` in its own entrypoint does so after this module is imported, and a module-load snapshot\n * would print the defaults for a host that configured everything correctly.\n */\n protected printStartUpInfo(opts: { scope: string }) {\n const { scope } = opts;\n const read = (key: string, fallback: string): string =>\n ParseUtility.blankToUndefined({ input: process.env[key] }) ?? fallback;\n const divider = '------------------------------------------------------------------------';\n\n this.logger.for(scope).info(divider);\n this.logger\n .for(scope)\n .info(\n 'Starting application... | Name: %s | Env: %s | Runtime: %s',\n read(EnvironmentKeys.APP_ENV_APPLICATION_NAME, 'PNT'),\n Environment.ambient,\n this.runtime,\n );\n this.logger\n .for(scope)\n .info(\n 'AllowEmptyEnv: %s | Prefix: %s',\n read('ALLOW_EMPTY_ENV_VALUE', 'true'),\n read('APPLICATION_ENV_PREFIX', 'APP_ENV'),\n );\n this.logger.for(scope).info('RunMode: %s', process.env.RUN_MODE);\n this.logger\n .for(scope)\n .info('Timezone: %s', read(EnvironmentKeys.APP_ENV_APPLICATION_TIMEZONE, 'Asia/Ho_Chi_Minh'));\n this.logger\n .for(scope)\n .info('LogPath: %s', read(EnvironmentKeys.APP_ENV_LOGGER_FOLDER_PATH, './'));\n this.logger.for(scope).info(divider);\n }\n\n /** Swaps in the `ErrorPrettier`-backed formatter - `node:util`, so the kernel cannot build it. */\n protected override buildErrorMiddleware(): AppErrorMiddleware {\n return new AppErrorMiddleware({\n logger: this.logger,\n rootKey: this.configs.error?.rootKey ?? undefined,\n });\n }\n\n /** Adds what only a listening server has, on top of the kernel's three - which stay in `RestApplication` so a browser Worker answers with the same envelope. */\n protected override async registerDefaultMiddlewares() {\n await PerformanceUtility.executeWithMeasure({\n logger: this.logger,\n scope: this.registerDefaultMiddlewares.name,\n description: 'Register default application server handler',\n task: async () => {\n const server = this.getServer();\n\n await super.registerDefaultMiddlewares();\n\n // Always installed, not only under `asyncContext.enable`: `tryGetContext()` answers \"no context\"\n // without a store, and a `contextStorage()` the application registered itself stays visible to\n // the enrichers. Inside a method body because every package declares `sideEffects: false`.\n RequestContextRegistry.setResolver({ resolver: () => tryGetContext() });\n\n if (this.configs.asyncContext?.enable) {\n server.use(contextStorage());\n }\n\n // Request-body parsing and the access log; the request id it reads is already installed\n // above (also works around the Bun + Hono body-parsing bug: https://github.com/honojs/middleware/issues/81).\n this.component(RequestTrackerComponent);\n\n server.use(EmojiFaviconMiddleware.create({ icon: this.configs.favicon ?? '🔥' }));\n },\n });\n }\n\n /** Lives here rather than on `AbstractApplication` - `applicationEnvironment` reads `process.env` at module load, so a kernel-pure ancestor cannot carry it; this is the layer that already depends on it. */\n protected validateEnvs() {\n const t = performance.now();\n const envKeys = applicationEnvironment.keys();\n\n // Permissive by DEFAULT: a name a host leaves empty is the host's business, and an empty value\n // already falls back to `defaultValue` at read time, so refusing to boot over one fights the\n // reader rather than helping it. Set ALLOW_EMPTY_ENV_VALUE to `false` or `0` to turn the check\n // on. Read once rather than per key, and a blank value reads as unset - the same rule every\n // other env read follows.\n const configured = ParseUtility.blankToUndefined({ input: process.env.ALLOW_EMPTY_ENV_VALUE });\n const allowsEmpty = configured === undefined || ParseUtility.toBoolean({ input: configured });\n\n this.logger\n .for(this.initialize.name)\n .info(\n 'Envs: %s | START Validating application environments | Empty values: %s',\n envKeys.length,\n allowsEmpty ? 'ALLOWED (default)' : 'REJECTED',\n );\n\n if (allowsEmpty) {\n this.logger\n .for(this.validateEnvs.name)\n .info(\n 'Envs: %s | SKIPPED - set ALLOW_EMPTY_ENV_VALUE=false to reject empty values',\n envKeys.length,\n );\n return;\n }\n\n for (const argKey of envKeys) {\n const argValue = applicationEnvironment.get<string | number>(argKey);\n\n if (!ObjectUtility.isEmpty({ value: argValue })) {\n continue;\n }\n\n throw getError({\n message: `[validateEnvs] Invalid Application Environment! Key: ${argKey} | Value: ${argValue}`,\n });\n }\n\n this.logger\n .for(this.validateEnvs.name)\n .info(\n 'Envs: %s | DONE Validating application environments | Took: %s (ms)',\n envKeys.length,\n performance.now() - t,\n );\n }\n\n /**\n * Version tripwire, body identical to `RestApplication.initialize()`: a stale kernel without\n * `getBootSequence()`/`runBootSequence()` throws here before any socket binds.\n */\n override async initialize(): Promise<void> {\n await ServerLoggerStartup.selectDefault();\n await this.runBootSequence({ steps: this.getBootSequence() });\n }\n\n protected override getBootSequence(): IBootSequenceStep[] {\n const steps: IBootSequenceStep[] = [\n {\n name: ServerBootSteps.PRINT_START_UP_INFO,\n run: () => this.printStartUpInfo({ scope: this.initialize.name }),\n },\n { name: ServerBootSteps.VALIDATE_ENVS, run: () => this.validateEnvs() },\n {\n name: ServerBootSteps.REGISTER_DEFAULT_MIDDLEWARES,\n run: () => this.registerDefaultMiddlewares(),\n },\n ...super.getBootSequence(),\n ];\n\n const withHydrate = BootSequence.insertAfter({\n steps,\n target: ServerBootSteps.PRE_CONFIGURE,\n step: { name: ServerBootSteps.HYDRATE_SECRETS, run: () => this.hydrateSecrets() },\n });\n\n // Components can contribute datasources, so wire rotatables only after the contributed sweep -\n // a lease key pointing at a component-contributed datasource would otherwise resolve to nothing.\n const withRotatables = BootSequence.insertAfter({\n steps: withHydrate,\n target: ServerBootSteps.REGISTER_CONTRIBUTED_DATA_SOURCES,\n step: {\n name: ServerBootSteps.WIRE_SECRET_ROTATABLES,\n run: () => this.wireSecretRotatables(),\n },\n });\n\n return [\n ...withRotatables,\n // Last, so a model registered by a component is covered too.\n {\n name: ServerBootSteps.VALIDATE_SCOPE_FILTER_SUPPORT,\n run: () => this.validateScopeFilterSupport(),\n },\n ];\n }\n\n /**\n * Refuses to start when a model's `settings.access` cannot take effect. Both failures are\n * silent at runtime and opposite: a search-backed model returns too many rows, a context-less one none.\n */\n protected validateScopeFilterSupport(): void {\n ScopeFilterUtility.assertScopeFilterSupported({\n asyncContextEnabled: this.configs.asyncContext?.enable ?? false,\n });\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/base/applications/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/base/applications/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/base/applications/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC","sourcesContent":["export * from './types';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/base/applications/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC","sourcesContent":["export * from './types';\nexport * from './logger-startup';\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the server does about logging at startup: an application that chose a provider (`LoggerFactory.use`) keeps it;
|
|
3
|
+
* one that did not gets Winston, the server's logger, when it is installed. Without Winston (an optional peer of the
|
|
4
|
+
* helpers) the console stays, which is the default provider everywhere. Any other failure to load Winston (a broken
|
|
5
|
+
* install, a version mismatch) is reported once on the console: the application must not log to the console in
|
|
6
|
+
* production without a word.
|
|
7
|
+
*/
|
|
8
|
+
export declare class ServerLoggerStartup {
|
|
9
|
+
static selectDefault(): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=logger-startup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger-startup.d.ts","sourceRoot":"","sources":["../../../../../src/base/applications/common/logger-startup.ts"],"names":[],"mappings":"AAKA;;;;;;GAMG;AACH,qBAAa,mBAAmB;WACjB,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;CAoB5C"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { LoggerFactory } from '@venizia/ignis-helpers/core';
|
|
2
|
+
/** What a failed `import()` reports when the package is simply not installed. */
|
|
3
|
+
const MODULE_NOT_FOUND_CODES = new Set(['ERR_MODULE_NOT_FOUND', 'MODULE_NOT_FOUND']);
|
|
4
|
+
/**
|
|
5
|
+
* What the server does about logging at startup: an application that chose a provider (`LoggerFactory.use`) keeps it;
|
|
6
|
+
* one that did not gets Winston, the server's logger, when it is installed. Without Winston (an optional peer of the
|
|
7
|
+
* helpers) the console stays, which is the default provider everywhere. Any other failure to load Winston (a broken
|
|
8
|
+
* install, a version mismatch) is reported once on the console: the application must not log to the console in
|
|
9
|
+
* production without a word.
|
|
10
|
+
*/
|
|
11
|
+
export class ServerLoggerStartup {
|
|
12
|
+
static async selectDefault() {
|
|
13
|
+
if (LoggerFactory.isChosen()) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
try {
|
|
17
|
+
const { WinstonLogger } = await import('@venizia/ignis-helpers/winston');
|
|
18
|
+
LoggerFactory.useUnlessChosen({ provider: WinstonLogger });
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
const code = error?.code;
|
|
22
|
+
if (code !== undefined && MODULE_NOT_FOUND_CODES.has(code)) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
console.warn(`[ServerLoggerStartup] Winston could not be loaded, so the console stays the logger | cause: ${error instanceof Error ? error.message : String(error)}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=logger-startup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger-startup.js","sourceRoot":"","sources":["../../../../../src/base/applications/common/logger-startup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,iFAAiF;AACjF,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC,CAAC,sBAAsB,EAAE,kBAAkB,CAAC,CAAC,CAAC;AAErF;;;;;;GAMG;AACH,MAAM,OAAO,mBAAmB;IAC9B,MAAM,CAAC,KAAK,CAAC,aAAa;QACxB,IAAI,aAAa,CAAC,QAAQ,EAAE,EAAE,CAAC;YAC7B,OAAO;QACT,CAAC;QAED,IAAI,CAAC;YACH,MAAM,EAAE,aAAa,EAAE,GAAG,MAAM,MAAM,CAAC,gCAAgC,CAAC,CAAC;YACzE,aAAa,CAAC,eAAe,CAAC,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC,CAAC;QAC7D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,GAAI,KAAkC,EAAE,IAAI,CAAC;YAEvD,IAAI,IAAI,KAAK,SAAS,IAAI,sBAAsB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC3D,OAAO;YACT,CAAC;YAED,OAAO,CAAC,IAAI,CACV,+FAA+F,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CACxJ,CAAC;QACJ,CAAC;IACH,CAAC;CACF","sourcesContent":["import { LoggerFactory } from '@venizia/ignis-helpers/core';\n\n/** What a failed `import()` reports when the package is simply not installed. */\nconst MODULE_NOT_FOUND_CODES = new Set(['ERR_MODULE_NOT_FOUND', 'MODULE_NOT_FOUND']);\n\n/**\n * What the server does about logging at startup: an application that chose a provider (`LoggerFactory.use`) keeps it;\n * one that did not gets Winston, the server's logger, when it is installed. Without Winston (an optional peer of the\n * helpers) the console stays, which is the default provider everywhere. Any other failure to load Winston (a broken\n * install, a version mismatch) is reported once on the console: the application must not log to the console in\n * production without a word.\n */\nexport class ServerLoggerStartup {\n static async selectDefault(): Promise<void> {\n if (LoggerFactory.isChosen()) {\n return;\n }\n\n try {\n const { WinstonLogger } = await import('@venizia/ignis-helpers/winston');\n LoggerFactory.useUnlessChosen({ provider: WinstonLogger });\n } catch (error) {\n const code = (error as { code?: string } | null)?.code;\n\n if (code !== undefined && MODULE_NOT_FOUND_CODES.has(code)) {\n return;\n }\n\n console.warn(\n `[ServerLoggerStartup] Winston could not be loaded, so the console stays the logger | cause: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n }\n}\n"]}
|
|
@@ -11,15 +11,20 @@ export interface IRuntimeSnapshot {
|
|
|
11
11
|
otherName?: string;
|
|
12
12
|
otherVersion?: string;
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
/** The Bun-only guard: what the process runs on, and the refusal when it is not Bun 1.4 or later. */
|
|
15
|
+
export declare class BunRuntimeGuard {
|
|
16
|
+
/** Reads the runtime the process is on. */
|
|
17
|
+
static readSnapshot(): IRuntimeSnapshot;
|
|
18
|
+
private static describeRuntime;
|
|
19
|
+
/**
|
|
20
|
+
* IGNIS runs on Bun 1.4 or later, and nothing else. One refusal at the top of `start()`, before any
|
|
21
|
+
* hook, datasource or socket is touched, replaces a failure that would otherwise surface halfway
|
|
22
|
+
* through startup.
|
|
23
|
+
*/
|
|
24
|
+
static assert(opts?: {
|
|
25
|
+
runtime?: IRuntimeSnapshot;
|
|
26
|
+
}): void;
|
|
27
|
+
}
|
|
23
28
|
/** Adds the listening server (`Bun.serve`) on top of `RestApplication` - the only layer that touches a socket, so it is the layer that stays out of the browser-pure kernel. */
|
|
24
29
|
export declare abstract class ServerApplication<AppEnv extends Env = Env, AppSchema extends Schema = {}, BasePath extends string = '/'> extends RestApplication<AppEnv, AppSchema, BasePath> implements IServerApplication<AppEnv, AppSchema, BasePath> {
|
|
25
30
|
/** Which runtime is underneath, and the socket once one is bound. Both live here, not on `RestApplication`: a browser Worker has neither. `start()` refuses to run unless this is Bun. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../../src/base/applications/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAItE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAGxC,OAAO,KAAK,EACV,kBAAkB,EAClB,yBAAyB,EACzB,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,UAAU,CAAC;AAElB,gTAAgT;AAChT,MAAM,MAAM,kBAAkB,GAAG,UAAU,CAAC,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;AAI9D,oKAAoK;AACpK,MAAM,WAAW,gBAAgB;IAC/B,yCAAyC;IACzC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sGAAsG;IACtG,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../../src/base/applications/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAItE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAGxC,OAAO,KAAK,EACV,kBAAkB,EAClB,yBAAyB,EACzB,qBAAqB,EACrB,uBAAuB,EACxB,MAAM,UAAU,CAAC;AAElB,gTAAgT;AAChT,MAAM,MAAM,kBAAkB,GAAG,UAAU,CAAC,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC;AAI9D,oKAAoK;AACpK,MAAM,WAAW,gBAAgB;IAC/B,yCAAyC;IACzC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sGAAsG;IACtG,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,qGAAqG;AACrG,qBAAa,eAAe;IAC1B,2CAA2C;IAC3C,MAAM,CAAC,YAAY,IAAI,gBAAgB;IAQvC,OA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IAAI,GAAE,uBAA4B,GAAG,MAAM,IAAI;cAyEtD,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;CAY5C"}
|
|
@@ -5,35 +5,42 @@ import { RuntimeModules } from '@venizia/ignis-helpers/common';
|
|
|
5
5
|
import { existsSync } from 'node:fs';
|
|
6
6
|
import path from 'node:path';
|
|
7
7
|
const MINIMUM_BUN = { major: 1, minor: 4 };
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
* hook, datasource or socket is touched, replaces a failure that would otherwise surface halfway
|
|
23
|
-
* through startup.
|
|
24
|
-
*/
|
|
25
|
-
export const assertBunRuntime = (opts = {}) => {
|
|
26
|
-
const runtime = opts.runtime ?? readRuntimeSnapshot();
|
|
27
|
-
if (runtime.bunVersion !== undefined) {
|
|
28
|
-
const [major = 0, minor = 0] = runtime.bunVersion.split('.').map(Number);
|
|
29
|
-
if (major > MINIMUM_BUN.major || (major === MINIMUM_BUN.major && minor >= MINIMUM_BUN.minor)) {
|
|
30
|
-
return;
|
|
8
|
+
/** The Bun-only guard: what the process runs on, and the refusal when it is not Bun 1.4 or later. */
|
|
9
|
+
export class BunRuntimeGuard {
|
|
10
|
+
/** Reads the runtime the process is on. */
|
|
11
|
+
static readSnapshot() {
|
|
12
|
+
return {
|
|
13
|
+
bunVersion: RuntimeModules.isBun() ? Bun.version : undefined,
|
|
14
|
+
otherName: globalThis.process?.release?.name,
|
|
15
|
+
otherVersion: globalThis.process?.version,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
static describeRuntime(opts) {
|
|
19
|
+
const { bunVersion, otherName, otherVersion } = opts.runtime;
|
|
20
|
+
if (bunVersion !== undefined) {
|
|
21
|
+
return `bun ${bunVersion}`;
|
|
31
22
|
}
|
|
23
|
+
return otherName ? `${otherName} ${otherVersion ?? ''}`.trim() : 'an unknown runtime';
|
|
32
24
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
25
|
+
/**
|
|
26
|
+
* IGNIS runs on Bun 1.4 or later, and nothing else. One refusal at the top of `start()`, before any
|
|
27
|
+
* hook, datasource or socket is touched, replaces a failure that would otherwise surface halfway
|
|
28
|
+
* through startup.
|
|
29
|
+
*/
|
|
30
|
+
static assert(opts = {}) {
|
|
31
|
+
const runtime = opts.runtime ?? BunRuntimeGuard.readSnapshot();
|
|
32
|
+
if (runtime.bunVersion !== undefined) {
|
|
33
|
+
const [major = 0, minor = 0] = runtime.bunVersion.split('.').map(Number);
|
|
34
|
+
if (major > MINIMUM_BUN.major ||
|
|
35
|
+
(major === MINIMUM_BUN.major && minor >= MINIMUM_BUN.minor)) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
throw getError({
|
|
40
|
+
message: `IGNIS requires Bun >= ${MINIMUM_BUN.major}.${MINIMUM_BUN.minor} (running on ${BunRuntimeGuard.describeRuntime({ runtime })})`,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
37
44
|
const DEFAULT_SHUTDOWN_SIGNALS = ['SIGTERM', 'SIGINT'];
|
|
38
45
|
const DEFAULT_SHUTDOWN_TIMEOUT_MS = 15_000;
|
|
39
46
|
const DEFAULT_SERVER_HOST = 'localhost';
|
|
@@ -115,7 +122,7 @@ export class ServerApplication extends RestApplication {
|
|
|
115
122
|
}
|
|
116
123
|
/** What `start()` checks. A seam for the guard's test: the `Bun` global cannot be hidden from inside Bun. */
|
|
117
124
|
getRuntimeSnapshot() {
|
|
118
|
-
return
|
|
125
|
+
return BunRuntimeGuard.readSnapshot();
|
|
119
126
|
}
|
|
120
127
|
getServerInstance() {
|
|
121
128
|
return this.serverInstance;
|
|
@@ -147,7 +154,7 @@ export class ServerApplication extends RestApplication {
|
|
|
147
154
|
});
|
|
148
155
|
}
|
|
149
156
|
async start() {
|
|
150
|
-
|
|
157
|
+
BunRuntimeGuard.assert({ runtime: this.getRuntimeSnapshot() });
|
|
151
158
|
await this.initialize();
|
|
152
159
|
await this.setupMiddlewares();
|
|
153
160
|
const server = this.getServer();
|