jimpex 8.0.0 → 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/README.md +2 -2
- package/dist/app/index.d.mts +14 -0
- package/dist/app/index.d.ts +5 -4
- package/dist/app/index.js +4 -0
- package/dist/app/jimpex.d.mts +14 -0
- package/dist/app/jimpex.d.ts +3 -2
- package/dist/app/jimpex.js +225 -0
- package/dist/app/jimpex.js.map +1 -1
- package/dist/controllers/common/config.d.mts +79 -0
- package/dist/controllers/common/config.d.ts +3 -2
- package/dist/controllers/common/config.js +18 -0
- package/dist/controllers/common/config.js.map +1 -1
- package/dist/controllers/common/health.d.mts +83 -0
- package/dist/controllers/common/health.d.ts +4 -3
- package/dist/controllers/common/health.js +18 -0
- package/dist/controllers/common/health.js.map +1 -1
- package/dist/controllers/common/index.d.mts +21 -0
- package/dist/controllers/common/index.d.ts +4 -4
- package/dist/controllers/common/index.js +6 -0
- package/dist/controllers/common/statics.d.mts +215 -0
- package/dist/controllers/common/statics.d.ts +4 -4
- package/dist/controllers/common/statics.js +51 -0
- package/dist/controllers/common/statics.js.map +1 -1
- package/dist/controllers/index.d.mts +24 -0
- package/dist/controllers/index.d.ts +4 -4
- package/dist/controllers/index.js +5 -0
- package/dist/controllers/utils/gateway.d.mts +725 -0
- package/dist/controllers/utils/gateway.d.ts +4 -3
- package/dist/controllers/utils/gateway.js +152 -0
- package/dist/controllers/utils/gateway.js.map +1 -1
- package/dist/controllers/utils/index.d.mts +17 -0
- package/dist/controllers/utils/index.d.ts +4 -3
- package/dist/controllers/utils/index.js +4 -0
- package/dist/esm/app/jimpex.js +222 -1
- package/dist/esm/app/jimpex.js.map +1 -1
- package/dist/esm/{chunk-T2T6Q22Z.js → chunk-2B2CG5KL.js} +1 -1
- package/dist/esm/controllers/common/config.js +19 -1
- package/dist/esm/controllers/common/config.js.map +1 -1
- package/dist/esm/controllers/common/health.js +19 -1
- package/dist/esm/controllers/common/health.js.map +1 -1
- package/dist/esm/controllers/common/statics.js +48 -1
- package/dist/esm/controllers/common/statics.js.map +1 -1
- package/dist/esm/controllers/utils/gateway.js +153 -1
- package/dist/esm/controllers/utils/gateway.js.map +1 -1
- package/dist/esm/middlewares/common/errorHandler.js +25 -1
- package/dist/esm/middlewares/common/errorHandler.js.map +1 -1
- package/dist/esm/middlewares/common/forceHTTPS.js +13 -1
- package/dist/esm/middlewares/common/forceHTTPS.js.map +1 -1
- package/dist/esm/middlewares/common/hsts.js +22 -1
- package/dist/esm/middlewares/common/hsts.js.map +1 -1
- package/dist/esm/middlewares/html/fastHTML.js +55 -1
- package/dist/esm/middlewares/html/fastHTML.js.map +1 -1
- package/dist/esm/middlewares/html/showHTML.js +33 -1
- package/dist/esm/middlewares/html/showHTML.js.map +1 -1
- package/dist/esm/middlewares/utils/versionValidator.js +35 -1
- package/dist/esm/middlewares/utils/versionValidator.js.map +1 -1
- package/dist/esm/services/common/appError.js +48 -2
- package/dist/esm/services/common/appError.js.map +1 -1
- package/dist/esm/services/common/httpError.js +10 -1
- package/dist/esm/services/common/httpError.js.map +1 -1
- package/dist/esm/services/common/index.js +1 -1
- package/dist/esm/services/common/sendFile.js +1 -1
- package/dist/esm/services/frontend/frontendFs.js +29 -1
- package/dist/esm/services/frontend/frontendFs.js.map +1 -1
- package/dist/esm/services/frontend/index.js +1 -1
- package/dist/esm/services/html/htmlGenerator.js +51 -1
- package/dist/esm/services/html/htmlGenerator.js.map +1 -1
- package/dist/esm/services/html/index.js +1 -1
- package/dist/esm/services/http/apiClient.js +27 -1
- package/dist/esm/services/http/apiClient.js.map +1 -1
- package/dist/esm/services/http/http.js +50 -1
- package/dist/esm/services/http/http.js.map +1 -1
- package/dist/esm/services/http/index.js +1 -1
- package/dist/esm/services/http/responsesBuilder.js +49 -2
- package/dist/esm/services/http/responsesBuilder.js.map +1 -1
- package/dist/esm/services/utils/ensureBearerToken.js +17 -1
- package/dist/esm/services/utils/ensureBearerToken.js.map +1 -1
- package/dist/esm/services/utils/index.js +1 -1
- package/dist/esm/utils/fns/others.js +1 -1
- package/dist/esm/utils/fns/routes.js +1 -1
- package/dist/esm/utils/fns/routes.js.map +1 -1
- package/dist/esm/utils/fns/statuses.js +1 -1
- package/dist/esm/utils/fns/text.js +1 -1
- package/dist/esm/utils/wrappers.js +1 -1
- package/dist/{jimpex-7eaee271.d.ts → index-b2a04c78.d.ts} +9 -5
- package/dist/index-efeb437e.d.ts +1282 -0
- package/dist/index.d.mts +46 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +9 -0
- package/dist/middlewares/common/errorHandler.d.mts +132 -0
- package/dist/middlewares/common/errorHandler.d.ts +4 -3
- package/dist/middlewares/common/errorHandler.js +24 -0
- package/dist/middlewares/common/errorHandler.js.map +1 -1
- package/dist/middlewares/common/forceHTTPS.d.mts +69 -0
- package/dist/middlewares/common/forceHTTPS.d.ts +5 -4
- package/dist/middlewares/common/forceHTTPS.js +12 -0
- package/dist/middlewares/common/forceHTTPS.js.map +1 -1
- package/dist/middlewares/common/hsts.d.mts +110 -0
- package/dist/middlewares/common/hsts.d.ts +5 -4
- package/dist/middlewares/common/hsts.js +21 -0
- package/dist/middlewares/common/hsts.js.map +1 -1
- package/dist/middlewares/common/index.d.mts +22 -0
- package/dist/middlewares/common/index.d.ts +4 -3
- package/dist/middlewares/common/index.js +6 -0
- package/dist/middlewares/html/fastHTML.d.mts +180 -0
- package/dist/middlewares/html/fastHTML.d.ts +4 -4
- package/dist/middlewares/html/fastHTML.js +54 -0
- package/dist/middlewares/html/fastHTML.js.map +1 -1
- package/dist/middlewares/html/index.d.mts +21 -0
- package/dist/middlewares/html/index.d.ts +4 -4
- package/dist/middlewares/html/index.js +5 -0
- package/dist/middlewares/html/showHTML.d.mts +127 -0
- package/dist/middlewares/html/showHTML.d.ts +4 -4
- package/dist/middlewares/html/showHTML.js +32 -0
- package/dist/middlewares/html/showHTML.js.map +1 -1
- package/dist/middlewares/index.d.mts +30 -0
- package/dist/middlewares/index.d.ts +4 -4
- package/dist/middlewares/index.js +6 -0
- package/dist/middlewares/utils/index.d.mts +20 -0
- package/dist/middlewares/utils/index.d.ts +4 -3
- package/dist/middlewares/utils/index.js +4 -0
- package/dist/middlewares/utils/versionValidator.d.mts +215 -0
- package/dist/middlewares/utils/versionValidator.d.ts +4 -3
- package/dist/middlewares/utils/versionValidator.js +34 -0
- package/dist/middlewares/utils/versionValidator.js.map +1 -1
- package/dist/services/common/appError.d.mts +139 -0
- package/dist/services/common/appError.d.ts +4 -3
- package/dist/services/common/appError.js +47 -1
- package/dist/services/common/appError.js.map +1 -1
- package/dist/services/common/httpError.d.mts +80 -0
- package/dist/services/common/httpError.d.ts +4 -3
- package/dist/services/common/httpError.js +9 -0
- package/dist/services/common/httpError.js.map +1 -1
- package/dist/services/common/index.d.mts +47 -0
- package/dist/services/common/index.d.ts +4 -4
- package/dist/services/common/index.js +4 -1
- package/dist/services/common/sendFile.d.mts +102 -0
- package/dist/services/common/sendFile.d.ts +3 -3
- package/dist/services/frontend/frontendFs.d.mts +96 -0
- package/dist/services/frontend/frontendFs.d.ts +3 -3
- package/dist/services/frontend/frontendFs.js +32 -0
- package/dist/services/frontend/frontendFs.js.map +1 -1
- package/dist/services/frontend/index.d.mts +40 -0
- package/dist/services/frontend/index.d.ts +4 -4
- package/dist/services/frontend/index.js +2 -1
- package/dist/services/html/htmlGenerator.d.mts +237 -0
- package/dist/services/html/htmlGenerator.d.ts +2 -2
- package/dist/services/html/htmlGenerator.js +50 -0
- package/dist/services/html/htmlGenerator.js.map +1 -1
- package/dist/services/html/index.d.mts +43 -0
- package/dist/services/html/index.d.ts +4 -4
- package/dist/services/html/index.js +2 -1
- package/dist/services/http/apiClient.d.mts +170 -0
- package/dist/services/http/apiClient.d.ts +4 -3
- package/dist/services/http/apiClient.js +26 -0
- package/dist/services/http/apiClient.js.map +1 -1
- package/dist/services/http/http.d.mts +176 -0
- package/dist/services/http/http.d.ts +4 -3
- package/dist/services/http/http.js +53 -0
- package/dist/services/http/http.js.map +1 -1
- package/dist/services/http/index.d.mts +51 -0
- package/dist/services/http/index.d.ts +4 -3
- package/dist/services/http/index.js +4 -1
- package/dist/services/http/responsesBuilder.d.mts +179 -0
- package/dist/services/http/responsesBuilder.d.ts +3 -2
- package/dist/services/http/responsesBuilder.js +48 -1
- package/dist/services/http/responsesBuilder.js.map +1 -1
- package/dist/services/index.d.mts +33 -0
- package/dist/services/index.d.ts +4 -4
- package/dist/services/index.js +8 -0
- package/dist/services/utils/ensureBearerToken.d.mts +158 -0
- package/dist/services/utils/ensureBearerToken.d.ts +5 -4
- package/dist/services/utils/ensureBearerToken.js +16 -0
- package/dist/services/utils/ensureBearerToken.js.map +1 -1
- package/dist/services/utils/index.d.mts +44 -0
- package/dist/services/utils/index.d.ts +4 -3
- package/dist/services/utils/index.js +2 -1
- package/dist/types/events.d.mts +14 -0
- package/dist/types/events.d.ts +5 -4
- package/dist/types/express.d.mts +10 -0
- package/dist/types/http.d.mts +79 -0
- package/dist/types/index.d.mts +14 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.js +9 -0
- package/dist/types/options.d.mts +14 -0
- package/dist/types/options.d.ts +4 -3
- package/dist/types/utils.d.mts +48 -0
- package/dist/types/wootils.d.mts +4 -0
- package/dist/utils/fns/index.d.mts +5 -0
- package/dist/utils/fns/index.js +7 -0
- package/dist/utils/fns/others.d.mts +17 -0
- package/dist/utils/fns/routes.d.mts +39 -0
- package/dist/utils/fns/routes.js.map +1 -1
- package/dist/utils/fns/statuses.d.mts +45 -0
- package/dist/utils/fns/statuses.js +4 -0
- package/dist/utils/fns/statuses.js.map +1 -1
- package/dist/utils/fns/text.d.mts +9 -0
- package/dist/utils/index.d.mts +19 -0
- package/dist/utils/index.d.ts +5 -4
- package/dist/utils/index.js +5 -0
- package/dist/utils/wrappers.d.mts +14 -0
- package/dist/utils/wrappers.d.ts +4 -3
- package/package.json +43 -43
- /package/dist/esm/{chunk-T2T6Q22Z.js.map → chunk-2B2CG5KL.js.map} +0 -0
package/dist/services/index.js
CHANGED
|
@@ -20,4 +20,12 @@ __reExport(services_exports, require("./frontend"), module.exports);
|
|
|
20
20
|
__reExport(services_exports, require("./html"), module.exports);
|
|
21
21
|
__reExport(services_exports, require("./http"), module.exports);
|
|
22
22
|
__reExport(services_exports, require("./utils"), module.exports);
|
|
23
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
24
|
+
0 && (module.exports = {
|
|
25
|
+
...require("./common"),
|
|
26
|
+
...require("./frontend"),
|
|
27
|
+
...require("./html"),
|
|
28
|
+
...require("./http"),
|
|
29
|
+
...require("./utils")
|
|
30
|
+
});
|
|
23
31
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
+
import { J as Jimpex } from '../../index-efeb437e.js';
|
|
3
|
+
import { ExpressMiddleware } from '../../types/express.mjs';
|
|
4
|
+
import { Statuses } from '../../utils/fns/statuses.mjs';
|
|
5
|
+
import { DeepPartial } from '../../types/utils.mjs';
|
|
6
|
+
import { HTTPErrorClass } from '../common/httpError.mjs';
|
|
7
|
+
import '../../types/http.mjs';
|
|
8
|
+
import 'https';
|
|
9
|
+
import 'http';
|
|
10
|
+
import 'spdy';
|
|
11
|
+
import 'express';
|
|
12
|
+
import 'node-fetch';
|
|
13
|
+
import '@homer0/path-utils';
|
|
14
|
+
import '@homer0/simple-logger';
|
|
15
|
+
import '@homer0/simple-config';
|
|
16
|
+
import '@homer0/events-hub';
|
|
17
|
+
import 'statuses';
|
|
18
|
+
import '../common/appError.mjs';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The options for the error the middleare can generate.
|
|
22
|
+
*
|
|
23
|
+
* @group Services/EnsureBearerToken
|
|
24
|
+
*/
|
|
25
|
+
type EnsureBearerTokenErrorOptions = {
|
|
26
|
+
/**
|
|
27
|
+
* The error message for the response.
|
|
28
|
+
*
|
|
29
|
+
* @default 'Unauthorized'
|
|
30
|
+
*/
|
|
31
|
+
message: string;
|
|
32
|
+
/**
|
|
33
|
+
* The HTTP status that will be added to the error context.
|
|
34
|
+
*
|
|
35
|
+
* @default 401
|
|
36
|
+
*/
|
|
37
|
+
status: number;
|
|
38
|
+
/**
|
|
39
|
+
* Context information for the error handler and that can be added to the actual
|
|
40
|
+
* response.
|
|
41
|
+
*/
|
|
42
|
+
response: unknown;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* The options to customize the service/middleware.
|
|
46
|
+
*
|
|
47
|
+
* @group Services/EnsureBearerToken
|
|
48
|
+
*/
|
|
49
|
+
type EnsureBearerTokenOptions = {
|
|
50
|
+
error: EnsureBearerTokenErrorOptions;
|
|
51
|
+
expression: RegExp;
|
|
52
|
+
local: string;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* The options to construct a {@link EnsureBearerToken}.
|
|
56
|
+
*
|
|
57
|
+
* @group Services/EnsureBearerToken
|
|
58
|
+
*/
|
|
59
|
+
type EnsureBearerConstructorOptions = DeepPartial<EnsureBearerTokenOptions> & {
|
|
60
|
+
/**
|
|
61
|
+
* A dictionary with the dependencies to inject.
|
|
62
|
+
*/
|
|
63
|
+
inject: {
|
|
64
|
+
HTTPError: HTTPErrorClass;
|
|
65
|
+
statuses: Statuses;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Custom options for the provider that will register an instance of
|
|
70
|
+
* {@link EnsureBearerToken}
|
|
71
|
+
* as a service.
|
|
72
|
+
*
|
|
73
|
+
* @group Services/EnsureBearerToken
|
|
74
|
+
*/
|
|
75
|
+
type EnsureBearerTokenProviderOptions = DeepPartial<EnsureBearerTokenOptions> & {
|
|
76
|
+
/**
|
|
77
|
+
* The name that will be used to register the service on the container. This is to allow
|
|
78
|
+
* multiple "instances" of the service to be created.
|
|
79
|
+
*
|
|
80
|
+
* @default 'ensureBearerToken'
|
|
81
|
+
*/
|
|
82
|
+
serviceName?: string;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* This service gives you a middleware that verifies if a request has an `Authorization`
|
|
86
|
+
* header with a bearer token; if it does, the token will be saved on the `res.locals`,
|
|
87
|
+
* otherwise, it will generate an error.
|
|
88
|
+
*
|
|
89
|
+
* This is a "service middleware" to allow certain flexibility: you can have controllers
|
|
90
|
+
* where some routes are protected and others are not. For those cases, you get the
|
|
91
|
+
* service from the container, and include it only in the routes that need it.
|
|
92
|
+
*
|
|
93
|
+
* @group Services
|
|
94
|
+
* @group Services/EnsureBearerToken
|
|
95
|
+
*/
|
|
96
|
+
declare class EnsureBearerToken {
|
|
97
|
+
/**
|
|
98
|
+
* To generate the errors when the validation fails.
|
|
99
|
+
*/
|
|
100
|
+
protected readonly _HTTPError: HTTPErrorClass;
|
|
101
|
+
/**
|
|
102
|
+
* The customization options for the service.
|
|
103
|
+
*/
|
|
104
|
+
protected readonly _options: EnsureBearerTokenOptions;
|
|
105
|
+
/**
|
|
106
|
+
* @param options The options to construct the class.
|
|
107
|
+
*/
|
|
108
|
+
constructor({ inject: { HTTPError, statuses }, ...options }: EnsureBearerConstructorOptions);
|
|
109
|
+
/**
|
|
110
|
+
* Generates the middleware that verifies if a request has an `Authorization` header
|
|
111
|
+
* with a bearer token.
|
|
112
|
+
*/
|
|
113
|
+
getMiddleware(): ExpressMiddleware;
|
|
114
|
+
/**
|
|
115
|
+
* The customization options.
|
|
116
|
+
*/
|
|
117
|
+
get options(): Readonly<EnsureBearerTokenOptions>;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Generates a "service middleware" that can be used on route controllers in order to
|
|
121
|
+
* validate the presence of a bearer token on the requests authorization header.
|
|
122
|
+
*
|
|
123
|
+
* The registered service is an instance of {@link EnsureBearerToken}, and it uses the key
|
|
124
|
+
* `ensureBearerToken`.
|
|
125
|
+
*
|
|
126
|
+
* Since it's a "provider creator", when registering it, you can pass custom options.
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
*
|
|
130
|
+
* <caption>Basic usage</caption>
|
|
131
|
+
*
|
|
132
|
+
* // Register it on the container
|
|
133
|
+
* container.register(ensureBearerTokenProvider);
|
|
134
|
+
*
|
|
135
|
+
* // Let's assume we are in a controller now...
|
|
136
|
+
* // Getting access to the middleware.
|
|
137
|
+
* const ensureBearerToken = container.get<ExpressMiddleware>('ensureBearerToken');
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
*
|
|
141
|
+
* <caption>Customizing the service</caption>
|
|
142
|
+
*
|
|
143
|
+
* // Register it on the container
|
|
144
|
+
* container.register(
|
|
145
|
+
* ensureBearerTokenProvider({
|
|
146
|
+
* serviceName: 'ensureBearerTokenCustom',
|
|
147
|
+
* error: {
|
|
148
|
+
* message: 'Missing token!',
|
|
149
|
+
* },
|
|
150
|
+
* }),
|
|
151
|
+
* );
|
|
152
|
+
*
|
|
153
|
+
* @group Providers
|
|
154
|
+
* @group Services/EnsureBearerToken
|
|
155
|
+
*/
|
|
156
|
+
declare const ensureBearerTokenProvider: _homer0_jimple.ResourceCreator<"provider", "register", (options?: EnsureBearerTokenProviderOptions) => (app: Jimpex) => void, _homer0_jimple.ProviderRegisterFn<Jimpex>>;
|
|
157
|
+
|
|
158
|
+
export { EnsureBearerConstructorOptions, EnsureBearerToken, EnsureBearerTokenErrorOptions, EnsureBearerTokenOptions, EnsureBearerTokenProviderOptions, ensureBearerTokenProvider };
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
-
import { J as Jimpex } from '../../
|
|
2
|
+
import { J as Jimpex } from '../../index-b2a04c78.js';
|
|
3
3
|
import { ExpressMiddleware } from '../../types/express.js';
|
|
4
4
|
import { Statuses } from '../../utils/fns/statuses.js';
|
|
5
5
|
import { DeepPartial } from '../../types/utils.js';
|
|
6
6
|
import { HTTPErrorClass } from '../common/httpError.js';
|
|
7
|
-
import '@homer0/events-hub';
|
|
8
|
-
import 'express';
|
|
9
7
|
import '../../types/http.js';
|
|
10
8
|
import 'https';
|
|
11
9
|
import 'http';
|
|
12
10
|
import 'spdy';
|
|
11
|
+
import 'express';
|
|
13
12
|
import 'node-fetch';
|
|
14
|
-
import '@homer0/
|
|
13
|
+
import '@homer0/path-utils';
|
|
15
14
|
import '@homer0/simple-logger';
|
|
15
|
+
import '@homer0/simple-config';
|
|
16
|
+
import '@homer0/events-hub';
|
|
16
17
|
import 'statuses';
|
|
17
18
|
import '../common/appError.js';
|
|
18
19
|
|
|
@@ -30,11 +30,20 @@ module.exports = __toCommonJS(ensureBearerToken_exports);
|
|
|
30
30
|
var import_deep_assign = require("@homer0/deep-assign");
|
|
31
31
|
var import_utils = require("../../utils");
|
|
32
32
|
class EnsureBearerToken {
|
|
33
|
+
/**
|
|
34
|
+
* @param options The options to construct the class.
|
|
35
|
+
*/
|
|
33
36
|
constructor({
|
|
34
37
|
inject: { HTTPError, statuses },
|
|
35
38
|
...options
|
|
36
39
|
}) {
|
|
40
|
+
/**
|
|
41
|
+
* To generate the errors when the validation fails.
|
|
42
|
+
*/
|
|
37
43
|
__publicField(this, "_HTTPError");
|
|
44
|
+
/**
|
|
45
|
+
* The customization options for the service.
|
|
46
|
+
*/
|
|
38
47
|
__publicField(this, "_options");
|
|
39
48
|
this._HTTPError = HTTPError;
|
|
40
49
|
this._options = (0, import_deep_assign.deepAssignWithOverwrite)(
|
|
@@ -50,6 +59,10 @@ class EnsureBearerToken {
|
|
|
50
59
|
options
|
|
51
60
|
);
|
|
52
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Generates the middleware that verifies if a request has an `Authorization` header
|
|
64
|
+
* with a bearer token.
|
|
65
|
+
*/
|
|
53
66
|
getMiddleware() {
|
|
54
67
|
return (req, res, next) => {
|
|
55
68
|
let unauthorized = true;
|
|
@@ -78,6 +91,9 @@ class EnsureBearerToken {
|
|
|
78
91
|
}
|
|
79
92
|
};
|
|
80
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* The customization options.
|
|
96
|
+
*/
|
|
81
97
|
get options() {
|
|
82
98
|
return (0, import_deep_assign.deepAssignWithOverwrite)({}, this._options);
|
|
83
99
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/services/utils/ensureBearerToken.ts"],"sourcesContent":["import { deepAssignWithOverwrite } from '@homer0/deep-assign';\nimport { providerCreator, type Statuses } from '../../utils';\nimport type { HTTPErrorClass } from '../common';\nimport type { DeepPartial, ExpressMiddleware } from '../../types';\n/**\n * The options for the error the middleare can generate.\n *\n * @group Services/EnsureBearerToken\n */\nexport type EnsureBearerTokenErrorOptions = {\n /**\n * The error message for the response.\n *\n * @default 'Unauthorized'\n */\n message: string;\n /**\n * The HTTP status that will be added to the error context.\n *\n * @default 401\n */\n status: number;\n /**\n * Context information for the error handler and that can be added to the actual\n * response.\n */\n response: unknown;\n};\n/**\n * The options to customize the service/middleware.\n *\n * @group Services/EnsureBearerToken\n */\nexport type EnsureBearerTokenOptions = {\n error: EnsureBearerTokenErrorOptions;\n expression: RegExp;\n local: string;\n};\n/**\n * The options to construct a {@link EnsureBearerToken}.\n *\n * @group Services/EnsureBearerToken\n */\nexport type EnsureBearerConstructorOptions = DeepPartial<EnsureBearerTokenOptions> & {\n /**\n * A dictionary with the dependencies to inject.\n */\n inject: {\n HTTPError: HTTPErrorClass;\n statuses: Statuses;\n };\n};\n/**\n * Custom options for the provider that will register an instance of\n * {@link EnsureBearerToken}\n * as a service.\n *\n * @group Services/EnsureBearerToken\n */\nexport type EnsureBearerTokenProviderOptions = DeepPartial<EnsureBearerTokenOptions> & {\n /**\n * The name that will be used to register the service on the container. This is to allow\n * multiple \"instances\" of the service to be created.\n *\n * @default 'ensureBearerToken'\n */\n serviceName?: string;\n};\n/**\n * This service gives you a middleware that verifies if a request has an `Authorization`\n * header with a bearer token; if it does, the token will be saved on the `res.locals`,\n * otherwise, it will generate an error.\n *\n * This is a \"service middleware\" to allow certain flexibility: you can have controllers\n * where some routes are protected and others are not. For those cases, you get the\n * service from the container, and include it only in the routes that need it.\n *\n * @group Services\n * @group Services/EnsureBearerToken\n */\nexport class EnsureBearerToken {\n /**\n * To generate the errors when the validation fails.\n */\n protected readonly _HTTPError: HTTPErrorClass;\n /**\n * The customization options for the service.\n */\n protected readonly _options: EnsureBearerTokenOptions;\n /**\n * @param options The options to construct the class.\n */\n constructor({\n inject: { HTTPError, statuses },\n ...options\n }: EnsureBearerConstructorOptions) {\n this._HTTPError = HTTPError;\n this._options = deepAssignWithOverwrite(\n {\n error: {\n message: 'Unauthorized',\n status: statuses('unauthorized'),\n response: {},\n },\n expression: /bearer (.*?)(?:$|\\s)/i,\n local: 'token',\n },\n options,\n );\n }\n /**\n * Generates the middleware that verifies if a request has an `Authorization` header\n * with a bearer token.\n */\n getMiddleware(): ExpressMiddleware {\n return (req, res, next) => {\n let unauthorized = true;\n const {\n headers: { authorization },\n } = req;\n if (authorization) {\n const matches = this._options.expression.exec(authorization);\n if (matches) {\n const [, token] = matches;\n res.locals[this._options.local] = token;\n unauthorized = false;\n }\n }\n\n if (unauthorized) {\n const {\n error: { message, status, response },\n } = this._options;\n next(\n new this._HTTPError(message, status, {\n response,\n }),\n );\n } else {\n next();\n }\n };\n }\n /**\n * The customization options.\n */\n get options(): Readonly<EnsureBearerTokenOptions> {\n return deepAssignWithOverwrite({}, this._options);\n }\n}\n/**\n * Generates a \"service middleware\" that can be used on route controllers in order to\n * validate the presence of a bearer token on the requests authorization header.\n *\n * The registered service is an instance of {@link EnsureBearerToken}, and it uses the key\n * `ensureBearerToken`.\n *\n * Since it's a \"provider creator\", when registering it, you can pass custom options.\n *\n * @example\n *\n * <caption>Basic usage</caption>\n *\n * // Register it on the container\n * container.register(ensureBearerTokenProvider);\n *\n * // Let's assume we are in a controller now...\n * // Getting access to the middleware.\n * const ensureBearerToken = container.get<ExpressMiddleware>('ensureBearerToken');\n *\n * @example\n *\n * <caption>Customizing the service</caption>\n *\n * // Register it on the container\n * container.register(\n * ensureBearerTokenProvider({\n * serviceName: 'ensureBearerTokenCustom',\n * error: {\n * message: 'Missing token!',\n * },\n * }),\n * );\n *\n * @group Providers\n * @group Services/EnsureBearerToken\n */\nexport const ensureBearerTokenProvider = providerCreator(\n (options: EnsureBearerTokenProviderOptions = {}) =>\n (app) => {\n const { serviceName = 'ensureBearerToken', ...rest } = options;\n app.set(serviceName, () =>\n new EnsureBearerToken({\n inject: {\n HTTPError: app.get('HTTPError'),\n statuses: app.get('statuses'),\n },\n ...rest,\n }).getMiddleware(),\n );\n },\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAwC;AACxC,mBAA+C;AA+ExC,MAAM,kBAAkB;AAAA,EAY7B,YAAY;AAAA,IACV,QAAQ,EAAE,WAAW,SAAS;AAAA,
|
|
1
|
+
{"version":3,"sources":["../../../src/services/utils/ensureBearerToken.ts"],"sourcesContent":["import { deepAssignWithOverwrite } from '@homer0/deep-assign';\nimport { providerCreator, type Statuses } from '../../utils';\nimport type { HTTPErrorClass } from '../common';\nimport type { DeepPartial, ExpressMiddleware } from '../../types';\n/**\n * The options for the error the middleare can generate.\n *\n * @group Services/EnsureBearerToken\n */\nexport type EnsureBearerTokenErrorOptions = {\n /**\n * The error message for the response.\n *\n * @default 'Unauthorized'\n */\n message: string;\n /**\n * The HTTP status that will be added to the error context.\n *\n * @default 401\n */\n status: number;\n /**\n * Context information for the error handler and that can be added to the actual\n * response.\n */\n response: unknown;\n};\n/**\n * The options to customize the service/middleware.\n *\n * @group Services/EnsureBearerToken\n */\nexport type EnsureBearerTokenOptions = {\n error: EnsureBearerTokenErrorOptions;\n expression: RegExp;\n local: string;\n};\n/**\n * The options to construct a {@link EnsureBearerToken}.\n *\n * @group Services/EnsureBearerToken\n */\nexport type EnsureBearerConstructorOptions = DeepPartial<EnsureBearerTokenOptions> & {\n /**\n * A dictionary with the dependencies to inject.\n */\n inject: {\n HTTPError: HTTPErrorClass;\n statuses: Statuses;\n };\n};\n/**\n * Custom options for the provider that will register an instance of\n * {@link EnsureBearerToken}\n * as a service.\n *\n * @group Services/EnsureBearerToken\n */\nexport type EnsureBearerTokenProviderOptions = DeepPartial<EnsureBearerTokenOptions> & {\n /**\n * The name that will be used to register the service on the container. This is to allow\n * multiple \"instances\" of the service to be created.\n *\n * @default 'ensureBearerToken'\n */\n serviceName?: string;\n};\n/**\n * This service gives you a middleware that verifies if a request has an `Authorization`\n * header with a bearer token; if it does, the token will be saved on the `res.locals`,\n * otherwise, it will generate an error.\n *\n * This is a \"service middleware\" to allow certain flexibility: you can have controllers\n * where some routes are protected and others are not. For those cases, you get the\n * service from the container, and include it only in the routes that need it.\n *\n * @group Services\n * @group Services/EnsureBearerToken\n */\nexport class EnsureBearerToken {\n /**\n * To generate the errors when the validation fails.\n */\n protected readonly _HTTPError: HTTPErrorClass;\n /**\n * The customization options for the service.\n */\n protected readonly _options: EnsureBearerTokenOptions;\n /**\n * @param options The options to construct the class.\n */\n constructor({\n inject: { HTTPError, statuses },\n ...options\n }: EnsureBearerConstructorOptions) {\n this._HTTPError = HTTPError;\n this._options = deepAssignWithOverwrite(\n {\n error: {\n message: 'Unauthorized',\n status: statuses('unauthorized'),\n response: {},\n },\n expression: /bearer (.*?)(?:$|\\s)/i,\n local: 'token',\n },\n options,\n );\n }\n /**\n * Generates the middleware that verifies if a request has an `Authorization` header\n * with a bearer token.\n */\n getMiddleware(): ExpressMiddleware {\n return (req, res, next) => {\n let unauthorized = true;\n const {\n headers: { authorization },\n } = req;\n if (authorization) {\n const matches = this._options.expression.exec(authorization);\n if (matches) {\n const [, token] = matches;\n res.locals[this._options.local] = token;\n unauthorized = false;\n }\n }\n\n if (unauthorized) {\n const {\n error: { message, status, response },\n } = this._options;\n next(\n new this._HTTPError(message, status, {\n response,\n }),\n );\n } else {\n next();\n }\n };\n }\n /**\n * The customization options.\n */\n get options(): Readonly<EnsureBearerTokenOptions> {\n return deepAssignWithOverwrite({}, this._options);\n }\n}\n/**\n * Generates a \"service middleware\" that can be used on route controllers in order to\n * validate the presence of a bearer token on the requests authorization header.\n *\n * The registered service is an instance of {@link EnsureBearerToken}, and it uses the key\n * `ensureBearerToken`.\n *\n * Since it's a \"provider creator\", when registering it, you can pass custom options.\n *\n * @example\n *\n * <caption>Basic usage</caption>\n *\n * // Register it on the container\n * container.register(ensureBearerTokenProvider);\n *\n * // Let's assume we are in a controller now...\n * // Getting access to the middleware.\n * const ensureBearerToken = container.get<ExpressMiddleware>('ensureBearerToken');\n *\n * @example\n *\n * <caption>Customizing the service</caption>\n *\n * // Register it on the container\n * container.register(\n * ensureBearerTokenProvider({\n * serviceName: 'ensureBearerTokenCustom',\n * error: {\n * message: 'Missing token!',\n * },\n * }),\n * );\n *\n * @group Providers\n * @group Services/EnsureBearerToken\n */\nexport const ensureBearerTokenProvider = providerCreator(\n (options: EnsureBearerTokenProviderOptions = {}) =>\n (app) => {\n const { serviceName = 'ensureBearerToken', ...rest } = options;\n app.set(serviceName, () =>\n new EnsureBearerToken({\n inject: {\n HTTPError: app.get('HTTPError'),\n statuses: app.get('statuses'),\n },\n ...rest,\n }).getMiddleware(),\n );\n },\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAwC;AACxC,mBAA+C;AA+ExC,MAAM,kBAAkB;AAAA;AAAA;AAAA;AAAA,EAY7B,YAAY;AAAA,IACV,QAAQ,EAAE,WAAW,SAAS;AAAA,IAC9B,GAAG;AAAA,EACL,GAAmC;AAXnC;AAAA;AAAA;AAAA,wBAAmB;AAInB;AAAA;AAAA;AAAA,wBAAmB;AAQjB,SAAK,aAAa;AAClB,SAAK,eAAW;AAAA,MACd;AAAA,QACE,OAAO;AAAA,UACL,SAAS;AAAA,UACT,QAAQ,SAAS,cAAc;AAAA,UAC/B,UAAU,CAAC;AAAA,QACb;AAAA,QACA,YAAY;AAAA,QACZ,OAAO;AAAA,MACT;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAKA,gBAAmC;AACjC,WAAO,CAAC,KAAK,KAAK,SAAS;AACzB,UAAI,eAAe;AACnB,YAAM;AAAA,QACJ,SAAS,EAAE,cAAc;AAAA,MAC3B,IAAI;AACJ,UAAI,eAAe;AACjB,cAAM,UAAU,KAAK,SAAS,WAAW,KAAK,aAAa;AAC3D,YAAI,SAAS;AACX,gBAAM,CAAC,EAAE,KAAK,IAAI;AAClB,cAAI,OAAO,KAAK,SAAS,KAAK,IAAI;AAClC,yBAAe;AAAA,QACjB;AAAA,MACF;AAEA,UAAI,cAAc;AAChB,cAAM;AAAA,UACJ,OAAO,EAAE,SAAS,QAAQ,SAAS;AAAA,QACrC,IAAI,KAAK;AACT;AAAA,UACE,IAAI,KAAK,WAAW,SAAS,QAAQ;AAAA,YACnC;AAAA,UACF,CAAC;AAAA,QACH;AAAA,MACF,OAAO;AACL,aAAK;AAAA,MACP;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAIA,IAAI,UAA8C;AAChD,eAAO,4CAAwB,CAAC,GAAG,KAAK,QAAQ;AAAA,EAClD;AACF;AAsCO,MAAM,gCAA4B;AAAA,EACvC,CAAC,UAA4C,CAAC,MAC5C,CAAC,QAAQ;AACP,UAAM,EAAE,cAAc,qBAAqB,GAAG,KAAK,IAAI;AACvD,QAAI;AAAA,MAAI;AAAA,MAAa,MACnB,IAAI,kBAAkB;AAAA,QACpB,QAAQ;AAAA,UACN,WAAW,IAAI,IAAI,WAAW;AAAA,UAC9B,UAAU,IAAI,IAAI,UAAU;AAAA,QAC9B;AAAA,QACA,GAAG;AAAA,MACL,CAAC,EAAE,cAAc;AAAA,IACnB;AAAA,EACF;AACJ;","names":[]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
+
import { J as Jimpex } from '../../index-efeb437e.js';
|
|
3
|
+
import { EnsureBearerTokenProviderOptions } from './ensureBearerToken.mjs';
|
|
4
|
+
export { EnsureBearerConstructorOptions, EnsureBearerToken, EnsureBearerTokenErrorOptions, EnsureBearerTokenOptions, ensureBearerTokenProvider } from './ensureBearerToken.mjs';
|
|
5
|
+
import '../../types/express.mjs';
|
|
6
|
+
import 'express';
|
|
7
|
+
import '../../types/http.mjs';
|
|
8
|
+
import 'https';
|
|
9
|
+
import 'http';
|
|
10
|
+
import 'spdy';
|
|
11
|
+
import 'node-fetch';
|
|
12
|
+
import '../../types/utils.mjs';
|
|
13
|
+
import '@homer0/path-utils';
|
|
14
|
+
import '@homer0/simple-logger';
|
|
15
|
+
import '@homer0/simple-config';
|
|
16
|
+
import '@homer0/events-hub';
|
|
17
|
+
import '../../utils/fns/statuses.mjs';
|
|
18
|
+
import 'statuses';
|
|
19
|
+
import '../common/httpError.mjs';
|
|
20
|
+
import '../common/appError.mjs';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Registers all the utility services on the container.
|
|
24
|
+
*
|
|
25
|
+
* - {@link EnsureBearerToken | ensureBearerToken}
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
*
|
|
29
|
+
* // Register the collection on the container
|
|
30
|
+
* container.register(utilsServicesProvider);
|
|
31
|
+
* // Getting access to one the services instance
|
|
32
|
+
* const ensureBearerToken = container.get<EnsureBearerToken>('ensureBearerToken');
|
|
33
|
+
*
|
|
34
|
+
* @group Providers
|
|
35
|
+
*/
|
|
36
|
+
declare const utilsServicesProvider: {
|
|
37
|
+
ensureBearerTokenProvider: _homer0_jimple.ResourceCreator<"provider", "register", (options?: EnsureBearerTokenProviderOptions) => (app: Jimpex) => void, _homer0_jimple.ProviderRegisterFn<Jimpex>>;
|
|
38
|
+
} & Record<string, _homer0_jimple.Resource<"provider", "register", _homer0_jimple.ProviderRegisterFn<Jimpex>>> & {
|
|
39
|
+
provider: true;
|
|
40
|
+
} & {
|
|
41
|
+
register: _homer0_jimple.ProviderRegisterFn<Jimpex>;
|
|
42
|
+
} & Record<string, unknown>;
|
|
43
|
+
|
|
44
|
+
export { EnsureBearerTokenProviderOptions, utilsServicesProvider };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
-
import { J as Jimpex } from '../../
|
|
2
|
+
import { J as Jimpex } from '../../index-b2a04c78.js';
|
|
3
3
|
import { EnsureBearerTokenProviderOptions } from './ensureBearerToken.js';
|
|
4
4
|
export { EnsureBearerConstructorOptions, EnsureBearerToken, EnsureBearerTokenErrorOptions, EnsureBearerTokenOptions, ensureBearerTokenProvider } from './ensureBearerToken.js';
|
|
5
|
-
import '@homer0/events-hub';
|
|
6
5
|
import '../../types/express.js';
|
|
7
6
|
import 'express';
|
|
8
7
|
import '../../types/http.js';
|
|
@@ -10,9 +9,11 @@ import 'https';
|
|
|
10
9
|
import 'http';
|
|
11
10
|
import 'spdy';
|
|
12
11
|
import 'node-fetch';
|
|
13
|
-
import '@homer0/simple-config';
|
|
14
12
|
import '../../types/utils.js';
|
|
13
|
+
import '@homer0/path-utils';
|
|
15
14
|
import '@homer0/simple-logger';
|
|
15
|
+
import '@homer0/simple-config';
|
|
16
|
+
import '@homer0/events-hub';
|
|
16
17
|
import '../../utils/fns/statuses.js';
|
|
17
18
|
import 'statuses';
|
|
18
19
|
import '../common/httpError.js';
|
|
@@ -30,6 +30,7 @@ const utilsServicesProvider = (0, import_utils.providers)({
|
|
|
30
30
|
});
|
|
31
31
|
// Annotate the CommonJS export names for ESM import in node:
|
|
32
32
|
0 && (module.exports = {
|
|
33
|
-
utilsServicesProvider
|
|
33
|
+
utilsServicesProvider,
|
|
34
|
+
...require("./ensureBearerToken")
|
|
34
35
|
});
|
|
35
36
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import './express.mjs';
|
|
2
|
+
export { E as EventPayload, l as Events, k as JimpexEventListener, b as JimpexEventName, i as JimpexEventNameLike, c as JimpexEventPayload, a as JimpexEvents, f as JimpexReducerEventName, h as JimpexReducerEventPayload, e as JimpexReducerEventPayloads, g as JimpexReducerEventTarget, d as JimpexReducerEventTargets } from '../index-efeb437e.js';
|
|
3
|
+
import 'express';
|
|
4
|
+
import './http.mjs';
|
|
5
|
+
import 'https';
|
|
6
|
+
import 'http';
|
|
7
|
+
import 'spdy';
|
|
8
|
+
import 'node-fetch';
|
|
9
|
+
import './utils.mjs';
|
|
10
|
+
import '@homer0/path-utils';
|
|
11
|
+
import '@homer0/simple-logger';
|
|
12
|
+
import '@homer0/simple-config';
|
|
13
|
+
import '@homer0/events-hub';
|
|
14
|
+
import '@homer0/jimple';
|
package/dist/types/events.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import './express.js';
|
|
2
|
-
export { E as EventPayload, l as Events, k as JimpexEventListener, b as JimpexEventName, i as JimpexEventNameLike, c as JimpexEventPayload, a as JimpexEvents, f as JimpexReducerEventName, h as JimpexReducerEventPayload, e as JimpexReducerEventPayloads, g as JimpexReducerEventTarget, d as JimpexReducerEventTargets } from '../
|
|
2
|
+
export { E as EventPayload, l as Events, k as JimpexEventListener, b as JimpexEventName, i as JimpexEventNameLike, c as JimpexEventPayload, a as JimpexEvents, f as JimpexReducerEventName, h as JimpexReducerEventPayload, e as JimpexReducerEventPayloads, g as JimpexReducerEventTarget, d as JimpexReducerEventTargets } from '../index-b2a04c78.js';
|
|
3
3
|
import 'express';
|
|
4
|
-
import '@homer0/jimple';
|
|
5
|
-
import '@homer0/events-hub';
|
|
6
4
|
import './http.js';
|
|
7
5
|
import 'https';
|
|
8
6
|
import 'http';
|
|
9
7
|
import 'spdy';
|
|
10
8
|
import 'node-fetch';
|
|
11
|
-
import '@homer0/simple-config';
|
|
12
9
|
import './utils.js';
|
|
10
|
+
import '@homer0/path-utils';
|
|
13
11
|
import '@homer0/simple-logger';
|
|
12
|
+
import '@homer0/simple-config';
|
|
13
|
+
import '@homer0/events-hub';
|
|
14
|
+
import '@homer0/jimple';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RequestHandler, ErrorRequestHandler } from 'express';
|
|
2
|
+
export { Express, NextFunction, Request, Response, Router } from 'express';
|
|
3
|
+
|
|
4
|
+
type ExpressMiddlewareLike = RequestHandler | ErrorRequestHandler;
|
|
5
|
+
type ExpressMiddleware = RequestHandler;
|
|
6
|
+
type AsyncExpressMiddleware = (...args: Parameters<ExpressMiddleware>) => Promise<void>;
|
|
7
|
+
type ExpressErrorHandler = ErrorRequestHandler;
|
|
8
|
+
type RouterMethod = 'all' | 'get' | 'head' | 'post' | 'patch' | 'put' | 'delete' | 'connect' | 'options' | 'trace';
|
|
9
|
+
|
|
10
|
+
export { AsyncExpressMiddleware, ExpressErrorHandler, ExpressMiddleware, ExpressMiddlewareLike, RouterMethod };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Server } from 'https';
|
|
2
|
+
export { Server as HTTPSServer } from 'https';
|
|
3
|
+
import { Server as Server$1 } from 'http';
|
|
4
|
+
export { Server as HTTPServer } from 'http';
|
|
5
|
+
import { ServerOptions } from 'spdy';
|
|
6
|
+
import { Express } from 'express';
|
|
7
|
+
export { Response as HTTPResponse } from 'node-fetch';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @group Jimpex
|
|
11
|
+
*/
|
|
12
|
+
type JimpexServer = Express | Server;
|
|
13
|
+
/**
|
|
14
|
+
* @group Jimpex
|
|
15
|
+
*/
|
|
16
|
+
type JimpexServerInstance = Server$1 | Server;
|
|
17
|
+
/**
|
|
18
|
+
* The paths to the SSL credentials. Depending on the application options, they can be
|
|
19
|
+
* relative to the project root, or the application executable, but they can't be
|
|
20
|
+
* absolute.
|
|
21
|
+
*
|
|
22
|
+
* @group Jimpex
|
|
23
|
+
*/
|
|
24
|
+
type JimpexHTTPSCredentials = {
|
|
25
|
+
/**
|
|
26
|
+
* The path to the certificate authority file.
|
|
27
|
+
*/
|
|
28
|
+
ca?: string;
|
|
29
|
+
/**
|
|
30
|
+
* The path to the certificate file.
|
|
31
|
+
*/
|
|
32
|
+
cert?: string;
|
|
33
|
+
/**
|
|
34
|
+
* The path to the key file.
|
|
35
|
+
*/
|
|
36
|
+
key?: string;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* The options to enable HTTP2.
|
|
40
|
+
*
|
|
41
|
+
* @group Jimpex
|
|
42
|
+
*/
|
|
43
|
+
type JimpexHTTP2Options = {
|
|
44
|
+
/**
|
|
45
|
+
* Whether or not to enable HTTP2.
|
|
46
|
+
*/
|
|
47
|
+
enabled?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Custom options for the Spdy server.
|
|
50
|
+
*
|
|
51
|
+
* @see {@link https://github.com/spdy-http2/node-spdy#options}
|
|
52
|
+
*/
|
|
53
|
+
spdy?: ServerOptions['spdy'];
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* The options to enable HTTPS.
|
|
57
|
+
*
|
|
58
|
+
* @group Jimpex
|
|
59
|
+
*/
|
|
60
|
+
type JimpexHTTPSOptions = {
|
|
61
|
+
/**
|
|
62
|
+
* Whether or not to enable HTTPS.
|
|
63
|
+
*/
|
|
64
|
+
enabled?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* The SSL credentials, and their location.
|
|
67
|
+
*/
|
|
68
|
+
credentials?: JimpexHTTPSCredentials & {
|
|
69
|
+
/**
|
|
70
|
+
* If `true`, the credentials will be located relative to the project root, otherwise,
|
|
71
|
+
* they will be located relative to the application executable.
|
|
72
|
+
*
|
|
73
|
+
* @default false
|
|
74
|
+
*/
|
|
75
|
+
onHome?: boolean;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export { JimpexHTTP2Options, JimpexHTTPSCredentials, JimpexHTTPSOptions, JimpexServer, JimpexServerInstance };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { E as EventPayload, l as Events, m as JimpexConfigOptions, k as JimpexEventListener, b as JimpexEventName, i as JimpexEventNameLike, c as JimpexEventPayload, a as JimpexEvents, o as JimpexExpressOptions, s as JimpexHealthCheckFn, r as JimpexHealthStatus, t as JimpexOptions, p as JimpexPathOptions, f as JimpexReducerEventName, h as JimpexReducerEventPayload, e as JimpexReducerEventPayloads, g as JimpexReducerEventTarget, d as JimpexReducerEventTargets, q as JimpexServicesOptions, u as JimpexStartCallback, n as JimpexStaticsOptions } from '../index-efeb437e.js';
|
|
2
|
+
export { AsyncExpressMiddleware, ExpressErrorHandler, ExpressMiddleware, ExpressMiddlewareLike, RouterMethod } from './express.mjs';
|
|
3
|
+
export { JimpexHTTP2Options, JimpexHTTPSCredentials, JimpexHTTPSOptions, JimpexServer, JimpexServerInstance } from './http.mjs';
|
|
4
|
+
export { DeepPartial, DeepReadonly, Dict, NoStringIndex } from './utils.mjs';
|
|
5
|
+
export { PathUtils } from '@homer0/path-utils';
|
|
6
|
+
export { SimpleLogger as Logger } from '@homer0/simple-logger';
|
|
7
|
+
export { SimpleConfig as Config } from '@homer0/simple-config';
|
|
8
|
+
export { EventsHub } from '@homer0/events-hub';
|
|
9
|
+
export { Express, NextFunction, Request, Response, Router } from 'express';
|
|
10
|
+
export { Response as HTTPResponse } from 'node-fetch';
|
|
11
|
+
export { Server as HTTPSServer } from 'https';
|
|
12
|
+
export { Server as HTTPServer } from 'http';
|
|
13
|
+
import '@homer0/jimple';
|
|
14
|
+
import 'spdy';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { E as EventPayload, l as Events, m as JimpexConfigOptions, k as JimpexEventListener, b as JimpexEventName, i as JimpexEventNameLike, c as JimpexEventPayload, a as JimpexEvents, o as JimpexExpressOptions, s as JimpexHealthCheckFn, r as JimpexHealthStatus, t as JimpexOptions, p as JimpexPathOptions, f as JimpexReducerEventName, h as JimpexReducerEventPayload, e as JimpexReducerEventPayloads, g as JimpexReducerEventTarget, d as JimpexReducerEventTargets, q as JimpexServicesOptions, u as JimpexStartCallback, n as JimpexStaticsOptions } from '../
|
|
1
|
+
export { E as EventPayload, l as Events, m as JimpexConfigOptions, k as JimpexEventListener, b as JimpexEventName, i as JimpexEventNameLike, c as JimpexEventPayload, a as JimpexEvents, o as JimpexExpressOptions, s as JimpexHealthCheckFn, r as JimpexHealthStatus, t as JimpexOptions, p as JimpexPathOptions, f as JimpexReducerEventName, h as JimpexReducerEventPayload, e as JimpexReducerEventPayloads, g as JimpexReducerEventTarget, d as JimpexReducerEventTargets, q as JimpexServicesOptions, u as JimpexStartCallback, n as JimpexStaticsOptions } from '../index-b2a04c78.js';
|
|
2
2
|
export { AsyncExpressMiddleware, ExpressErrorHandler, ExpressMiddleware, ExpressMiddlewareLike, RouterMethod } from './express.js';
|
|
3
3
|
export { JimpexHTTP2Options, JimpexHTTPSCredentials, JimpexHTTPSOptions, JimpexServer, JimpexServerInstance } from './http.js';
|
|
4
4
|
export { DeepPartial, DeepReadonly, Dict, NoStringIndex } from './utils.js';
|
package/dist/types/index.js
CHANGED
|
@@ -21,4 +21,13 @@ __reExport(types_exports, require("./http"), module.exports);
|
|
|
21
21
|
__reExport(types_exports, require("./options"), module.exports);
|
|
22
22
|
__reExport(types_exports, require("./utils"), module.exports);
|
|
23
23
|
__reExport(types_exports, require("./wootils"), module.exports);
|
|
24
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
25
|
+
0 && (module.exports = {
|
|
26
|
+
...require("./events"),
|
|
27
|
+
...require("./express"),
|
|
28
|
+
...require("./http"),
|
|
29
|
+
...require("./options"),
|
|
30
|
+
...require("./utils"),
|
|
31
|
+
...require("./wootils")
|
|
32
|
+
});
|
|
24
33
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import '@homer0/simple-config';
|
|
2
|
+
export { m as JimpexConfigOptions, o as JimpexExpressOptions, s as JimpexHealthCheckFn, r as JimpexHealthStatus, t as JimpexOptions, p as JimpexPathOptions, q as JimpexServicesOptions, u as JimpexStartCallback, n as JimpexStaticsOptions } from '../index-efeb437e.js';
|
|
3
|
+
import './express.mjs';
|
|
4
|
+
import 'express';
|
|
5
|
+
import './http.mjs';
|
|
6
|
+
import 'https';
|
|
7
|
+
import 'http';
|
|
8
|
+
import 'spdy';
|
|
9
|
+
import 'node-fetch';
|
|
10
|
+
import './utils.mjs';
|
|
11
|
+
import '@homer0/path-utils';
|
|
12
|
+
import '@homer0/simple-logger';
|
|
13
|
+
import '@homer0/events-hub';
|
|
14
|
+
import '@homer0/jimple';
|
package/dist/types/options.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import '@homer0/simple-config';
|
|
2
|
-
export { m as JimpexConfigOptions, o as JimpexExpressOptions, s as JimpexHealthCheckFn, r as JimpexHealthStatus, t as JimpexOptions, p as JimpexPathOptions, q as JimpexServicesOptions, u as JimpexStartCallback, n as JimpexStaticsOptions } from '../
|
|
3
|
-
import '@homer0/jimple';
|
|
4
|
-
import '@homer0/events-hub';
|
|
2
|
+
export { m as JimpexConfigOptions, o as JimpexExpressOptions, s as JimpexHealthCheckFn, r as JimpexHealthStatus, t as JimpexOptions, p as JimpexPathOptions, q as JimpexServicesOptions, u as JimpexStartCallback, n as JimpexStaticsOptions } from '../index-b2a04c78.js';
|
|
5
3
|
import './express.js';
|
|
6
4
|
import 'express';
|
|
7
5
|
import './http.js';
|
|
@@ -10,4 +8,7 @@ import 'http';
|
|
|
10
8
|
import 'spdy';
|
|
11
9
|
import 'node-fetch';
|
|
12
10
|
import './utils.js';
|
|
11
|
+
import '@homer0/path-utils';
|
|
13
12
|
import '@homer0/simple-logger';
|
|
13
|
+
import '@homer0/events-hub';
|
|
14
|
+
import '@homer0/jimple';
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A simple dictionary with unknown values.
|
|
3
|
+
*
|
|
4
|
+
* @group Utilities
|
|
5
|
+
*/
|
|
6
|
+
type Dict = Record<string, unknown>;
|
|
7
|
+
/**
|
|
8
|
+
* Utility to make a deep "partial" of an existing type.
|
|
9
|
+
*
|
|
10
|
+
* @template T The type to make a partial of.
|
|
11
|
+
* @group Utilities
|
|
12
|
+
*/
|
|
13
|
+
type DeepPartial<T> = {
|
|
14
|
+
[P in keyof T]?: T[P] extends (infer U)[] ? DeepPartial<U>[] : T[P] extends object ? DeepPartial<T[P]> : T[P];
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Utility to make a deep "readonly" of an existing type.
|
|
18
|
+
*
|
|
19
|
+
* @template T The type to make a readonly of.
|
|
20
|
+
* @group Utilities
|
|
21
|
+
*/
|
|
22
|
+
type DeepReadonly<T> = {
|
|
23
|
+
readonly [P in keyof T]: T[P] extends (infer U)[] ? DeepReadonly<U>[] : T[P] extends object ? DeepReadonly<T[P]> : T[P];
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Utility to remove string indexes from types.
|
|
27
|
+
*
|
|
28
|
+
* @template T The type to remove string indexes from.
|
|
29
|
+
* @example
|
|
30
|
+
*
|
|
31
|
+
* type Foo = {
|
|
32
|
+
* a: string;
|
|
33
|
+
* b: string;
|
|
34
|
+
* [key: string]: string;
|
|
35
|
+
* };
|
|
36
|
+
* type Bar = RemoveStringIndexes<Foo>;
|
|
37
|
+
* // Bar = {
|
|
38
|
+
* // a: string;
|
|
39
|
+
* // b: string;
|
|
40
|
+
* // };
|
|
41
|
+
*
|
|
42
|
+
* @group Utilities
|
|
43
|
+
*/
|
|
44
|
+
type NoStringIndex<T> = {
|
|
45
|
+
[K in keyof T as string extends K ? never : K]: T[K];
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export { DeepPartial, DeepReadonly, Dict, NoStringIndex };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { notUndefined } from './others.mjs';
|
|
2
|
+
export { createRouteExpression, removeLeadingSlash, removeSlashes, removeTrailingSlash } from './routes.mjs';
|
|
3
|
+
export { Statuses } from './statuses.mjs';
|
|
4
|
+
export { escapeForRegExp } from './text.mjs';
|
|
5
|
+
export { default as statuses } from 'statuses';
|
package/dist/utils/fns/index.js
CHANGED
|
@@ -19,4 +19,11 @@ __reExport(fns_exports, require("./others"), module.exports);
|
|
|
19
19
|
__reExport(fns_exports, require("./routes"), module.exports);
|
|
20
20
|
__reExport(fns_exports, require("./statuses"), module.exports);
|
|
21
21
|
__reExport(fns_exports, require("./text"), module.exports);
|
|
22
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
23
|
+
0 && (module.exports = {
|
|
24
|
+
...require("./others"),
|
|
25
|
+
...require("./routes"),
|
|
26
|
+
...require("./statuses"),
|
|
27
|
+
...require("./text")
|
|
28
|
+
});
|
|
22
29
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A utility function that can be used in `.filter` calls to remove `undefined` values and
|
|
3
|
+
* assert that the type is not longer `undefined`.
|
|
4
|
+
*
|
|
5
|
+
* @param value The value to check.
|
|
6
|
+
* @template T The type that is not `undefined`.
|
|
7
|
+
* @example
|
|
8
|
+
*
|
|
9
|
+
* const arr: (number | undefined)[] = [1, 2, 3, undefined];
|
|
10
|
+
* const filtered = arr.filter(notUndefined);
|
|
11
|
+
* // filtered = [1, 2, 3] and its type is number[]
|
|
12
|
+
*
|
|
13
|
+
* @group Utilities
|
|
14
|
+
*/
|
|
15
|
+
declare const notUndefined: <T>(value: T | undefined) => value is T;
|
|
16
|
+
|
|
17
|
+
export { notUndefined };
|