@venizia/ignis 0.4.6 → 0.4.7-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +19 -15
- package/dist/esm/base/applications/base.js.map +1 -1
- 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/base/controllers/grpc/adapter.d.ts.map +1 -1
- package/dist/esm/base/controllers/grpc/adapter.js +5 -1
- package/dist/esm/base/controllers/grpc/adapter.js.map +1 -1
- package/dist/esm/base/middlewares/request-spy/request-spy.middleware.d.ts.map +1 -1
- package/dist/esm/base/middlewares/request-spy/request-spy.middleware.js +9 -3
- package/dist/esm/base/middlewares/request-spy/request-spy.middleware.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/api-reference/ui/scalar.d.ts.map +1 -1
- package/dist/esm/components/api-reference/ui/scalar.js +2 -1
- package/dist/esm/components/api-reference/ui/scalar.js.map +1 -1
- package/dist/esm/components/api-reference/ui/swagger.d.ts.map +1 -1
- package/dist/esm/components/api-reference/ui/swagger.js +2 -1
- package/dist/esm/components/api-reference/ui/swagger.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/authenticate/services/bearer/abstract.service.d.ts.map +1 -1
- package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.js +4 -2
- package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.js.map +1 -1
- package/dist/esm/components/auth/authenticate/services/service/signer.service.d.ts.map +1 -1
- package/dist/esm/components/auth/authenticate/services/service/signer.service.js +6 -4
- package/dist/esm/components/auth/authenticate/services/service/signer.service.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/authorize/adapters/scoped-casbin/adapter.d.ts.map +1 -1
- package/dist/esm/components/auth/authorize/adapters/scoped-casbin/adapter.js +6 -3
- package/dist/esm/components/auth/authorize/adapters/scoped-casbin/adapter.js.map +1 -1
- package/dist/esm/components/auth/authorize/enforcers/casbin-module.d.ts.map +1 -1
- package/dist/esm/components/auth/authorize/enforcers/casbin-module.js +2 -1
- package/dist/esm/components/auth/authorize/enforcers/casbin-module.js.map +1 -1
- package/dist/esm/components/auth/authorize/enforcers/casbin.enforcer.d.ts.map +1 -1
- package/dist/esm/components/auth/authorize/enforcers/casbin.enforcer.js +9 -3
- package/dist/esm/components/auth/authorize/enforcers/casbin.enforcer.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/component.d.ts.map +1 -1
- package/dist/esm/components/health-check/component.js +5 -3
- package/dist/esm/components/health-check/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/executors/bull-mq-executor.helper.d.ts.map +1 -1
- package/dist/esm/components/mail/helpers/executors/bull-mq-executor.helper.js +2 -1
- package/dist/esm/components/mail/helpers/executors/bull-mq-executor.helper.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 +9 -7
- 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.d.ts.map +1 -1
- package/dist/esm/components/mail/services/mail.service.js +12 -9
- 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 +94 -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 -98
- 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 +104 -74
- 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 -129
- 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 +1 -1
- 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,MAAM,6BAA6B,C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AK,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;cAIvB,eAAe,IAAI,iBAAiB,EAAE;IAyCzD;;;OAGG;IACH,SAAS,CAAC,0BAA0B,IAAI,IAAI;CAK7C"}
|
|
@@ -1,15 +1,15 @@
|
|
|
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
14
|
import { ServerBootSteps } from './boot-steps.js';
|
|
15
15
|
import { ServerApplication } from './server.js';
|
|
@@ -42,7 +42,7 @@ export class BaseApplication extends ServerApplication {
|
|
|
42
42
|
/** Adds the gRPC branch the kernel cannot own: `GrpcComponent` needs `AbstractGrpcController`, core-only code that reaches `node:module`. */
|
|
43
43
|
async registerControllers() {
|
|
44
44
|
await super.registerControllers();
|
|
45
|
-
await
|
|
45
|
+
await PerformanceUtility.executeWithMeasure({
|
|
46
46
|
logger: this.logger,
|
|
47
47
|
description: 'Register application gRPC controllers',
|
|
48
48
|
scope: this.registerControllers.name,
|
|
@@ -91,7 +91,8 @@ export class BaseApplication extends ServerApplication {
|
|
|
91
91
|
let provider;
|
|
92
92
|
const emptyHydrations = [];
|
|
93
93
|
try {
|
|
94
|
-
|
|
94
|
+
const result = await SecretsHelperFactory.create({ ...registration, identifier: 'app' });
|
|
95
|
+
provider = result;
|
|
95
96
|
await provider.configure();
|
|
96
97
|
await this.hydrateSecretEntries({ provider, registration, emptyHydrations, logger });
|
|
97
98
|
const registrationLease = registration.lease ?? [];
|
|
@@ -112,10 +113,11 @@ export class BaseApplication extends ServerApplication {
|
|
|
112
113
|
.shutdown()
|
|
113
114
|
.catch((shutdownError) => logger.error('Failed to shut down partially-built provider during fallback | error: %s', shutdownError));
|
|
114
115
|
}
|
|
115
|
-
|
|
116
|
+
const result2 = await SecretsHelperFactory.create({
|
|
116
117
|
provider: SecretProviders.SYSTEM_ENVS,
|
|
117
118
|
identifier: 'app',
|
|
118
119
|
});
|
|
120
|
+
provider = result2;
|
|
119
121
|
}
|
|
120
122
|
if (!provider) {
|
|
121
123
|
throw getError({ message: '[hydrateSecrets] No secrets provider resolved' });
|
|
@@ -204,7 +206,7 @@ export class BaseApplication extends ServerApplication {
|
|
|
204
206
|
*/
|
|
205
207
|
printStartUpInfo(opts) {
|
|
206
208
|
const { scope } = opts;
|
|
207
|
-
const read = (key, fallback) => blankToUndefined(process.env[key]) ?? fallback;
|
|
209
|
+
const read = (key, fallback) => ParseUtility.blankToUndefined({ input: process.env[key] }) ?? fallback;
|
|
208
210
|
const divider = '------------------------------------------------------------------------';
|
|
209
211
|
this.logger.for(scope).info(divider);
|
|
210
212
|
this.logger
|
|
@@ -231,7 +233,7 @@ export class BaseApplication extends ServerApplication {
|
|
|
231
233
|
}
|
|
232
234
|
/** 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. */
|
|
233
235
|
async registerDefaultMiddlewares() {
|
|
234
|
-
await
|
|
236
|
+
await PerformanceUtility.executeWithMeasure({
|
|
235
237
|
logger: this.logger,
|
|
236
238
|
scope: this.registerDefaultMiddlewares.name,
|
|
237
239
|
description: 'Register default application server handler',
|
|
@@ -248,7 +250,7 @@ export class BaseApplication extends ServerApplication {
|
|
|
248
250
|
// Request-body parsing and the access log; the request id it reads is already installed
|
|
249
251
|
// above (also works around the Bun + Hono body-parsing bug: https://github.com/honojs/middleware/issues/81).
|
|
250
252
|
this.component(RequestTrackerComponent);
|
|
251
|
-
server.use(
|
|
253
|
+
server.use(EmojiFaviconMiddleware.create({ icon: this.configs.favicon ?? '🔥' }));
|
|
252
254
|
},
|
|
253
255
|
});
|
|
254
256
|
}
|
|
@@ -261,8 +263,8 @@ export class BaseApplication extends ServerApplication {
|
|
|
261
263
|
// reader rather than helping it. Set ALLOW_EMPTY_ENV_VALUE to `false` or `0` to turn the check
|
|
262
264
|
// on. Read once rather than per key, and a blank value reads as unset - the same rule every
|
|
263
265
|
// other env read follows.
|
|
264
|
-
const configured = blankToUndefined(process.env.ALLOW_EMPTY_ENV_VALUE);
|
|
265
|
-
const allowsEmpty = configured === undefined || toBoolean(configured);
|
|
266
|
+
const configured = ParseUtility.blankToUndefined({ input: process.env.ALLOW_EMPTY_ENV_VALUE });
|
|
267
|
+
const allowsEmpty = configured === undefined || ParseUtility.toBoolean({ input: configured });
|
|
266
268
|
this.logger
|
|
267
269
|
.for(this.initialize.name)
|
|
268
270
|
.info('Envs: %s | START Validating application environments | Empty values: %s', envKeys.length, allowsEmpty ? 'ALLOWED (default)' : 'REJECTED');
|
|
@@ -274,7 +276,7 @@ export class BaseApplication extends ServerApplication {
|
|
|
274
276
|
}
|
|
275
277
|
for (const argKey of envKeys) {
|
|
276
278
|
const argValue = applicationEnvironment.get(argKey);
|
|
277
|
-
if (!isEmpty({ value: argValue })) {
|
|
279
|
+
if (!ObjectUtility.isEmpty({ value: argValue })) {
|
|
278
280
|
continue;
|
|
279
281
|
}
|
|
280
282
|
throw getError({
|
|
@@ -334,7 +336,9 @@ export class BaseApplication extends ServerApplication {
|
|
|
334
336
|
* silent at runtime and opposite: a search-backed model returns too many rows, a context-less one none.
|
|
335
337
|
*/
|
|
336
338
|
validateScopeFilterSupport() {
|
|
337
|
-
assertScopeFilterSupported({
|
|
339
|
+
ScopeFilterUtility.assertScopeFilterSupported({
|
|
340
|
+
asyncContextEnabled: this.configs.asyncContext?.enable ?? false,
|
|
341
|
+
});
|
|
338
342
|
}
|
|
339
343
|
}
|
|
340
344
|
//# 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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AG,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 provider = await createSecretsHelper({ ...registration, identifier: 'app' });\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 provider = await createSecretsHelper({\n provider: SecretProviders.SYSTEM_ENVS,\n identifier: 'app',\n });\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,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,YAAY,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,kBAAkB,EAClB,WAAW,EACX,eAAe,GAChB,MAAM,wBAAwB,CAAC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;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,kBAAkB,CAAC,0BAA0B,CAAC;YAC5C,mBAAmB,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,IAAI,KAAK;SAChE,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { ScopeFilterUtility } 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 { 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 { 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 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 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 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"]}
|
|
@@ -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,CA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SAAS,CAAC,kBAAkB,IAAI,gBAAgB;IAIhD,iBAAiB,CAAC,CAAC,SAAS,kBAAkB,GAAG,kBAAkB,KAAK,CAAC,GAAG,SAAS;IAIrF,SAAS,CAAC,cAAc;IAmClB,KAAK;IAcX,mJAAmJ;IAC7I,IAAI;IAUV,8FAA8F;IAC9F,SAAS,CAAC,eAAe,CAAC,EAAE;QAAE,SAAS,EAAE,MAAM,IAAI,CAAA;KAAE,CAAC;IAEtD;;;;;;;;OAQG;IACH,sBAAsB,CAAC,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();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../../src/base/applications/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,IAAI,MAAM,WAAW,CAAC;AAW7B,MAAM,WAAW,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;AAW3C,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAqB,EAAE,CAAC,CAAC;IAC1D,UAAU,EAAE,cAAc,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;IAC5D,SAAS,EAAE,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI;IAC5C,YAAY,EAA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AAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IACzD,CAAC;CACF","sourcesContent":["import { CoreBindings, RestApplication } from '@venizia/ignis-kernel';\nimport { ModuleUtility } from '@venizia/ignis-helpers';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { RuntimeModules } from '@venizia/ignis-helpers/common';\nimport type { Env, Schema } from 'hono';\nimport { existsSync } from 'node:fs';\nimport path from 'node:path';\nimport type {\n IServerApplication,\n IServerApplicationConfigs,\n IServerRuntimeConfigs,\n IShutdownSignalsOptions,\n} from './common';\n\n/** Lives here, not in the kernel: `Bun.serve` resolves only through `@types/bun`, and emitting `Bun` into the kernel's published `.d.ts` would force that dependency on every browser consumer of `@venizia/ignis-kernel`. This package legitimately has Bun types - it is the layer that calls `Bun.serve`. */\nexport type TBunServerInstance = ReturnType<typeof Bun.serve>;\n\nconst MINIMUM_BUN = { major: 1, minor: 4 };\n\n/** What the process runs on. `Bun` is the one global that tells the runtimes apart, and it cannot be hidden in a test, so the guard reads this snapshot instead. */\nexport interface IRuntimeSnapshot {\n /** `Bun.version`, set only under Bun. */\n bunVersion?: string;\n /** `process.release.name` and `process.version` of a runtime that is not Bun (`node`, `v24.14.0`). */\n otherName?: string;\n otherVersion?: string;\n}\n\nexport const readRuntimeSnapshot = (): IRuntimeSnapshot => ({\n bunVersion: RuntimeModules.isBun() ? Bun.version : undefined,\n otherName: globalThis.process?.release?.name,\n otherVersion: globalThis.process?.version,\n});\n\nconst describeRuntime = (opts: { runtime: IRuntimeSnapshot }): string => {\n const { bunVersion, otherName, otherVersion } = opts.runtime;\n\n if (bunVersion !== undefined) {\n return `bun ${bunVersion}`;\n }\n\n return otherName ? `${otherName} ${otherVersion ?? ''}`.trim() : 'an unknown runtime';\n};\n\n/**\n * IGNIS runs on Bun 1.4 or later, and nothing else. One refusal at the top of `start()`, before any\n * hook, datasource or socket is touched, replaces a failure that would otherwise surface halfway\n * through startup.\n */\nexport const assertBunRuntime = (opts: { runtime?: IRuntimeSnapshot } = {}): void => {\n const runtime = opts.runtime ?? readRuntimeSnapshot();\n\n if (runtime.bunVersion !== undefined) {\n const [major = 0, minor = 0] = runtime.bunVersion.split('.').map(Number);\n if (major > MINIMUM_BUN.major || (major === MINIMUM_BUN.major && minor >= MINIMUM_BUN.minor)) {\n return;\n }\n }\n\n throw getError({\n message: `IGNIS requires Bun >= ${MINIMUM_BUN.major}.${MINIMUM_BUN.minor} (running on ${describeRuntime({ runtime })})`,\n });\n};\n\nconst DEFAULT_SHUTDOWN_SIGNALS: NodeJS.Signals[] = ['SIGTERM', 'SIGINT'];\nconst DEFAULT_SHUTDOWN_TIMEOUT_MS = 15_000;\n\nconst DEFAULT_SERVER_HOST = 'localhost';\nconst DEFAULT_SERVER_PORT = 3000;\nconst MAX_SERVER_PORT = 65535;\n\n/**\n * The first candidate USABLE as a port. Rejection is on validity, never falsiness: `0` legitimately\n * asks the OS for an ephemeral port, and taking the first TRUTHY value instead let an unusable\n * `PORT` shadow a usable `APP_ENV_SERVER_PORT` - `PORT=abc APP_ENV_SERVER_PORT=8080` bound 3000, as\n * did Docker's legacy container-link form `PORT=tcp://172.17.0.5:8080`.\n */\nconst resolveServerPort = (opts: { candidates: Array<number | string | undefined> }): number => {\n for (const candidate of opts.candidates) {\n if (candidate === undefined || candidate === null) {\n continue;\n }\n\n const normalized = typeof candidate === 'string' ? candidate.trim() : candidate;\n if (normalized === '') {\n continue;\n }\n\n const parsed = Number(normalized);\n if (!Number.isInteger(parsed) || parsed < 0 || parsed > MAX_SERVER_PORT) {\n continue;\n }\n\n return parsed;\n }\n\n return DEFAULT_SERVER_PORT;\n};\n\n/** 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. */\nexport abstract class ServerApplication<\n AppEnv extends Env = Env,\n AppSchema extends Schema = {},\n BasePath extends string = '/',\n>\n extends RestApplication<AppEnv, AppSchema, BasePath>\n implements IServerApplication<AppEnv, AppSchema, BasePath>\n{\n /** 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. */\n protected runtime = RuntimeModules.detect();\n protected serverInstance?: TBunServerInstance;\n\n /** Widened by this layer, which is the only one that binds a socket. Assigned by the base constructor - `declare` so no field initializer runs here and overwrites it with `undefined`. */\n declare protected configs: IServerApplicationConfigs;\n\n /**\n * The address resolution the kernel deliberately does not do: `host` and `port` mean nothing to a\n * host with no socket, and resolving them there silently configured every browser Worker with\n * `localhost:3000`. Env is the fallback, explicit config always wins.\n */\n constructor(opts: { scope: string; config: IServerApplicationConfigs }) {\n super(opts);\n\n this.configs.host =\n [opts.config.host, process.env.HOST, process.env.APP_ENV_SERVER_HOST].find(Boolean) ??\n DEFAULT_SERVER_HOST;\n this.configs.port = resolveServerPort({\n candidates: [opts.config.port, process.env.PORT, process.env.APP_ENV_SERVER_PORT],\n });\n }\n\n /** Restores the pre-split default: a server-capable application installs `hono/context-storage` unless the caller opts out explicitly. */\n protected override getDefaultAsyncContextEnabled(): boolean {\n return true;\n }\n\n /** `configs.projectRoot` wins, else the process cwd. The value is bound AND handed to `ModuleUtility`, so every peer lookup (optional modules, the gRPC adapter) resolves under it - a compiled binary sets it to where its `node_modules` really is. */\n override getProjectRoot(): string {\n const projectRoot = this.configs.projectRoot ?? process.cwd();\n if (this.configs.projectRoot && !existsSync(path.join(projectRoot, 'node_modules'))) {\n this.logger\n .for(this.getProjectRoot.name)\n .warn(\n 'configs.projectRoot has no node_modules | root: %s | optional peers will not resolve from it',\n projectRoot,\n );\n }\n this.bind<string>({ key: CoreBindings.APPLICATION_PROJECT_ROOT }).toValue(projectRoot);\n ModuleUtility.setProjectRoot({ projectRoot });\n return projectRoot;\n }\n\n getServerHost(): string {\n return this.configs.host!;\n }\n\n getServerPort(): number {\n return this.configs.port!;\n }\n\n getServerAddress() {\n return `${this.getServerHost()}:${this.getServerPort()}`;\n }\n\n /** `configs.server` with unset keys dropped, so a missing option keeps Bun's default instead of passing `undefined`. */\n protected getServerRuntimeOptions(): IServerRuntimeConfigs {\n const { idleTimeout, maxRequestBodySize } = this.configs.server ?? {};\n return {\n ...(idleTimeout === undefined ? {} : { idleTimeout }),\n ...(maxRequestBodySize === undefined ? {} : { maxRequestBodySize }),\n };\n }\n\n /** What `start()` checks. A seam for the guard's test: the `Bun` global cannot be hidden from inside Bun. */\n protected getRuntimeSnapshot(): IRuntimeSnapshot {\n return readRuntimeSnapshot();\n }\n\n getServerInstance<T extends TBunServerInstance = TBunServerInstance>(): T | undefined {\n return this.serverInstance as T | undefined;\n }\n\n protected startBunModule() {\n return new Promise((resolve, reject) => {\n const port = this.getServerPort();\n const host = this.getServerHost();\n const server = this.getServer();\n\n Promise.resolve(\n Bun.serve({\n port,\n hostname: host,\n fetch: server.fetch,\n ...this.getServerRuntimeOptions(),\n }),\n )\n .then((rs) => {\n this.serverInstance = rs;\n this.configs.port = rs.port;\n this.inspectRoutes();\n\n this.logger\n .for(this.start.name)\n .info('Server STARTED | Address: %s', this.getServerAddress());\n this.logger\n .for(this.start.name)\n .info(\n 'Log folder: %s',\n path.resolve(process.env.APP_ENV_LOGGER_FOLDER_PATH ?? '').toString(),\n );\n\n resolve(rs);\n })\n .catch(reject);\n });\n }\n\n async start() {\n assertBunRuntime({ runtime: this.getRuntimeSnapshot() });\n\n await this.initialize();\n await this.setupMiddlewares();\n\n const server = this.getServer();\n server.route(this.configs.path.base, this.rootRouter);\n\n await this.startBunModule();\n\n await this.executePostStartHooks();\n }\n\n /** Post-stop hooks, then the server, then the datasources - closed even when the server fails to, so a stopped application holds no connection. */\n async stop() {\n await this.executePostStopHooks();\n\n try {\n await this.stopServer();\n } finally {\n await this.closeDataSources();\n }\n }\n\n /** Set once `installShutdownSignals` ran; holds the way back, so a second call is a no-op. */\n protected shutdownSignals?: { uninstall: () => void };\n\n /**\n * Stops the application on a signal (SIGTERM and SIGINT by default), then exits the process.\n * Opt-in: nothing is installed until you call it, usually right after `start()`.\n *\n * - Calls `stop()` once. A second signal while it runs is ignored.\n * - Exits 0 when `stop()` finishes, 1 when it throws or does not finish within `timeoutMs`.\n * - Idempotent: calling it again returns the same uninstall function and adds no listener.\n * - Returns an uninstall function that removes the listeners and the pending timeout.\n */\n installShutdownSignals(opts: IShutdownSignalsOptions = {}): () => void {\n if (this.shutdownSignals) {\n return this.shutdownSignals.uninstall;\n }\n\n const {\n signals = DEFAULT_SHUTDOWN_SIGNALS,\n timeoutMs = DEFAULT_SHUTDOWN_TIMEOUT_MS,\n exit = (code: number) => process.exit(code),\n } = opts;\n\n if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {\n throw getError({\n message: `[installShutdownSignals] timeoutMs must be a positive number of milliseconds | value: ${String(timeoutMs)}`,\n });\n }\n\n const log = this.logger.for(this.installShutdownSignals.name);\n let isShuttingDown = false;\n let timer: ReturnType<typeof setTimeout> | undefined;\n\n const finish = (code: number) => {\n clearTimeout(timer);\n exit(code);\n };\n\n const onSignal = (signal: NodeJS.Signals) => {\n if (isShuttingDown) {\n log.warn('Signal %s ignored | shutdown already in progress', signal);\n return;\n }\n\n isShuttingDown = true;\n log.info('Signal %s received | stopping the application | timeout: %s ms', signal, timeoutMs);\n\n timer = setTimeout(() => {\n log.error('Shutdown did not finish within %s ms | forcing exit', timeoutMs);\n exit(1);\n }, timeoutMs);\n\n this.stop().then(\n () => {\n log.info('Application stopped | exiting');\n finish(0);\n },\n (error: unknown) => {\n log.error(\n 'Shutdown failed | error: %s',\n error instanceof Error ? error.message : String(error),\n );\n finish(1);\n },\n );\n };\n\n const listeners = signals.map((signal) => {\n const listener = () => onSignal(signal);\n process.on(signal, listener);\n return { signal, listener };\n });\n\n const uninstall = () => {\n clearTimeout(timer);\n for (const { signal, listener } of listeners) {\n process.off(signal, listener);\n }\n this.shutdownSignals = undefined;\n };\n\n this.shutdownSignals = { uninstall };\n return uninstall;\n }\n\n protected async stopServer(): Promise<void> {\n const instance = this.serverInstance;\n if (!instance) {\n this.logger.for(this.stop.name).info('Server was not started | Nothing to stop');\n return;\n }\n\n await instance.stop();\n\n this.serverInstance = undefined;\n this.logger.for(this.stop.name).info('Server STOPPED');\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../../src/base/applications/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,IAAI,MAAM,WAAW,CAAC;AAW7B,MAAM,WAAW,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;AAW3C,qGAAqG;AACrG,MAAM,OAAO,eAAe;IAC1B,2CAA2C;IAC3C,MAAM,CAAC,YAAY;QACjB,OAAO;YACL,UAAU,EAAE,cAAc,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;YAC5D,SAAS,EAAE,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI;YAC5C,YAAY,EAAE,UAAU,CAAC,OAAO,EAAE,OAAO;SAC1C,CAAC;IACJ,CAAC;IAEO,MAAM,CAAC,eAAe,CAAC,IAAmC;QAChE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;QAE7D,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;YAC7B,OAAO,OAAO,UAAU,EAAE,CAAC;QAC7B,CAAC;QAED,OAAO,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,IAAI,YAAY,IAAI,EAAE,EAAE,CAAC,IAAI,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EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;YAC7B,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;QAC9B,CAAC,CAAC,CAAC;QAEH,MAAM,SAAS,GAAG,GAAG,EAAE;YACrB,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,KAAK,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,SAAS,EAAE,CAAC;gBAC7C,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;YAChC,CAAC;YACD,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;QACnC,CAAC,CAAC;QAEF,IAAI,CAAC,eAAe,GAAG,EAAE,SAAS,EAAE,CAAC;QACrC,OAAO,SAAS,CAAC;IACnB,CAAC;IAES,KAAK,CAAC,UAAU;QACxB,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC;QACrC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,0CAA0C,CAAC,CAAC;YACjF,OAAO;QACT,CAAC;QAED,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QAEtB,IAAI,CAAC,cAAc,GAAG,SAAS,CAAC;QAChC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IACzD,CAAC;CACF","sourcesContent":["import { CoreBindings, RestApplication } from '@venizia/ignis-kernel';\nimport { ModuleUtility } from '@venizia/ignis-helpers';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { RuntimeModules } from '@venizia/ignis-helpers/common';\nimport type { Env, Schema } from 'hono';\nimport { existsSync } from 'node:fs';\nimport path from 'node:path';\nimport type {\n IServerApplication,\n IServerApplicationConfigs,\n IServerRuntimeConfigs,\n IShutdownSignalsOptions,\n} from './common';\n\n/** Lives here, not in the kernel: `Bun.serve` resolves only through `@types/bun`, and emitting `Bun` into the kernel's published `.d.ts` would force that dependency on every browser consumer of `@venizia/ignis-kernel`. This package legitimately has Bun types - it is the layer that calls `Bun.serve`. */\nexport type TBunServerInstance = ReturnType<typeof Bun.serve>;\n\nconst MINIMUM_BUN = { major: 1, minor: 4 };\n\n/** What the process runs on. `Bun` is the one global that tells the runtimes apart, and it cannot be hidden in a test, so the guard reads this snapshot instead. */\nexport interface IRuntimeSnapshot {\n /** `Bun.version`, set only under Bun. */\n bunVersion?: string;\n /** `process.release.name` and `process.version` of a runtime that is not Bun (`node`, `v24.14.0`). */\n otherName?: string;\n otherVersion?: string;\n}\n\n/** The Bun-only guard: what the process runs on, and the refusal when it is not Bun 1.4 or later. */\nexport class BunRuntimeGuard {\n /** Reads the runtime the process is on. */\n static readSnapshot(): IRuntimeSnapshot {\n return {\n bunVersion: RuntimeModules.isBun() ? Bun.version : undefined,\n otherName: globalThis.process?.release?.name,\n otherVersion: globalThis.process?.version,\n };\n }\n\n private static describeRuntime(opts: { runtime: IRuntimeSnapshot }): string {\n const { bunVersion, otherName, otherVersion } = opts.runtime;\n\n if (bunVersion !== undefined) {\n return `bun ${bunVersion}`;\n }\n\n return otherName ? `${otherName} ${otherVersion ?? ''}`.trim() : 'an unknown runtime';\n }\n\n /**\n * IGNIS runs on Bun 1.4 or later, and nothing else. One refusal at the top of `start()`, before any\n * hook, datasource or socket is touched, replaces a failure that would otherwise surface halfway\n * through startup.\n */\n static assert(opts: { runtime?: IRuntimeSnapshot } = {}): void {\n const runtime = opts.runtime ?? BunRuntimeGuard.readSnapshot();\n\n if (runtime.bunVersion !== undefined) {\n const [major = 0, minor = 0] = runtime.bunVersion.split('.').map(Number);\n if (\n major > MINIMUM_BUN.major ||\n (major === MINIMUM_BUN.major && minor >= MINIMUM_BUN.minor)\n ) {\n return;\n }\n }\n\n throw getError({\n message: `IGNIS requires Bun >= ${MINIMUM_BUN.major}.${MINIMUM_BUN.minor} (running on ${BunRuntimeGuard.describeRuntime({ runtime })})`,\n });\n }\n}\n\nconst DEFAULT_SHUTDOWN_SIGNALS: NodeJS.Signals[] = ['SIGTERM', 'SIGINT'];\nconst DEFAULT_SHUTDOWN_TIMEOUT_MS = 15_000;\n\nconst DEFAULT_SERVER_HOST = 'localhost';\nconst DEFAULT_SERVER_PORT = 3000;\nconst MAX_SERVER_PORT = 65535;\n\n/**\n * The first candidate USABLE as a port. Rejection is on validity, never falsiness: `0` legitimately\n * asks the OS for an ephemeral port, and taking the first TRUTHY value instead let an unusable\n * `PORT` shadow a usable `APP_ENV_SERVER_PORT` - `PORT=abc APP_ENV_SERVER_PORT=8080` bound 3000, as\n * did Docker's legacy container-link form `PORT=tcp://172.17.0.5:8080`.\n */\nconst resolveServerPort = (opts: { candidates: Array<number | string | undefined> }): number => {\n for (const candidate of opts.candidates) {\n if (candidate === undefined || candidate === null) {\n continue;\n }\n\n const normalized = typeof candidate === 'string' ? candidate.trim() : candidate;\n if (normalized === '') {\n continue;\n }\n\n const parsed = Number(normalized);\n if (!Number.isInteger(parsed) || parsed < 0 || parsed > MAX_SERVER_PORT) {\n continue;\n }\n\n return parsed;\n }\n\n return DEFAULT_SERVER_PORT;\n};\n\n/** 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. */\nexport abstract class ServerApplication<\n AppEnv extends Env = Env,\n AppSchema extends Schema = {},\n BasePath extends string = '/',\n>\n extends RestApplication<AppEnv, AppSchema, BasePath>\n implements IServerApplication<AppEnv, AppSchema, BasePath>\n{\n /** 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. */\n protected runtime = RuntimeModules.detect();\n protected serverInstance?: TBunServerInstance;\n\n /** Widened by this layer, which is the only one that binds a socket. Assigned by the base constructor - `declare` so no field initializer runs here and overwrites it with `undefined`. */\n declare protected configs: IServerApplicationConfigs;\n\n /**\n * The address resolution the kernel deliberately does not do: `host` and `port` mean nothing to a\n * host with no socket, and resolving them there silently configured every browser Worker with\n * `localhost:3000`. Env is the fallback, explicit config always wins.\n */\n constructor(opts: { scope: string; config: IServerApplicationConfigs }) {\n super(opts);\n\n this.configs.host =\n [opts.config.host, process.env.HOST, process.env.APP_ENV_SERVER_HOST].find(Boolean) ??\n DEFAULT_SERVER_HOST;\n this.configs.port = resolveServerPort({\n candidates: [opts.config.port, process.env.PORT, process.env.APP_ENV_SERVER_PORT],\n });\n }\n\n /** Restores the pre-split default: a server-capable application installs `hono/context-storage` unless the caller opts out explicitly. */\n protected override getDefaultAsyncContextEnabled(): boolean {\n return true;\n }\n\n /** `configs.projectRoot` wins, else the process cwd. The value is bound AND handed to `ModuleUtility`, so every peer lookup (optional modules, the gRPC adapter) resolves under it - a compiled binary sets it to where its `node_modules` really is. */\n override getProjectRoot(): string {\n const projectRoot = this.configs.projectRoot ?? process.cwd();\n if (this.configs.projectRoot && !existsSync(path.join(projectRoot, 'node_modules'))) {\n this.logger\n .for(this.getProjectRoot.name)\n .warn(\n 'configs.projectRoot has no node_modules | root: %s | optional peers will not resolve from it',\n projectRoot,\n );\n }\n this.bind<string>({ key: CoreBindings.APPLICATION_PROJECT_ROOT }).toValue(projectRoot);\n ModuleUtility.setProjectRoot({ projectRoot });\n return projectRoot;\n }\n\n getServerHost(): string {\n return this.configs.host!;\n }\n\n getServerPort(): number {\n return this.configs.port!;\n }\n\n getServerAddress() {\n return `${this.getServerHost()}:${this.getServerPort()}`;\n }\n\n /** `configs.server` with unset keys dropped, so a missing option keeps Bun's default instead of passing `undefined`. */\n protected getServerRuntimeOptions(): IServerRuntimeConfigs {\n const { idleTimeout, maxRequestBodySize } = this.configs.server ?? {};\n return {\n ...(idleTimeout === undefined ? {} : { idleTimeout }),\n ...(maxRequestBodySize === undefined ? {} : { maxRequestBodySize }),\n };\n }\n\n /** What `start()` checks. A seam for the guard's test: the `Bun` global cannot be hidden from inside Bun. */\n protected getRuntimeSnapshot(): IRuntimeSnapshot {\n return BunRuntimeGuard.readSnapshot();\n }\n\n getServerInstance<T extends TBunServerInstance = TBunServerInstance>(): T | undefined {\n return this.serverInstance as T | undefined;\n }\n\n protected startBunModule() {\n return new Promise((resolve, reject) => {\n const port = this.getServerPort();\n const host = this.getServerHost();\n const server = this.getServer();\n\n Promise.resolve(\n Bun.serve({\n port,\n hostname: host,\n fetch: server.fetch,\n ...this.getServerRuntimeOptions(),\n }),\n )\n .then((rs) => {\n this.serverInstance = rs;\n this.configs.port = rs.port;\n this.inspectRoutes();\n\n this.logger\n .for(this.start.name)\n .info('Server STARTED | Address: %s', this.getServerAddress());\n this.logger\n .for(this.start.name)\n .info(\n 'Log folder: %s',\n path.resolve(process.env.APP_ENV_LOGGER_FOLDER_PATH ?? '').toString(),\n );\n\n resolve(rs);\n })\n .catch(reject);\n });\n }\n\n async start() {\n BunRuntimeGuard.assert({ runtime: this.getRuntimeSnapshot() });\n\n await this.initialize();\n await this.setupMiddlewares();\n\n const server = this.getServer();\n server.route(this.configs.path.base, this.rootRouter);\n\n await this.startBunModule();\n\n await this.executePostStartHooks();\n }\n\n /** Post-stop hooks, then the server, then the datasources - closed even when the server fails to, so a stopped application holds no connection. */\n async stop() {\n await this.executePostStopHooks();\n\n try {\n await this.stopServer();\n } finally {\n await this.closeDataSources();\n }\n }\n\n /** Set once `installShutdownSignals` ran; holds the way back, so a second call is a no-op. */\n protected shutdownSignals?: { uninstall: () => void };\n\n /**\n * Stops the application on a signal (SIGTERM and SIGINT by default), then exits the process.\n * Opt-in: nothing is installed until you call it, usually right after `start()`.\n *\n * - Calls `stop()` once. A second signal while it runs is ignored.\n * - Exits 0 when `stop()` finishes, 1 when it throws or does not finish within `timeoutMs`.\n * - Idempotent: calling it again returns the same uninstall function and adds no listener.\n * - Returns an uninstall function that removes the listeners and the pending timeout.\n */\n installShutdownSignals(opts: IShutdownSignalsOptions = {}): () => void {\n if (this.shutdownSignals) {\n return this.shutdownSignals.uninstall;\n }\n\n const {\n signals = DEFAULT_SHUTDOWN_SIGNALS,\n timeoutMs = DEFAULT_SHUTDOWN_TIMEOUT_MS,\n exit = (code: number) => process.exit(code),\n } = opts;\n\n if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {\n throw getError({\n message: `[installShutdownSignals] timeoutMs must be a positive number of milliseconds | value: ${String(timeoutMs)}`,\n });\n }\n\n const log = this.logger.for(this.installShutdownSignals.name);\n let isShuttingDown = false;\n let timer: ReturnType<typeof setTimeout> | undefined;\n\n const finish = (code: number) => {\n clearTimeout(timer);\n exit(code);\n };\n\n const onSignal = (signal: NodeJS.Signals) => {\n if (isShuttingDown) {\n log.warn('Signal %s ignored | shutdown already in progress', signal);\n return;\n }\n\n isShuttingDown = true;\n log.info('Signal %s received | stopping the application | timeout: %s ms', signal, timeoutMs);\n\n timer = setTimeout(() => {\n log.error('Shutdown did not finish within %s ms | forcing exit', timeoutMs);\n exit(1);\n }, timeoutMs);\n\n this.stop().then(\n () => {\n log.info('Application stopped | exiting');\n finish(0);\n },\n (error: unknown) => {\n log.error(\n 'Shutdown failed | error: %s',\n error instanceof Error ? error.message : String(error),\n );\n finish(1);\n },\n );\n };\n\n const listeners = signals.map((signal) => {\n const listener = () => onSignal(signal);\n process.on(signal, listener);\n return { signal, listener };\n });\n\n const uninstall = () => {\n clearTimeout(timer);\n for (const { signal, listener } of listeners) {\n process.off(signal, listener);\n }\n this.shutdownSignals = undefined;\n };\n\n this.shutdownSignals = { uninstall };\n return uninstall;\n }\n\n protected async stopServer(): Promise<void> {\n const instance = this.serverInstance;\n if (!instance) {\n this.logger.for(this.stop.name).info('Server was not started | Nothing to stop');\n return;\n }\n\n await instance.stop();\n\n this.serverInstance = undefined;\n this.logger.for(this.stop.name).info('Server STOPPED');\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../../../src/base/controllers/grpc/adapter.ts"],"names":[],"mappings":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S,GAAG,GAAG,GAAG,EAC1B,WAAW,SAAS,MAAM,GAAG,EAAE,EAC/B,QAAQ,SAAS,MAAM,GAAG,GAAG,EAC7B,WAAW,GAAG,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,EACrD,mBAAmB,SAAS,MAAM,GAAG,EAAE,EACvC,IAAI,EAAE;QACN,UAAU,EAAE,sBAAsB,CAChC,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,WAAW,EACX,mBAAmB,CACpB,CAAC;QACF,YAAY,CAAC,EAAE,OAAO,EAAE,CAAC;QACzB,MAAM,CAAC,EAAE,iBAAiB,CAAC;KAC5B,GAAG,OAAO,CAAC,qBAAqB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;CAuDvD"}
|
|
@@ -104,7 +104,11 @@ export class GrpcRequestAdapter extends BaseHelper {
|
|
|
104
104
|
}
|
|
105
105
|
/** Validates peer deps, creates adapter, and returns paths + middleware. */
|
|
106
106
|
static async build(opts) {
|
|
107
|
-
|
|
107
|
+
let module = opts.module;
|
|
108
|
+
if (!module) {
|
|
109
|
+
const loaded = await GrpcRequestAdapter.loadModule();
|
|
110
|
+
module = loaded;
|
|
111
|
+
}
|
|
108
112
|
const adapter = new GrpcRequestAdapter({ ...opts, module });
|
|
109
113
|
const routerOpts = {};
|
|
110
114
|
if (adapter.interceptors?.length) {
|