@decohere/http 0.0.1-dev.126 → 0.0.1-dev.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/package.json +4 -13
- package/src/app/app.ts +147 -0
- package/src/app/module.ts +19 -0
- package/src/auth/ability.ts +56 -0
- package/src/auth/auth.config.ts +34 -0
- package/src/auth/auth.extensions.ts +115 -0
- package/src/auth/auth.types.ts +124 -0
- package/src/auth/casl-authorization.service.ts +62 -0
- package/{types/src/auth/principal-provider.d.ts → src/auth/principal-provider.ts} +13 -5
- package/src/auth/safe-outbound-url.ts +117 -0
- package/src/auth/token-service.ts +192 -0
- package/src/builder/builder.ts +118 -0
- package/{es6/src/const.js → src/const.ts} +25 -17
- package/src/health/health.controller.ts +34 -0
- package/src/health/health.extensions.ts +53 -0
- package/src/health/readiness.service.ts +33 -0
- package/{types/src/health/readiness.types.d.ts → src/health/readiness.types.ts} +4 -8
- package/src/hosting/hosted-service-host.ts +102 -0
- package/src/hosting/hosted-service.ts +31 -0
- package/src/http/http.compression.ts +38 -0
- package/src/http/http.extensions.ts +244 -0
- package/{types/src/http/http.options.store.d.ts → src/http/http.options.store.ts} +11 -1
- package/src/http/http.options.ts +41 -0
- package/{types/src/http/http.security.d.ts → src/http/http.security.ts} +16 -10
- package/src/http/http.static.ts +359 -0
- package/{es6/src/index.js → src/index.ts} +1 -0
- package/src/openapi/index.ts +22 -0
- package/src/openapi/openapi.generator.ts +78 -0
- package/src/openapi/openapi.types.ts +60 -0
- package/src/openapi/request-schema.ts +155 -0
- package/src/openapi/request-validator.ts +95 -0
- package/src/providers/fastify.provider.ts +454 -0
- package/src/routing/anvil.types.ts +150 -0
- package/src/routing/decorators/argument.decorator.ts +33 -0
- package/src/routing/decorators/auth.decorator.ts +79 -0
- package/src/routing/decorators/controller.decorator.ts +9 -0
- package/src/routing/decorators/field.decorator.ts +15 -0
- package/src/routing/decorators/request.decorator.ts +34 -0
- package/src/routing/decorators/response.decorator.ts +18 -0
- package/src/routing/decorators/route.decorator.ts +52 -0
- package/src/routing/filters/exception-filter-host.ts +90 -0
- package/src/routing/filters/exception-filter.ts +29 -0
- package/src/routing/middleware/http-access-log.middleware.ts +36 -0
- package/src/routing/middleware/middleware.ts +26 -0
- package/src/routing/middleware/request-id.ts +18 -0
- package/src/routing/path.util.ts +38 -0
- package/src/routing/pipes/pipes.ts +132 -0
- package/src/routing/services/route-argument-resolver.ts +92 -0
- package/src/routing/services/route-registry.ts +229 -0
- package/src/routing/services/router.ts +166 -0
- package/src/sse/sse.decorator.ts +41 -0
- package/src/sse/sse.encoder.ts +86 -0
- package/src/sse/sse.types.ts +47 -0
- package/src/sse/sse.wire.ts +34 -0
- package/src/testing/boot-module.ts +63 -0
- package/src/testing/sse-reader.ts +120 -0
- package/tests/app.hosted-services.spec.ts +292 -0
- package/tests/app.shutdown.integration.spec.ts +160 -0
- package/tests/app.spec.ts +132 -0
- package/tests/auth.ability.spec.ts +48 -0
- package/tests/auth.decorators.spec.ts +20 -0
- package/tests/auth.fail-closed.pentest.spec.ts +77 -0
- package/tests/auth.integration.spec.ts +234 -0
- package/tests/auth.jwks-cache.spec.ts +52 -0
- package/tests/auth.missing-auth.pentest.spec.ts +56 -0
- package/tests/auth.oidc-ssrf.pentest.spec.ts +72 -0
- package/tests/auth.oidc.integration.spec.ts +161 -0
- package/tests/auth.token-service.spec.ts +251 -0
- package/tests/builder.spec.ts +12 -0
- package/tests/health.integration.spec.ts +111 -0
- package/tests/helpers/listen-ephemeral.ts +13 -0
- package/tests/helpers/local-oidc-server.ts +100 -0
- package/tests/http.access-log.integration.spec.ts +111 -0
- package/tests/http.boolean-query.integration.spec.ts +59 -0
- package/tests/http.compression.integration.spec.ts +604 -0
- package/tests/http.date-query.integration.spec.ts +71 -0
- package/tests/http.global-prefix.integration.spec.ts +284 -0
- package/tests/http.number-query.integration.spec.ts +65 -0
- package/tests/http.pino-roll-hmr.integration.spec.ts +79 -0
- package/tests/http.pipeline-order.integration.spec.ts +95 -0
- package/tests/http.request-cleanup.integration.spec.ts +57 -0
- package/tests/http.request-id-scope.pentest.spec.ts +50 -0
- package/tests/http.security.integration.spec.ts +106 -0
- package/tests/http.static.integration.spec.ts +847 -0
- package/tests/http.static.spec.ts +111 -0
- package/tests/http.surface.integration.spec.ts +167 -0
- package/tests/openapi.integration.spec.ts +193 -0
- package/tests/openapi.validator-cache.integration.spec.ts +55 -0
- package/tests/routing.decorators.spec.ts +15 -0
- package/tests/routing.registry.spec.ts +44 -0
- package/tests/routing.resolver.spec.ts +92 -0
- package/tests/sse.integration.spec.ts +421 -0
- package/tests/sse.wire.spec.ts +33 -0
- package/LICENSE +0 -15
- package/commonjs/src/app/app.js +0 -166
- package/commonjs/src/app/index.js +0 -19
- package/commonjs/src/app/module.js +0 -17
- package/commonjs/src/auth/ability.js +0 -54
- package/commonjs/src/auth/auth.config.js +0 -23
- package/commonjs/src/auth/auth.extensions.js +0 -106
- package/commonjs/src/auth/auth.types.js +0 -65
- package/commonjs/src/auth/casl-authorization.service.js +0 -36
- package/commonjs/src/auth/index.js +0 -23
- package/commonjs/src/auth/principal-provider.js +0 -19
- package/commonjs/src/auth/safe-outbound-url.js +0 -102
- package/commonjs/src/auth/token-service.js +0 -151
- package/commonjs/src/builder/builder.js +0 -95
- package/commonjs/src/builder/index.js +0 -18
- package/commonjs/src/const.js +0 -87
- package/commonjs/src/health/health.controller.js +0 -75
- package/commonjs/src/health/health.extensions.js +0 -50
- package/commonjs/src/health/index.js +0 -21
- package/commonjs/src/health/readiness.service.js +0 -67
- package/commonjs/src/health/readiness.types.js +0 -7
- package/commonjs/src/hosting/hosted-service-host.js +0 -88
- package/commonjs/src/hosting/hosted-service.js +0 -11
- package/commonjs/src/hosting/index.js +0 -19
- package/commonjs/src/http/http.compression.js +0 -27
- package/commonjs/src/http/http.extensions.js +0 -269
- package/commonjs/src/http/http.options.js +0 -26
- package/commonjs/src/http/http.options.store.js +0 -20
- package/commonjs/src/http/http.security.js +0 -27
- package/commonjs/src/http/http.static.js +0 -248
- package/commonjs/src/http/index.js +0 -22
- package/commonjs/src/index.js +0 -27
- package/commonjs/src/openapi/index.js +0 -45
- package/commonjs/src/openapi/openapi.generator.js +0 -103
- package/commonjs/src/openapi/openapi.types.js +0 -4
- package/commonjs/src/openapi/request-schema.js +0 -187
- package/commonjs/src/openapi/request-validator.js +0 -85
- package/commonjs/src/providers/fastify.provider.js +0 -391
- package/commonjs/src/providers/index.js +0 -18
- package/commonjs/src/routing/anvil.types.js +0 -99
- package/commonjs/src/routing/decorators/argument.decorator.js +0 -49
- package/commonjs/src/routing/decorators/auth.decorator.js +0 -70
- package/commonjs/src/routing/decorators/controller.decorator.js +0 -16
- package/commonjs/src/routing/decorators/field.decorator.js +0 -25
- package/commonjs/src/routing/decorators/index.js +0 -24
- package/commonjs/src/routing/decorators/request.decorator.js +0 -30
- package/commonjs/src/routing/decorators/response.decorator.js +0 -34
- package/commonjs/src/routing/decorators/route.decorator.js +0 -67
- package/commonjs/src/routing/filters/exception-filter-host.js +0 -145
- package/commonjs/src/routing/filters/exception-filter.js +0 -28
- package/commonjs/src/routing/index.js +0 -25
- package/commonjs/src/routing/middleware/http-access-log.middleware.js +0 -47
- package/commonjs/src/routing/middleware/middleware.js +0 -20
- package/commonjs/src/routing/middleware/request-id.js +0 -30
- package/commonjs/src/routing/path.util.js +0 -51
- package/commonjs/src/routing/pipes/index.js +0 -18
- package/commonjs/src/routing/pipes/pipes.js +0 -145
- package/commonjs/src/routing/services/index.js +0 -18
- package/commonjs/src/routing/services/route-argument-resolver.js +0 -77
- package/commonjs/src/routing/services/route-registry.js +0 -194
- package/commonjs/src/routing/services/router.js +0 -158
- package/commonjs/src/sse/index.js +0 -26
- package/commonjs/src/sse/sse.decorator.js +0 -42
- package/commonjs/src/sse/sse.encoder.js +0 -73
- package/commonjs/src/sse/sse.types.js +0 -36
- package/commonjs/src/sse/sse.wire.js +0 -40
- package/commonjs/src/testing/boot-module.js +0 -38
- package/commonjs/src/testing/index.js +0 -20
- package/commonjs/src/testing/sse-reader.js +0 -98
- package/es6/src/app/app.js +0 -148
- package/es6/src/app/index.js +0 -2
- package/es6/src/app/module.js +0 -7
- package/es6/src/auth/ability.js +0 -45
- package/es6/src/auth/auth.config.js +0 -19
- package/es6/src/auth/auth.extensions.js +0 -83
- package/es6/src/auth/auth.types.js +0 -35
- package/es6/src/auth/casl-authorization.service.js +0 -40
- package/es6/src/auth/index.js +0 -6
- package/es6/src/auth/principal-provider.js +0 -14
- package/es6/src/auth/safe-outbound-url.js +0 -99
- package/es6/src/auth/token-service.js +0 -141
- package/es6/src/builder/builder.js +0 -85
- package/es6/src/builder/index.js +0 -1
- package/es6/src/health/health.controller.js +0 -65
- package/es6/src/health/health.extensions.js +0 -40
- package/es6/src/health/index.js +0 -4
- package/es6/src/health/readiness.service.js +0 -57
- package/es6/src/health/readiness.types.js +0 -4
- package/es6/src/hosting/hosted-service-host.js +0 -81
- package/es6/src/hosting/hosted-service.js +0 -8
- package/es6/src/hosting/index.js +0 -2
- package/es6/src/http/http.compression.js +0 -9
- package/es6/src/http/http.extensions.js +0 -259
- package/es6/src/http/http.options.js +0 -16
- package/es6/src/http/http.options.store.js +0 -13
- package/es6/src/http/http.security.js +0 -9
- package/es6/src/http/http.static.js +0 -224
- package/es6/src/http/index.js +0 -5
- package/es6/src/openapi/index.js +0 -3
- package/es6/src/openapi/openapi.generator.js +0 -82
- package/es6/src/openapi/openapi.types.js +0 -1
- package/es6/src/openapi/request-schema.js +0 -160
- package/es6/src/openapi/request-validator.js +0 -71
- package/es6/src/providers/fastify.provider.js +0 -376
- package/es6/src/providers/index.js +0 -1
- package/es6/src/routing/anvil.types.js +0 -57
- package/es6/src/routing/decorators/argument.decorator.js +0 -28
- package/es6/src/routing/decorators/auth.decorator.js +0 -58
- package/es6/src/routing/decorators/controller.decorator.js +0 -6
- package/es6/src/routing/decorators/field.decorator.js +0 -15
- package/es6/src/routing/decorators/index.js +0 -7
- package/es6/src/routing/decorators/request.decorator.js +0 -24
- package/es6/src/routing/decorators/response.decorator.js +0 -16
- package/es6/src/routing/decorators/route.decorator.js +0 -37
- package/es6/src/routing/filters/exception-filter-host.js +0 -127
- package/es6/src/routing/filters/exception-filter.js +0 -10
- package/es6/src/routing/index.js +0 -8
- package/es6/src/routing/middleware/http-access-log.middleware.js +0 -37
- package/es6/src/routing/middleware/middleware.js +0 -10
- package/es6/src/routing/middleware/request-id.js +0 -14
- package/es6/src/routing/path.util.js +0 -33
- package/es6/src/routing/pipes/index.js +0 -1
- package/es6/src/routing/pipes/pipes.js +0 -118
- package/es6/src/routing/services/index.js +0 -1
- package/es6/src/routing/services/route-argument-resolver.js +0 -67
- package/es6/src/routing/services/route-registry.js +0 -184
- package/es6/src/routing/services/router.js +0 -148
- package/es6/src/sse/index.js +0 -2
- package/es6/src/sse/sse.decorator.js +0 -31
- package/es6/src/sse/sse.encoder.js +0 -67
- package/es6/src/sse/sse.types.js +0 -22
- package/es6/src/sse/sse.wire.js +0 -30
- package/es6/src/testing/boot-module.js +0 -35
- package/es6/src/testing/index.js +0 -2
- package/es6/src/testing/sse-reader.js +0 -91
- package/types/src/app/app.d.ts +0 -41
- package/types/src/app/module.d.ts +0 -15
- package/types/src/auth/ability.d.ts +0 -19
- package/types/src/auth/auth.config.d.ts +0 -28
- package/types/src/auth/auth.extensions.d.ts +0 -53
- package/types/src/auth/auth.types.d.ts +0 -73
- package/types/src/auth/casl-authorization.service.d.ts +0 -28
- package/types/src/auth/safe-outbound-url.d.ts +0 -9
- package/types/src/auth/token-service.d.ts +0 -31
- package/types/src/builder/builder.d.ts +0 -36
- package/types/src/const.d.ts +0 -32
- package/types/src/health/health.controller.d.ts +0 -16
- package/types/src/health/health.extensions.d.ts +0 -31
- package/types/src/health/readiness.service.d.ts +0 -9
- package/types/src/hosting/hosted-service-host.d.ts +0 -37
- package/types/src/hosting/hosted-service.d.ts +0 -31
- package/types/src/http/http.compression.d.ts +0 -32
- package/types/src/http/http.extensions.d.ts +0 -79
- package/types/src/http/http.options.d.ts +0 -39
- package/types/src/http/http.static.d.ts +0 -160
- package/types/src/index.d.ts +0 -10
- package/types/src/openapi/index.d.ts +0 -6
- package/types/src/openapi/openapi.generator.d.ts +0 -6
- package/types/src/openapi/openapi.types.d.ts +0 -58
- package/types/src/openapi/request-schema.d.ts +0 -21
- package/types/src/openapi/request-validator.d.ts +0 -9
- package/types/src/providers/fastify.provider.d.ts +0 -56
- package/types/src/routing/anvil.types.d.ts +0 -119
- package/types/src/routing/decorators/argument.decorator.d.ts +0 -11
- package/types/src/routing/decorators/auth.decorator.d.ts +0 -30
- package/types/src/routing/decorators/controller.decorator.d.ts +0 -3
- package/types/src/routing/decorators/field.decorator.d.ts +0 -2
- package/types/src/routing/decorators/request.decorator.d.ts +0 -8
- package/types/src/routing/decorators/response.decorator.d.ts +0 -4
- package/types/src/routing/decorators/route.decorator.d.ts +0 -7
- package/types/src/routing/filters/exception-filter-host.d.ts +0 -19
- package/types/src/routing/filters/exception-filter.d.ts +0 -16
- package/types/src/routing/middleware/http-access-log.middleware.d.ts +0 -8
- package/types/src/routing/middleware/middleware.d.ts +0 -10
- package/types/src/routing/middleware/request-id.d.ts +0 -6
- package/types/src/routing/path.util.d.ts +0 -9
- package/types/src/routing/pipes/pipes.d.ts +0 -21
- package/types/src/routing/services/route-argument-resolver.d.ts +0 -10
- package/types/src/routing/services/route-registry.d.ts +0 -20
- package/types/src/routing/services/router.d.ts +0 -22
- package/types/src/sse/sse.decorator.d.ts +0 -17
- package/types/src/sse/sse.encoder.d.ts +0 -16
- package/types/src/sse/sse.types.d.ts +0 -37
- package/types/src/sse/sse.wire.d.ts +0 -9
- package/types/src/testing/boot-module.d.ts +0 -34
- package/types/src/testing/sse-reader.d.ts +0 -29
- /package/{types/src/app/index.d.ts → src/app/index.ts} +0 -0
- /package/{types/src/auth/index.d.ts → src/auth/index.ts} +0 -0
- /package/{types/src/builder/index.d.ts → src/builder/index.ts} +0 -0
- /package/{types/src/health/index.d.ts → src/health/index.ts} +0 -0
- /package/{types/src/hosting/index.d.ts → src/hosting/index.ts} +0 -0
- /package/{types/src/http/index.d.ts → src/http/index.ts} +0 -0
- /package/{types/src/providers/index.d.ts → src/providers/index.ts} +0 -0
- /package/{types/src/routing/decorators/index.d.ts → src/routing/decorators/index.ts} +0 -0
- /package/{types/src/routing/index.d.ts → src/routing/index.ts} +0 -0
- /package/{types/src/routing/pipes/index.d.ts → src/routing/pipes/index.ts} +0 -0
- /package/{types/src/routing/services/index.d.ts → src/routing/services/index.ts} +0 -0
- /package/{types/src/sse/index.d.ts → src/sse/index.ts} +0 -0
- /package/{types/src/testing/index.d.ts → src/testing/index.ts} +0 -0
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
_export_star(require("./builder.js"), exports);
|
|
6
|
-
function _export_star(from, to) {
|
|
7
|
-
Object.keys(from).forEach(function(k) {
|
|
8
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
9
|
-
Object.defineProperty(to, k, {
|
|
10
|
-
enumerable: true,
|
|
11
|
-
get: function() {
|
|
12
|
-
return from[k];
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
return from;
|
|
18
|
-
}
|
package/commonjs/src/const.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
function _export(target, all) {
|
|
6
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
_export(exports, {
|
|
12
|
-
get AuthorizationServiceToken () {
|
|
13
|
-
return AuthorizationServiceToken;
|
|
14
|
-
},
|
|
15
|
-
get ExceptionFilterHostToken () {
|
|
16
|
-
return ExceptionFilterHostToken;
|
|
17
|
-
},
|
|
18
|
-
get HTTPMethods () {
|
|
19
|
-
return HTTPMethods;
|
|
20
|
-
},
|
|
21
|
-
get HostedServiceHostToken () {
|
|
22
|
-
return HostedServiceHostToken;
|
|
23
|
-
},
|
|
24
|
-
get HttpOptionsToken () {
|
|
25
|
-
return HttpOptionsToken;
|
|
26
|
-
},
|
|
27
|
-
get HttpProviderToken () {
|
|
28
|
-
return HttpProviderToken;
|
|
29
|
-
},
|
|
30
|
-
get IPrincipalProviderToken () {
|
|
31
|
-
return IPrincipalProviderToken;
|
|
32
|
-
},
|
|
33
|
-
get MetadataKeys () {
|
|
34
|
-
return MetadataKeys;
|
|
35
|
-
},
|
|
36
|
-
get PrincipalToken () {
|
|
37
|
-
return PrincipalToken;
|
|
38
|
-
},
|
|
39
|
-
get ReadinessCheckToken () {
|
|
40
|
-
return ReadinessCheckToken;
|
|
41
|
-
},
|
|
42
|
-
get ReadinessServiceToken () {
|
|
43
|
-
return ReadinessServiceToken;
|
|
44
|
-
},
|
|
45
|
-
get RouteRegistryToken () {
|
|
46
|
-
return RouteRegistryToken;
|
|
47
|
-
},
|
|
48
|
-
get RouterToken () {
|
|
49
|
-
return RouterToken;
|
|
50
|
-
},
|
|
51
|
-
get TokenServiceToken () {
|
|
52
|
-
return TokenServiceToken;
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
const Anvil = "anvil";
|
|
56
|
-
const RoutingKey = `${Anvil}:Routing`;
|
|
57
|
-
const RouteRegistryToken = Symbol("RouteRegistryToken");
|
|
58
|
-
const HttpProviderToken = Symbol("HttpProviderToken");
|
|
59
|
-
const RouterToken = Symbol("RouterToken");
|
|
60
|
-
const PrincipalToken = Symbol("PrincipalToken");
|
|
61
|
-
const IPrincipalProviderToken = Symbol("IPrincipalProvider");
|
|
62
|
-
const TokenServiceToken = Symbol("TokenService");
|
|
63
|
-
const AuthorizationServiceToken = Symbol("AuthorizationService");
|
|
64
|
-
const HttpOptionsToken = Symbol("HttpOptions");
|
|
65
|
-
const ExceptionFilterHostToken = Symbol("ExceptionFilterHost");
|
|
66
|
-
const ReadinessCheckToken = Symbol("ReadinessCheck");
|
|
67
|
-
const ReadinessServiceToken = Symbol("ReadinessService");
|
|
68
|
-
const HostedServiceHostToken = Symbol("HostedServiceHost");
|
|
69
|
-
const HTTPMethods = {
|
|
70
|
-
GET: "GET",
|
|
71
|
-
PUT: "PUT",
|
|
72
|
-
POST: "POST",
|
|
73
|
-
PATCH: "PATCH",
|
|
74
|
-
DELETE: "DELETE"
|
|
75
|
-
};
|
|
76
|
-
const MetadataKeys = {
|
|
77
|
-
controller: `${RoutingKey}:controller`,
|
|
78
|
-
route: `${RoutingKey}:route`,
|
|
79
|
-
parameter: `${RoutingKey}:parameter`,
|
|
80
|
-
fieldMap: `${RoutingKey}:fieldMap`,
|
|
81
|
-
authorize: `${RoutingKey}:authorize`,
|
|
82
|
-
allowAnonymous: `${RoutingKey}:allowAnonymous`,
|
|
83
|
-
httpCode: `${RoutingKey}:httpCode`,
|
|
84
|
-
headers: `${RoutingKey}:headers`,
|
|
85
|
-
catch: `${RoutingKey}:catch`,
|
|
86
|
-
sse: `${RoutingKey}:sse`
|
|
87
|
-
};
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "HealthController", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return HealthController;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _decorators = require("@decohere/crucible/decorators");
|
|
12
|
-
const _const = require("../const.js");
|
|
13
|
-
const _anviltypes = require("../routing/anvil.types.js");
|
|
14
|
-
const _index = require("../routing/index.js");
|
|
15
|
-
const _readinessservice = require("./readiness.service.js");
|
|
16
|
-
function _ts_decorate(decorators, target, key, desc) {
|
|
17
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
18
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
19
|
-
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
20
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
21
|
-
}
|
|
22
|
-
function _ts_metadata(k, v) {
|
|
23
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
24
|
-
}
|
|
25
|
-
function _ts_param(paramIndex, decorator) {
|
|
26
|
-
return function(target, key) {
|
|
27
|
-
decorator(target, key, paramIndex);
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
class HealthController {
|
|
31
|
-
readiness;
|
|
32
|
-
constructor(readiness){
|
|
33
|
-
this.readiness = readiness;
|
|
34
|
-
}
|
|
35
|
-
health() {
|
|
36
|
-
return {
|
|
37
|
-
status: "ok"
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
async ready() {
|
|
41
|
-
const result = await this.readiness.checkAll();
|
|
42
|
-
if (!result.ok) {
|
|
43
|
-
throw new _anviltypes.HttpError("Not ready", 503);
|
|
44
|
-
}
|
|
45
|
-
return {
|
|
46
|
-
status: "ok"
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
_ts_decorate([
|
|
51
|
-
(0, _index.AllowAnonymous)(),
|
|
52
|
-
(0, _index.Get)("/health"),
|
|
53
|
-
_ts_metadata("design:type", Function),
|
|
54
|
-
_ts_metadata("design:paramtypes", []),
|
|
55
|
-
_ts_metadata("design:returntype", void 0)
|
|
56
|
-
], HealthController.prototype, "health", null);
|
|
57
|
-
_ts_decorate([
|
|
58
|
-
(0, _index.AllowAnonymous)(),
|
|
59
|
-
(0, _index.Get)("/ready"),
|
|
60
|
-
_ts_metadata("design:type", Function),
|
|
61
|
-
_ts_metadata("design:paramtypes", []),
|
|
62
|
-
_ts_metadata("design:returntype", Promise)
|
|
63
|
-
], HealthController.prototype, "ready", null);
|
|
64
|
-
HealthController = _ts_decorate([
|
|
65
|
-
(0, _index.Controller)({
|
|
66
|
-
prefix: "/",
|
|
67
|
-
globalPrefix: false
|
|
68
|
-
}),
|
|
69
|
-
(0, _decorators.injectable)(),
|
|
70
|
-
_ts_param(0, (0, _decorators.inject)(_const.ReadinessServiceToken)),
|
|
71
|
-
_ts_metadata("design:type", Function),
|
|
72
|
-
_ts_metadata("design:paramtypes", [
|
|
73
|
-
typeof _readinessservice.ReadinessService === "undefined" ? Object : _readinessservice.ReadinessService
|
|
74
|
-
])
|
|
75
|
-
], HealthController);
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "BuilderExtensions", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return BuilderExtensions;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _extensibility = require("@decohere/core/extensibility");
|
|
12
|
-
const _builder = require("../builder/builder.js");
|
|
13
|
-
const _const = require("../const.js");
|
|
14
|
-
require("../http/http.extensions.js");
|
|
15
|
-
const _httpoptionsstore = require("../http/http.options.store.js");
|
|
16
|
-
const _healthcontroller = require("./health.controller.js");
|
|
17
|
-
const _readinessservice = require("./readiness.service.js");
|
|
18
|
-
function _ts_decorate(decorators, target, key, desc) {
|
|
19
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
-
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
-
}
|
|
24
|
-
function _ts_metadata(k, v) {
|
|
25
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
26
|
-
}
|
|
27
|
-
class BuilderExtensions {
|
|
28
|
-
static withHealth(builder, options) {
|
|
29
|
-
builder.withServices((containerBuilder)=>{
|
|
30
|
-
containerBuilder.registerSingleton(_const.ReadinessServiceToken, _readinessservice.ReadinessService);
|
|
31
|
-
for (const check of options?.checks ?? []){
|
|
32
|
-
containerBuilder.registerSingleton(_const.ReadinessCheckToken, check);
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
if (options?.underGlobalPrefix === true) {
|
|
36
|
-
(0, _httpoptionsstore.getOrCreateHttpOptions)(builder).underGlobalPrefix.add(_healthcontroller.HealthController);
|
|
37
|
-
}
|
|
38
|
-
builder.withControllers(_healthcontroller.HealthController);
|
|
39
|
-
return builder;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
_ts_decorate([
|
|
43
|
-
(0, _extensibility.extension)(_builder.Builder),
|
|
44
|
-
_ts_metadata("design:type", Function),
|
|
45
|
-
_ts_metadata("design:paramtypes", [
|
|
46
|
-
typeof _builder.Builder === "undefined" ? Object : _builder.Builder,
|
|
47
|
-
typeof WithHealthOptions === "undefined" ? Object : WithHealthOptions
|
|
48
|
-
]),
|
|
49
|
-
_ts_metadata("design:returntype", void 0)
|
|
50
|
-
], BuilderExtensions, "withHealth", null);
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
_export_star(require("./health.controller.js"), exports);
|
|
6
|
-
_export_star(require("./health.extensions.js"), exports);
|
|
7
|
-
_export_star(require("./readiness.service.js"), exports);
|
|
8
|
-
_export_star(require("./readiness.types.js"), exports);
|
|
9
|
-
function _export_star(from, to) {
|
|
10
|
-
Object.keys(from).forEach(function(k) {
|
|
11
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
12
|
-
Object.defineProperty(to, k, {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function() {
|
|
15
|
-
return from[k];
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
return from;
|
|
21
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "ReadinessService", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return ReadinessService;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _decorators = require("@decohere/crucible/decorators");
|
|
12
|
-
const _const = require("../const.js");
|
|
13
|
-
function _ts_decorate(decorators, target, key, desc) {
|
|
14
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
15
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
16
|
-
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
17
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
18
|
-
}
|
|
19
|
-
function _ts_metadata(k, v) {
|
|
20
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
21
|
-
}
|
|
22
|
-
function _ts_param(paramIndex, decorator) {
|
|
23
|
-
return function(target, key) {
|
|
24
|
-
decorator(target, key, paramIndex);
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
class ReadinessService {
|
|
28
|
-
hostedServices;
|
|
29
|
-
checks;
|
|
30
|
-
constructor(checks = [], hostedServices){
|
|
31
|
-
this.hostedServices = hostedServices;
|
|
32
|
-
this.checks = checks;
|
|
33
|
-
}
|
|
34
|
-
/** Registered checks, then each started hosted service that has a `check()` (still warming up). */ async checkAll() {
|
|
35
|
-
const failures = [];
|
|
36
|
-
const probes = [
|
|
37
|
-
...this.checks,
|
|
38
|
-
...this.hostedServices?.readinessChecks() ?? []
|
|
39
|
-
];
|
|
40
|
-
for (const probe of probes){
|
|
41
|
-
try {
|
|
42
|
-
await probe.check();
|
|
43
|
-
} catch {
|
|
44
|
-
failures.push(probe.name);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
if (failures.length > 0) {
|
|
48
|
-
return {
|
|
49
|
-
ok: false,
|
|
50
|
-
failures
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
return {
|
|
54
|
-
ok: true
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
ReadinessService = _ts_decorate([
|
|
59
|
-
(0, _decorators.injectable)(),
|
|
60
|
-
_ts_param(0, (0, _decorators.inject)(_const.ReadinessCheckToken)),
|
|
61
|
-
_ts_param(1, (0, _decorators.inject)(_const.HostedServiceHostToken)),
|
|
62
|
-
_ts_metadata("design:type", Function),
|
|
63
|
-
_ts_metadata("design:paramtypes", [
|
|
64
|
-
Array,
|
|
65
|
-
typeof HostedServiceHost === "undefined" ? Object : HostedServiceHost
|
|
66
|
-
])
|
|
67
|
-
], ReadinessService);
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "HostedServiceHost", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return HostedServiceHost;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _scribe = require("@decohere/scribe");
|
|
12
|
-
class HostedServiceHost {
|
|
13
|
-
logger = _scribe.scribe.logger(HostedServiceHost.name);
|
|
14
|
-
types = [];
|
|
15
|
-
controller = new AbortController();
|
|
16
|
-
/** In start order; stopped in reverse. */ started = [];
|
|
17
|
-
starting;
|
|
18
|
-
stopping;
|
|
19
|
-
add(...types) {
|
|
20
|
-
this.types.push(...types);
|
|
21
|
-
}
|
|
22
|
-
get isEmpty() {
|
|
23
|
-
return this.types.length === 0;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Start every service in registration order. If one throws, the ones already started are
|
|
27
|
-
* stopped and the error is rethrown. Stops launching more once {@link stop} has begun.
|
|
28
|
-
*/ start(container) {
|
|
29
|
-
this.starting ??= this.startAll(container);
|
|
30
|
-
return this.starting;
|
|
31
|
-
}
|
|
32
|
-
/** Abort the services' signal: background work should wind down. {@link stop} does this too. */ abort() {
|
|
33
|
-
this.controller.abort();
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Abort the signal, wait for a start still in progress, then stop the started services in
|
|
37
|
-
* reverse order. Every `stop()` runs even if one throws; the failures are rethrown after.
|
|
38
|
-
*/ stop() {
|
|
39
|
-
this.stopping ??= this.stopAll();
|
|
40
|
-
return this.stopping;
|
|
41
|
-
}
|
|
42
|
-
/** The started services that report readiness, for `GET /ready`. */ readinessChecks() {
|
|
43
|
-
return this.started.filter((service)=>typeof service.check === "function").map((service)=>({
|
|
44
|
-
name: service.constructor.name,
|
|
45
|
-
check: ()=>service.check?.() ?? Promise.resolve()
|
|
46
|
-
}));
|
|
47
|
-
}
|
|
48
|
-
async startAll(container) {
|
|
49
|
-
const { signal } = this.controller;
|
|
50
|
-
for (const type of this.types){
|
|
51
|
-
if (signal.aborted) return;
|
|
52
|
-
const service = container.resolve(type);
|
|
53
|
-
try {
|
|
54
|
-
await service.start(signal);
|
|
55
|
-
} catch (error) {
|
|
56
|
-
this.logger.error(`Hosted service ${type.name} failed to start`, error);
|
|
57
|
-
// Not stop(): it waits for this start to settle.
|
|
58
|
-
this.controller.abort();
|
|
59
|
-
await this.stopStarted().catch(()=>{});
|
|
60
|
-
throw error;
|
|
61
|
-
}
|
|
62
|
-
this.started.push(service);
|
|
63
|
-
this.logger.debug(`Hosted service ${type.name} started`);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
async stopAll() {
|
|
67
|
-
this.controller.abort();
|
|
68
|
-
await Promise.allSettled([
|
|
69
|
-
this.starting
|
|
70
|
-
]);
|
|
71
|
-
await this.stopStarted();
|
|
72
|
-
}
|
|
73
|
-
/** Stop what is started, newest first. Takes each service off the list, so it runs once. */ async stopStarted() {
|
|
74
|
-
const failures = [];
|
|
75
|
-
for(let service = this.started.pop(); service != null; service = this.started.pop()){
|
|
76
|
-
try {
|
|
77
|
-
await service.stop?.();
|
|
78
|
-
} catch (error) {
|
|
79
|
-
this.logger.error(`Hosted service ${service.constructor.name} failed to stop`, error);
|
|
80
|
-
failures.push(error);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
if (failures.length === 1) throw failures[0];
|
|
84
|
-
if (failures.length > 1) {
|
|
85
|
-
throw new AggregateError(failures, `${failures.length} hosted services failed to stop`);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Work that runs for the life of the app outside a request: a feed, a poller, a queue consumer.
|
|
3
|
-
* Register it with `builder.withHostedService(Type)`; it is a singleton, so other services can
|
|
4
|
-
* inject it by its class.
|
|
5
|
-
*
|
|
6
|
-
* The app starts hosted services in registration order before the HTTP server listens, and stops
|
|
7
|
-
* them in reverse order when it stops (`app.dispose()`, SIGTERM or SIGINT, a Flux reboot).
|
|
8
|
-
*/ "use strict";
|
|
9
|
-
Object.defineProperty(exports, "__esModule", {
|
|
10
|
-
value: true
|
|
11
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
_export_star(require("./hosted-service.js"), exports);
|
|
6
|
-
_export_star(require("./hosted-service-host.js"), exports);
|
|
7
|
-
function _export_star(from, to) {
|
|
8
|
-
Object.keys(from).forEach(function(k) {
|
|
9
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
10
|
-
Object.defineProperty(to, k, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function() {
|
|
13
|
-
return from[k];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
return from;
|
|
19
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Response compression (`builder.withCompression`). Provider-neutral options and defaults;
|
|
3
|
-
* the HTTP provider hands them to its compression plugin and the plugin owns the policy
|
|
4
|
-
* (which responses are compressed, `Vary`, `HEAD`, streams). See ADR 0008.
|
|
5
|
-
*/ /** A content coding the HTTP package can offer. */ "use strict";
|
|
6
|
-
Object.defineProperty(exports, "__esModule", {
|
|
7
|
-
value: true
|
|
8
|
-
});
|
|
9
|
-
function _export(target, all) {
|
|
10
|
-
for(var name in all)Object.defineProperty(target, name, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
_export(exports, {
|
|
16
|
-
get DEFAULT_COMPRESSION_ENCODINGS () {
|
|
17
|
-
return DEFAULT_COMPRESSION_ENCODINGS;
|
|
18
|
-
},
|
|
19
|
-
get DEFAULT_COMPRESSION_THRESHOLD () {
|
|
20
|
-
return DEFAULT_COMPRESSION_THRESHOLD;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
const DEFAULT_COMPRESSION_THRESHOLD = 1024;
|
|
24
|
-
const DEFAULT_COMPRESSION_ENCODINGS = [
|
|
25
|
-
"br",
|
|
26
|
-
"gzip"
|
|
27
|
-
];
|