jimpex 10.0.2 → 11.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 +29 -0
- package/README.md +7 -9
- package/dist/app/index.d.ts +1 -1
- package/dist/app/index.js +1 -22
- package/dist/app/index.js.map +1 -1
- package/dist/app/jimpex.d.ts +1 -1
- package/dist/app/jimpex.js +100 -131
- package/dist/app/jimpex.js.map +1 -1
- package/dist/controllers/common/config.d.ts +2 -2
- package/dist/controllers/common/config.js +12 -39
- package/dist/controllers/common/config.js.map +1 -1
- package/dist/controllers/common/health.d.ts +4 -4
- package/dist/controllers/common/health.js +20 -47
- package/dist/controllers/common/health.js.map +1 -1
- package/dist/controllers/common/index.d.ts +1 -1
- package/dist/controllers/common/index.js +3 -26
- package/dist/controllers/common/index.js.map +1 -1
- package/dist/controllers/common/statics.d.ts +3 -3
- package/dist/controllers/common/statics.js +32 -65
- package/dist/controllers/common/statics.js.map +1 -1
- package/dist/controllers/index.d.ts +1 -1
- package/dist/controllers/index.js +2 -24
- package/dist/controllers/index.js.map +1 -1
- package/dist/controllers/utils/gateway.d.ts +5 -5
- package/dist/controllers/utils/gateway.js +70 -91
- package/dist/controllers/utils/gateway.js.map +1 -1
- package/dist/controllers/utils/index.d.ts +1 -1
- package/dist/controllers/utils/index.js +1 -22
- package/dist/controllers/utils/index.js.map +1 -1
- package/dist/{index-C6I3NCC-.d.ts → index-BlSpNHox.d.ts} +13 -13
- package/dist/index.d.ts +3 -3
- package/dist/index.js +6 -32
- package/dist/index.js.map +1 -1
- package/dist/middlewares/common/errorHandler.d.ts +5 -5
- package/dist/middlewares/common/errorHandler.js +31 -56
- package/dist/middlewares/common/errorHandler.js.map +1 -1
- package/dist/middlewares/common/forceHTTPS.d.ts +1 -1
- package/dist/middlewares/common/forceHTTPS.js +8 -35
- package/dist/middlewares/common/forceHTTPS.js.map +1 -1
- package/dist/middlewares/common/hsts.d.ts +1 -1
- package/dist/middlewares/common/hsts.js +12 -39
- package/dist/middlewares/common/hsts.js.map +1 -1
- package/dist/middlewares/common/index.d.ts +3 -3
- package/dist/middlewares/common/index.js +3 -26
- package/dist/middlewares/common/index.js.map +1 -1
- package/dist/middlewares/html/fastHTML.d.ts +4 -4
- package/dist/middlewares/html/fastHTML.js +43 -66
- package/dist/middlewares/html/fastHTML.js.map +1 -1
- package/dist/middlewares/html/index.d.ts +2 -2
- package/dist/middlewares/html/index.js +2 -24
- package/dist/middlewares/html/index.js.map +1 -1
- package/dist/middlewares/html/showHTML.d.ts +3 -3
- package/dist/middlewares/html/showHTML.js +25 -52
- package/dist/middlewares/html/showHTML.js.map +1 -1
- package/dist/middlewares/index.d.ts +4 -4
- package/dist/middlewares/index.js +3 -26
- package/dist/middlewares/index.js.map +1 -1
- package/dist/middlewares/utils/index.d.ts +3 -3
- package/dist/middlewares/utils/index.js +1 -22
- package/dist/middlewares/utils/index.js.map +1 -1
- package/dist/middlewares/utils/versionValidator.d.ts +5 -5
- package/dist/middlewares/utils/versionValidator.js +24 -51
- package/dist/middlewares/utils/versionValidator.js.map +1 -1
- package/dist/services/common/appError.d.ts +2 -2
- package/dist/services/common/appError.js +18 -46
- package/dist/services/common/appError.js.map +1 -1
- package/dist/services/common/httpError.d.ts +2 -2
- package/dist/services/common/httpError.js +7 -33
- package/dist/services/common/httpError.js.map +1 -1
- package/dist/services/common/index.d.ts +1 -1
- package/dist/services/common/index.js +14 -42
- package/dist/services/common/index.js.map +1 -1
- package/dist/services/common/sendFile.d.ts +1 -1
- package/dist/services/common/sendFile.js +4 -29
- package/dist/services/common/sendFile.js.map +1 -1
- package/dist/services/frontend/frontendFs.d.ts +2 -2
- package/dist/services/frontend/frontendFs.js +12 -49
- package/dist/services/frontend/frontendFs.js.map +1 -1
- package/dist/services/frontend/index.d.ts +2 -2
- package/dist/services/frontend/index.js +8 -34
- package/dist/services/frontend/index.js.map +1 -1
- package/dist/services/html/htmlGenerator.d.ts +5 -5
- package/dist/services/html/htmlGenerator.js +46 -75
- package/dist/services/html/htmlGenerator.js.map +1 -1
- package/dist/services/html/index.d.ts +2 -2
- package/dist/services/html/index.js +8 -34
- package/dist/services/html/index.js.map +1 -1
- package/dist/services/http/apiClient.d.ts +1 -1
- package/dist/services/http/apiClient.js +23 -48
- package/dist/services/http/apiClient.js.map +1 -1
- package/dist/services/http/http.d.ts +5 -5
- package/dist/services/http/http.js +23 -60
- package/dist/services/http/http.js.map +1 -1
- package/dist/services/http/index.d.ts +2 -2
- package/dist/services/http/index.js +14 -42
- package/dist/services/http/index.js.map +1 -1
- package/dist/services/http/responsesBuilder.d.ts +4 -4
- package/dist/services/http/responsesBuilder.js +13 -40
- package/dist/services/http/responsesBuilder.js.map +1 -1
- package/dist/services/index.d.ts +3 -3
- package/dist/services/index.js +5 -30
- package/dist/services/index.js.map +1 -1
- package/dist/services/utils/ensureBearerToken.d.ts +2 -2
- package/dist/services/utils/ensureBearerToken.js +15 -42
- package/dist/services/utils/ensureBearerToken.js.map +1 -1
- package/dist/services/utils/index.d.ts +1 -1
- package/dist/services/utils/index.js +8 -34
- package/dist/services/utils/index.js.map +1 -1
- package/dist/types/events.d.ts +1 -1
- package/dist/types/events.js +0 -16
- package/dist/types/events.js.map +1 -1
- package/dist/types/express.js +0 -16
- package/dist/types/express.js.map +1 -1
- package/dist/types/http.js +0 -16
- package/dist/types/http.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.js +6 -32
- package/dist/types/index.js.map +1 -1
- package/dist/types/options.d.ts +1 -1
- package/dist/types/options.js +0 -16
- package/dist/types/options.js.map +1 -1
- package/dist/types/utils.js +0 -16
- package/dist/types/utils.js.map +1 -1
- package/dist/types/wootils.js +0 -16
- package/dist/types/wootils.js.map +1 -1
- package/dist/utils/fns/index.js +4 -28
- package/dist/utils/fns/index.js.map +1 -1
- package/dist/utils/fns/others.js +2 -26
- package/dist/utils/fns/others.js.map +1 -1
- package/dist/utils/fns/routes.js +4 -31
- package/dist/utils/fns/routes.js.map +1 -1
- package/dist/utils/fns/statuses.js +3 -37
- package/dist/utils/fns/statuses.js.map +1 -1
- package/dist/utils/fns/text.js +2 -26
- package/dist/utils/fns/text.js.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +2 -24
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/wrappers.d.ts +1 -1
- package/dist/utils/wrappers.js +20 -48
- package/dist/utils/wrappers.js.map +1 -1
- package/eslint.config.js +19 -0
- package/examples/basic/app.ts +4 -4
- package/examples/basic/controller.ts +2 -2
- package/examples/basic/index.ts +4 -4
- package/examples/basic/middleware.ts +2 -2
- package/examples/basic/service.ts +1 -1
- package/package.json +61 -49
- package/pnpm-workspace.yaml +4 -0
- package/src/app/index.ts +1 -1
- package/src/app/jimpex.ts +23 -20
- package/src/controllers/common/config.ts +4 -4
- package/src/controllers/common/health.ts +9 -5
- package/src/controllers/common/index.ts +3 -3
- package/src/controllers/common/statics.ts +12 -7
- package/src/controllers/index.ts +2 -2
- package/src/controllers/utils/gateway.ts +8 -8
- package/src/controllers/utils/index.ts +1 -1
- package/src/index.ts +6 -6
- package/src/middlewares/common/errorHandler.ts +9 -5
- package/src/middlewares/common/forceHTTPS.ts +2 -2
- package/src/middlewares/common/hsts.ts +2 -2
- package/src/middlewares/common/index.ts +3 -3
- package/src/middlewares/html/fastHTML.ts +14 -5
- package/src/middlewares/html/index.ts +2 -2
- package/src/middlewares/html/showHTML.ts +8 -4
- package/src/middlewares/index.ts +3 -3
- package/src/middlewares/utils/index.ts +1 -1
- package/src/middlewares/utils/versionValidator.ts +6 -6
- package/src/services/common/appError.ts +1 -1
- package/src/services/common/httpError.ts +2 -2
- package/src/services/common/index.ts +7 -7
- package/src/services/common/sendFile.ts +2 -2
- package/src/services/frontend/frontendFs.ts +3 -3
- package/src/services/frontend/index.ts +3 -3
- package/src/services/html/htmlGenerator.ts +11 -13
- package/src/services/html/index.ts +3 -3
- package/src/services/http/apiClient.ts +3 -3
- package/src/services/http/http.ts +5 -5
- package/src/services/http/index.ts +7 -7
- package/src/services/http/responsesBuilder.ts +5 -5
- package/src/services/index.ts +5 -5
- package/src/services/utils/ensureBearerToken.ts +4 -4
- package/src/services/utils/index.ts +3 -3
- package/src/types/events.ts +8 -8
- package/src/types/http.ts +1 -1
- package/src/types/index.ts +6 -6
- package/src/types/options.ts +2 -2
- package/src/types/utils.ts +4 -4
- package/src/utils/fns/index.ts +4 -4
- package/src/utils/fns/routes.ts +1 -1
- package/src/utils/index.ts +2 -2
- package/src/utils/wrappers.ts +6 -6
- package/tsconfig.json +9 -4
- package/tsup.config.ts +1 -2
- package/vitest.config.ts +24 -0
- package/dist/app/index.d.mts +0 -14
- package/dist/app/jimpex.d.mts +0 -14
- package/dist/controllers/common/config.d.mts +0 -79
- package/dist/controllers/common/health.d.mts +0 -83
- package/dist/controllers/common/index.d.mts +0 -22
- package/dist/controllers/common/statics.d.mts +0 -223
- package/dist/controllers/index.d.mts +0 -25
- package/dist/controllers/utils/gateway.d.mts +0 -725
- package/dist/controllers/utils/index.d.mts +0 -17
- package/dist/esm/app/index.js +0 -2
- package/dist/esm/app/index.js.map +0 -1
- package/dist/esm/app/jimpex.js +0 -640
- package/dist/esm/app/jimpex.js.map +0 -1
- package/dist/esm/chunk-V6TY7KAL.js +0 -8
- package/dist/esm/chunk-V6TY7KAL.js.map +0 -1
- package/dist/esm/controllers/common/config.js +0 -80
- package/dist/esm/controllers/common/config.js.map +0 -1
- package/dist/esm/controllers/common/health.js +0 -88
- package/dist/esm/controllers/common/health.js.map +0 -1
- package/dist/esm/controllers/common/index.js +0 -4
- package/dist/esm/controllers/common/index.js.map +0 -1
- package/dist/esm/controllers/common/statics.js +0 -226
- package/dist/esm/controllers/common/statics.js.map +0 -1
- package/dist/esm/controllers/index.js +0 -3
- package/dist/esm/controllers/index.js.map +0 -1
- package/dist/esm/controllers/utils/gateway.js +0 -559
- package/dist/esm/controllers/utils/gateway.js.map +0 -1
- package/dist/esm/controllers/utils/index.js +0 -2
- package/dist/esm/controllers/utils/index.js.map +0 -1
- package/dist/esm/index.js +0 -7
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/middlewares/common/errorHandler.js +0 -116
- package/dist/esm/middlewares/common/errorHandler.js.map +0 -1
- package/dist/esm/middlewares/common/forceHTTPS.js +0 -52
- package/dist/esm/middlewares/common/forceHTTPS.js.map +0 -1
- package/dist/esm/middlewares/common/hsts.js +0 -74
- package/dist/esm/middlewares/common/hsts.js.map +0 -1
- package/dist/esm/middlewares/common/index.js +0 -4
- package/dist/esm/middlewares/common/index.js.map +0 -1
- package/dist/esm/middlewares/html/fastHTML.js +0 -157
- package/dist/esm/middlewares/html/fastHTML.js.map +0 -1
- package/dist/esm/middlewares/html/index.js +0 -3
- package/dist/esm/middlewares/html/index.js.map +0 -1
- package/dist/esm/middlewares/html/showHTML.js +0 -100
- package/dist/esm/middlewares/html/showHTML.js.map +0 -1
- package/dist/esm/middlewares/index.js +0 -4
- package/dist/esm/middlewares/index.js.map +0 -1
- package/dist/esm/middlewares/utils/index.js +0 -2
- package/dist/esm/middlewares/utils/index.js.map +0 -1
- package/dist/esm/middlewares/utils/versionValidator.js +0 -135
- package/dist/esm/middlewares/utils/versionValidator.js.map +0 -1
- package/dist/esm/services/common/appError.js +0 -98
- package/dist/esm/services/common/appError.js.map +0 -1
- package/dist/esm/services/common/httpError.js +0 -28
- package/dist/esm/services/common/httpError.js.map +0 -1
- package/dist/esm/services/common/index.js +0 -17
- package/dist/esm/services/common/index.js.map +0 -1
- package/dist/esm/services/common/sendFile.js +0 -27
- package/dist/esm/services/common/sendFile.js.map +0 -1
- package/dist/esm/services/frontend/frontendFs.js +0 -66
- package/dist/esm/services/frontend/frontendFs.js.map +0 -1
- package/dist/esm/services/frontend/index.js +0 -11
- package/dist/esm/services/frontend/index.js.map +0 -1
- package/dist/esm/services/html/htmlGenerator.js +0 -192
- package/dist/esm/services/html/htmlGenerator.js.map +0 -1
- package/dist/esm/services/html/index.js +0 -11
- package/dist/esm/services/html/index.js.map +0 -1
- package/dist/esm/services/http/apiClient.js +0 -94
- package/dist/esm/services/http/apiClient.js.map +0 -1
- package/dist/esm/services/http/http.js +0 -180
- package/dist/esm/services/http/http.js.map +0 -1
- package/dist/esm/services/http/index.js +0 -17
- package/dist/esm/services/http/index.js.map +0 -1
- package/dist/esm/services/http/responsesBuilder.js +0 -152
- package/dist/esm/services/http/responsesBuilder.js.map +0 -1
- package/dist/esm/services/index.js +0 -6
- package/dist/esm/services/index.js.map +0 -1
- package/dist/esm/services/utils/ensureBearerToken.js +0 -94
- package/dist/esm/services/utils/ensureBearerToken.js.map +0 -1
- package/dist/esm/services/utils/index.js +0 -11
- package/dist/esm/services/utils/index.js.map +0 -1
- package/dist/esm/types/events.js +0 -1
- package/dist/esm/types/events.js.map +0 -1
- package/dist/esm/types/express.js +0 -1
- package/dist/esm/types/express.js.map +0 -1
- package/dist/esm/types/http.js +0 -1
- package/dist/esm/types/http.js.map +0 -1
- package/dist/esm/types/index.js +0 -7
- package/dist/esm/types/index.js.map +0 -1
- package/dist/esm/types/options.js +0 -1
- package/dist/esm/types/options.js.map +0 -1
- package/dist/esm/types/utils.js +0 -1
- package/dist/esm/types/utils.js.map +0 -1
- package/dist/esm/types/wootils.js +0 -1
- package/dist/esm/types/wootils.js.map +0 -1
- package/dist/esm/utils/fns/index.js +0 -5
- package/dist/esm/utils/fns/index.js.map +0 -1
- package/dist/esm/utils/fns/others.js +0 -6
- package/dist/esm/utils/fns/others.js.map +0 -1
- package/dist/esm/utils/fns/routes.js +0 -25
- package/dist/esm/utils/fns/routes.js.map +0 -1
- package/dist/esm/utils/fns/statuses.js +0 -6
- package/dist/esm/utils/fns/statuses.js.map +0 -1
- package/dist/esm/utils/fns/text.js +0 -6
- package/dist/esm/utils/fns/text.js.map +0 -1
- package/dist/esm/utils/index.js +0 -3
- package/dist/esm/utils/index.js.map +0 -1
- package/dist/esm/utils/wrappers.js +0 -41
- package/dist/esm/utils/wrappers.js.map +0 -1
- package/dist/index-Bwf7JHu9.d.mts +0 -1287
- package/dist/index.d.mts +0 -47
- package/dist/middlewares/common/errorHandler.d.mts +0 -132
- package/dist/middlewares/common/forceHTTPS.d.mts +0 -69
- package/dist/middlewares/common/hsts.d.mts +0 -110
- package/dist/middlewares/common/index.d.mts +0 -22
- package/dist/middlewares/html/fastHTML.d.mts +0 -180
- package/dist/middlewares/html/index.d.mts +0 -21
- package/dist/middlewares/html/showHTML.d.mts +0 -127
- package/dist/middlewares/index.d.mts +0 -30
- package/dist/middlewares/utils/index.d.mts +0 -20
- package/dist/middlewares/utils/versionValidator.d.mts +0 -215
- package/dist/services/common/appError.d.mts +0 -139
- package/dist/services/common/httpError.d.mts +0 -80
- package/dist/services/common/index.d.mts +0 -47
- package/dist/services/common/sendFile.d.mts +0 -102
- package/dist/services/frontend/frontendFs.d.mts +0 -96
- package/dist/services/frontend/index.d.mts +0 -40
- package/dist/services/html/htmlGenerator.d.mts +0 -237
- package/dist/services/html/index.d.mts +0 -43
- package/dist/services/http/apiClient.d.mts +0 -170
- package/dist/services/http/http.d.mts +0 -182
- package/dist/services/http/index.d.mts +0 -51
- package/dist/services/http/responsesBuilder.d.mts +0 -179
- package/dist/services/index.d.mts +0 -33
- package/dist/services/utils/ensureBearerToken.d.mts +0 -158
- package/dist/services/utils/index.d.mts +0 -44
- package/dist/types/events.d.mts +0 -14
- package/dist/types/express.d.mts +0 -10
- package/dist/types/http.d.mts +0 -82
- package/dist/types/index.d.mts +0 -14
- package/dist/types/options.d.mts +0 -14
- package/dist/types/utils.d.mts +0 -48
- package/dist/types/wootils.d.mts +0 -4
- package/dist/utils/fns/index.d.mts +0 -5
- package/dist/utils/fns/others.d.mts +0 -17
- package/dist/utils/fns/routes.d.mts +0 -39
- package/dist/utils/fns/statuses.d.mts +0 -45
- package/dist/utils/fns/text.d.mts +0 -9
- package/dist/utils/index.d.mts +0 -19
- package/dist/utils/wrappers.d.mts +0 -14
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
-
import { J as Jimpex } from '../../index-Bwf7JHu9.mjs';
|
|
3
|
-
import { Request } from 'express';
|
|
4
|
-
import { NodeFetch } from '../../types/http.mjs';
|
|
5
|
-
import { SimpleLogger } from '@homer0/simple-logger';
|
|
6
|
-
import { BodyInit, Response, RequestInit } from 'node-fetch';
|
|
7
|
-
import '../../types/express.mjs';
|
|
8
|
-
import '../../types/utils.mjs';
|
|
9
|
-
import '@homer0/path-utils';
|
|
10
|
-
import '@homer0/simple-config';
|
|
11
|
-
import '@homer0/events-hub';
|
|
12
|
-
import 'https';
|
|
13
|
-
import 'http';
|
|
14
|
-
import 'spdy';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* The options to customize the service.
|
|
18
|
-
*
|
|
19
|
-
* @group Services/HTTP
|
|
20
|
-
*/
|
|
21
|
-
type HTTPOptions = {
|
|
22
|
-
/**
|
|
23
|
-
* Whether or not the service should log the requests and their responses.
|
|
24
|
-
*/
|
|
25
|
-
logRequests?: boolean;
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* The options to construct a {@link HTTP}.
|
|
29
|
-
*
|
|
30
|
-
* @group Services/HTTP
|
|
31
|
-
*/
|
|
32
|
-
type HTTPContructorOptions = Partial<HTTPOptions> & {
|
|
33
|
-
/**
|
|
34
|
-
* A dictionary with the dependencies to inject.
|
|
35
|
-
*/
|
|
36
|
-
inject: {
|
|
37
|
-
logger: SimpleLogger;
|
|
38
|
-
nodeFetch: NodeFetch;
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
/**
|
|
42
|
-
* The allowed formats for the body of a request.
|
|
43
|
-
*
|
|
44
|
-
* @group Services/HTTP
|
|
45
|
-
*/
|
|
46
|
-
type HTTPFetchBody = string | Record<string | number, unknown> | BodyInit;
|
|
47
|
-
/**
|
|
48
|
-
* The options for a request.
|
|
49
|
-
*
|
|
50
|
-
* @group Services/HTTP
|
|
51
|
-
*/
|
|
52
|
-
type HTTPFetchOptions = {
|
|
53
|
-
/**
|
|
54
|
-
* The HTTP method.
|
|
55
|
-
*
|
|
56
|
-
* @default 'GET'
|
|
57
|
-
*/
|
|
58
|
-
method?: string;
|
|
59
|
-
/**
|
|
60
|
-
* The headers dictionary.
|
|
61
|
-
*/
|
|
62
|
-
headers?: Record<string, string>;
|
|
63
|
-
/**
|
|
64
|
-
* The body of the request.
|
|
65
|
-
*/
|
|
66
|
-
body?: HTTPFetchBody;
|
|
67
|
-
/**
|
|
68
|
-
* A dictionary of query string parameters.
|
|
69
|
-
*/
|
|
70
|
-
qs?: Record<string, unknown>;
|
|
71
|
-
/**
|
|
72
|
-
* A request object generated by the application. This can be used to copy information
|
|
73
|
-
* like custom headers or the IP (for the X-Forwarded-For header).
|
|
74
|
-
*/
|
|
75
|
-
req?: Request;
|
|
76
|
-
};
|
|
77
|
-
/**
|
|
78
|
-
* The options for the method that extracts custom headers from a request.
|
|
79
|
-
*
|
|
80
|
-
* @group Services/HTTP
|
|
81
|
-
*/
|
|
82
|
-
type GetCustomHeadersFromRequestOptions = {
|
|
83
|
-
/**
|
|
84
|
-
* Since the method considers all headers that start with `x-` as custom headers,
|
|
85
|
-
* setting this to `false` is the only way to exclude `x-forwarded-` headers from the
|
|
86
|
-
* list.
|
|
87
|
-
*
|
|
88
|
-
* @default false
|
|
89
|
-
*/
|
|
90
|
-
includeXForwardedHeaders?: boolean;
|
|
91
|
-
};
|
|
92
|
-
/**
|
|
93
|
-
* A set of utilities to work with HTTP requests and responses.
|
|
94
|
-
*
|
|
95
|
-
* @group Services
|
|
96
|
-
* @group Services/HTTP
|
|
97
|
-
*/
|
|
98
|
-
declare class HTTP {
|
|
99
|
-
/**
|
|
100
|
-
* The service used to log information in the terminal.
|
|
101
|
-
*/
|
|
102
|
-
protected readonly _logger: SimpleLogger;
|
|
103
|
-
/**
|
|
104
|
-
* The node-fetch library. Since it's an ESM only module, Jimpex loads it on boot and makes
|
|
105
|
-
* it available on the container.
|
|
106
|
-
*/
|
|
107
|
-
protected readonly _nodeFetch: NodeFetch;
|
|
108
|
-
/**
|
|
109
|
-
* The service customization options.
|
|
110
|
-
*/
|
|
111
|
-
protected readonly _options: HTTPOptions;
|
|
112
|
-
/**
|
|
113
|
-
* @param options The options to construct the class.
|
|
114
|
-
*/
|
|
115
|
-
constructor({ inject: { logger, nodeFetch }, ...options }: HTTPContructorOptions);
|
|
116
|
-
/**
|
|
117
|
-
* Makes a fetch request.
|
|
118
|
-
*
|
|
119
|
-
* @param url The URL to fetch.
|
|
120
|
-
* @param options The custom options for the request.
|
|
121
|
-
*/
|
|
122
|
-
fetch(url: string, options?: HTTPFetchOptions): Promise<Response>;
|
|
123
|
-
/**
|
|
124
|
-
* Tries to get the IP address from a given request.
|
|
125
|
-
*
|
|
126
|
-
* @param req The request from which it will try to obtain the IP address.
|
|
127
|
-
*/
|
|
128
|
-
getIPFromRequest(req: Request): string | undefined;
|
|
129
|
-
/**
|
|
130
|
-
* Creates a dictionary with all the custom headers a request has. By custom header it
|
|
131
|
-
* means all the headers which name start with `x-`.
|
|
132
|
-
*
|
|
133
|
-
* @param req The request from which it will try to get the headers.
|
|
134
|
-
* @param options The options to customize the behavior with certain headers.
|
|
135
|
-
*/
|
|
136
|
-
getCustomHeadersFromRequest(req: Request, options?: GetCustomHeadersFromRequestOptions): Record<string, string>;
|
|
137
|
-
/**
|
|
138
|
-
* It takes a dictionary of headers and normalize the names so each word will start with
|
|
139
|
-
* an upper case character. This is helpful in case you added custom headers and didn't
|
|
140
|
-
* care about the casing, or when copying headers from a server request, as they all
|
|
141
|
-
* come tranformed into lower case.
|
|
142
|
-
*
|
|
143
|
-
* @param headers The dictionary of headers to normalize.
|
|
144
|
-
*/
|
|
145
|
-
normalizeHeaders(headers: Record<string, string>): Record<string, string>;
|
|
146
|
-
/**
|
|
147
|
-
* The customization options.
|
|
148
|
-
*/
|
|
149
|
-
get options(): Readonly<HTTPOptions>;
|
|
150
|
-
/**
|
|
151
|
-
* Logs a request information into the terminal.
|
|
152
|
-
*
|
|
153
|
-
* @param url The request URL.
|
|
154
|
-
* @param options The options for the request.
|
|
155
|
-
*/
|
|
156
|
-
protected _logRequest(url: string, options: RequestInit): void;
|
|
157
|
-
/**
|
|
158
|
-
* Logs a response information into the terminal.
|
|
159
|
-
*
|
|
160
|
-
* @param response The response to log.
|
|
161
|
-
*/
|
|
162
|
-
protected _logResponse(response: Response): void;
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* The service provider that once registered on the container will set an instance of
|
|
166
|
-
* {@link HTTP} as the `http` service. The provider also checks the `debug.logRequests`
|
|
167
|
-
* setting on the application configuration in order to enable or not the logging of
|
|
168
|
-
* requests/responses.
|
|
169
|
-
*
|
|
170
|
-
* @example
|
|
171
|
-
*
|
|
172
|
-
* // Register it on the container
|
|
173
|
-
* container.register(httpProvider);
|
|
174
|
-
* // Getting access to the service instance
|
|
175
|
-
* const http = container.get<HTTP>('http');
|
|
176
|
-
*
|
|
177
|
-
* @group Providers
|
|
178
|
-
* @group Services/HTTP
|
|
179
|
-
*/
|
|
180
|
-
declare const httpProvider: _homer0_jimple.Resource<"provider", "register", _homer0_jimple.ProviderRegisterFn<Jimpex>>;
|
|
181
|
-
|
|
182
|
-
export { type GetCustomHeadersFromRequestOptions, HTTP, type HTTPContructorOptions, type HTTPFetchBody, type HTTPFetchOptions, type HTTPOptions, httpProvider };
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
-
import { J as Jimpex } from '../../index-Bwf7JHu9.mjs';
|
|
3
|
-
export { ErrorResponse } from '@homer0/api-utils';
|
|
4
|
-
import { APIClientProviderOptions } from './apiClient.mjs';
|
|
5
|
-
export { APIClient, APIClientConfig, APIClientConstructorOptions, APIClientSettings, EndpointsType, apiClientProvider } from './apiClient.mjs';
|
|
6
|
-
export { GetCustomHeadersFromRequestOptions, HTTP, HTTPContructorOptions, HTTPFetchBody, HTTPFetchOptions, HTTPOptions, httpProvider } from './http.mjs';
|
|
7
|
-
export { HTMLPostMessageResponseOptions, JSONResponseOptions, ResponsesBuilder, ResponsesBuilderConstructorOptions, responsesBuilderProvider } from './responsesBuilder.mjs';
|
|
8
|
-
import '../../types/express.mjs';
|
|
9
|
-
import 'express';
|
|
10
|
-
import '../../types/http.mjs';
|
|
11
|
-
import 'https';
|
|
12
|
-
import 'http';
|
|
13
|
-
import 'spdy';
|
|
14
|
-
import 'node-fetch';
|
|
15
|
-
import '../../types/utils.mjs';
|
|
16
|
-
import '@homer0/path-utils';
|
|
17
|
-
import '@homer0/simple-logger';
|
|
18
|
-
import '@homer0/simple-config';
|
|
19
|
-
import '@homer0/events-hub';
|
|
20
|
-
import '../common/httpError.mjs';
|
|
21
|
-
import '../../utils/fns/statuses.mjs';
|
|
22
|
-
import 'statuses';
|
|
23
|
-
import '../common/appError.mjs';
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Registers all the HTTP services on the container.
|
|
27
|
-
*
|
|
28
|
-
* - {@link APIClient | apiClient}
|
|
29
|
-
* - {@link HTTP | http}
|
|
30
|
-
* - {@link ResponsesBuilder | responsesBuilder}
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
*
|
|
34
|
-
* // Register the collection on the container
|
|
35
|
-
* container.register(httpServicesProvider);
|
|
36
|
-
* // Getting access to one the services instance
|
|
37
|
-
* const apiClient = container.get<APIClient>('apiClient');
|
|
38
|
-
*
|
|
39
|
-
* @group Providers
|
|
40
|
-
*/
|
|
41
|
-
declare const httpServicesProvider: {
|
|
42
|
-
apiClientProvider: _homer0_jimple.ResourceCreator<"provider", "register", (options?: APIClientProviderOptions) => (app: Jimpex) => void, _homer0_jimple.ProviderRegisterFn<Jimpex>>;
|
|
43
|
-
httpProvider: _homer0_jimple.Resource<"provider", "register", _homer0_jimple.ProviderRegisterFn<Jimpex>>;
|
|
44
|
-
responsesBuilderProvider: _homer0_jimple.Resource<"provider", "register", _homer0_jimple.ProviderRegisterFn<Jimpex>>;
|
|
45
|
-
} & Record<string, _homer0_jimple.Resource<"provider", "register", _homer0_jimple.ProviderRegisterFn<Jimpex>>> & {
|
|
46
|
-
provider: true;
|
|
47
|
-
} & {
|
|
48
|
-
register: _homer0_jimple.ProviderRegisterFn<Jimpex>;
|
|
49
|
-
} & Record<string, unknown>;
|
|
50
|
-
|
|
51
|
-
export { APIClientProviderOptions, httpServicesProvider };
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
-
import { J as Jimpex } from '../../index-Bwf7JHu9.mjs';
|
|
3
|
-
import { Response } from 'express';
|
|
4
|
-
import { Statuses } from '../../utils/fns/statuses.mjs';
|
|
5
|
-
import { SimpleConfig } from '@homer0/simple-config';
|
|
6
|
-
import '../../types/express.mjs';
|
|
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/events-hub';
|
|
16
|
-
import 'statuses';
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* The options to construct a {@link ResponsesBuilder}.
|
|
20
|
-
*
|
|
21
|
-
* @group Services/ResponsesBuilder
|
|
22
|
-
*/
|
|
23
|
-
type ResponsesBuilderConstructorOptions = {
|
|
24
|
-
/**
|
|
25
|
-
* A dictionary with the dependencies to inject.
|
|
26
|
-
*/
|
|
27
|
-
inject: {
|
|
28
|
-
config: SimpleConfig;
|
|
29
|
-
statuses: Statuses;
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* The options to build a response for a post message.
|
|
34
|
-
*
|
|
35
|
-
* @group Services/ResponsesBuilder
|
|
36
|
-
*/
|
|
37
|
-
type HTMLPostMessageResponseOptions = {
|
|
38
|
-
/**
|
|
39
|
-
* The response object generated by the application.
|
|
40
|
-
*/
|
|
41
|
-
res: Response;
|
|
42
|
-
/**
|
|
43
|
-
* The title for the HTML.
|
|
44
|
-
*/
|
|
45
|
-
title: string;
|
|
46
|
-
/**
|
|
47
|
-
* The contents of the post message.
|
|
48
|
-
*/
|
|
49
|
-
message: string;
|
|
50
|
-
/**
|
|
51
|
-
* The status code for the response.
|
|
52
|
-
*
|
|
53
|
-
* @default 200
|
|
54
|
-
*/
|
|
55
|
-
status?: number | string;
|
|
56
|
-
/**
|
|
57
|
-
* From which object will the `postMessage` method called from.
|
|
58
|
-
*
|
|
59
|
-
* @default 'window.opener'
|
|
60
|
-
*/
|
|
61
|
-
target?: string;
|
|
62
|
-
/**
|
|
63
|
-
* Whether or not to call `window.close` after sending the message.
|
|
64
|
-
*
|
|
65
|
-
* @default true
|
|
66
|
-
*/
|
|
67
|
-
close?: boolean;
|
|
68
|
-
/**
|
|
69
|
-
* In case `close` is set to `true`, this option is to specify how many milliseconds
|
|
70
|
-
* should be waited before closing the window.
|
|
71
|
-
*
|
|
72
|
-
* @default 700
|
|
73
|
-
*/
|
|
74
|
-
closeDelay?: number;
|
|
75
|
-
};
|
|
76
|
-
/**
|
|
77
|
-
* The options to build a reponse for JSON.
|
|
78
|
-
*
|
|
79
|
-
* @group Services/ResponsesBuilder
|
|
80
|
-
*/
|
|
81
|
-
type JSONResponseOptions = {
|
|
82
|
-
/**
|
|
83
|
-
* The response object generated by the application.
|
|
84
|
-
*/
|
|
85
|
-
res: Response;
|
|
86
|
-
/**
|
|
87
|
-
* The actual data for the response. It will be added in a `data` property.
|
|
88
|
-
*/
|
|
89
|
-
data: unknown;
|
|
90
|
-
/**
|
|
91
|
-
* The status code for the response.
|
|
92
|
-
*
|
|
93
|
-
* @default 200
|
|
94
|
-
*/
|
|
95
|
-
status?: number | string;
|
|
96
|
-
/**
|
|
97
|
-
* Extra information to include inside the `metadata` object.
|
|
98
|
-
*/
|
|
99
|
-
metadata?: object;
|
|
100
|
-
};
|
|
101
|
-
/**
|
|
102
|
-
* A utility service to build responses.
|
|
103
|
-
*
|
|
104
|
-
* @group Services
|
|
105
|
-
* @group Services/ResponsesBuilder
|
|
106
|
-
*/
|
|
107
|
-
declare class ResponsesBuilder {
|
|
108
|
-
/**
|
|
109
|
-
* The application configuration, to get the `version` and the `postMessagesPrefix`.
|
|
110
|
-
*/
|
|
111
|
-
protected readonly _config: SimpleConfig;
|
|
112
|
-
/**
|
|
113
|
-
* The uility service to get HTTP status codes.
|
|
114
|
-
*/
|
|
115
|
-
protected readonly _statuses: Statuses;
|
|
116
|
-
/**
|
|
117
|
-
* @param options The options to construct the service.
|
|
118
|
-
*/
|
|
119
|
-
constructor({ inject: { config, statuses } }: ResponsesBuilderConstructorOptions);
|
|
120
|
-
/**
|
|
121
|
-
* Generates and send an HTML response that emits a post message.
|
|
122
|
-
* The post message will be prefixed with the value of the configuration setting
|
|
123
|
-
* `postMessagesPrefix`.
|
|
124
|
-
*
|
|
125
|
-
* @param options The options to customize how the HTML is generated.
|
|
126
|
-
*/
|
|
127
|
-
htmlPostMessage(options: HTMLPostMessageResponseOptions): void;
|
|
128
|
-
/**
|
|
129
|
-
* Generates and sends a JSON response.
|
|
130
|
-
*
|
|
131
|
-
* @param options The options to customize how the JSON is generated.
|
|
132
|
-
* @example
|
|
133
|
-
*
|
|
134
|
-
* <caption>The generated looks like this.</caption>
|
|
135
|
-
*
|
|
136
|
-
* {
|
|
137
|
-
* metadata: {
|
|
138
|
-
* version: 'dev',
|
|
139
|
-
* status: 200,
|
|
140
|
-
* },
|
|
141
|
-
* data: { foo: 'bar' },
|
|
142
|
-
* }
|
|
143
|
-
*
|
|
144
|
-
*/
|
|
145
|
-
json(options: JSONResponseOptions): void;
|
|
146
|
-
/**
|
|
147
|
-
* Generates a basic HTML template for the service to use when generating a post message
|
|
148
|
-
* response.
|
|
149
|
-
*
|
|
150
|
-
* @param title The HTML `<title />` attribute.
|
|
151
|
-
* @param code Javascript code to be wrapped on a `<script />` tag.
|
|
152
|
-
*/
|
|
153
|
-
protected _htmlTemplate(title: string, code: string): string;
|
|
154
|
-
/**
|
|
155
|
-
* Utility method used to make sure a recevied status is a valid status code. If the
|
|
156
|
-
* status is a string, the method will try to find the code from the `statuses` package.
|
|
157
|
-
*
|
|
158
|
-
* @param status The status to normalize.
|
|
159
|
-
* @returns If `status` is a string, but there's no valid code, it will return 200.
|
|
160
|
-
*/
|
|
161
|
-
protected _normalizeStatus(status: number | string): number;
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* The service provider that once registered on the container will set an instance of
|
|
165
|
-
* {@link ResponsesBuilder} as the `responsesBuilder` service.
|
|
166
|
-
*
|
|
167
|
-
* @example
|
|
168
|
-
*
|
|
169
|
-
* // Register it on the container
|
|
170
|
-
* container.register(responsesBuilderProvider);
|
|
171
|
-
* // Getting access to the service instance
|
|
172
|
-
* const responsesBuilder = container.get<ResponsesBuilder>('responsesBuilder');
|
|
173
|
-
*
|
|
174
|
-
* @group Providers
|
|
175
|
-
* @group Services/ResponsesBuilder
|
|
176
|
-
*/
|
|
177
|
-
declare const responsesBuilderProvider: _homer0_jimple.Resource<"provider", "register", _homer0_jimple.ProviderRegisterFn<Jimpex>>;
|
|
178
|
-
|
|
179
|
-
export { type HTMLPostMessageResponseOptions, type JSONResponseOptions, ResponsesBuilder, type ResponsesBuilderConstructorOptions, responsesBuilderProvider };
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
export { commonServicesProvider } from './common/index.mjs';
|
|
2
|
-
export { frontendServicesProvider } from './frontend/index.mjs';
|
|
3
|
-
export { htmlServicesProvider } from './html/index.mjs';
|
|
4
|
-
export { httpServicesProvider } from './http/index.mjs';
|
|
5
|
-
export { utilsServicesProvider } from './utils/index.mjs';
|
|
6
|
-
export { AppError, AppErrorClass, AppErrorContext, CreateAppErrorFn, appErrorProvider, createAppError } from './common/appError.mjs';
|
|
7
|
-
export { CreateHTTPErrorFn, HTTPError, HTTPErrorClass, createHTTPError, httpErrorProvider } from './common/httpError.mjs';
|
|
8
|
-
export { SendFile, SendFileGeneratorOptions, SendFileOptions, sendFile, sendFileProvider } from './common/sendFile.mjs';
|
|
9
|
-
export { FrontendFs, FrontendFsOptions, frontendFsProvider } from './frontend/frontendFs.mjs';
|
|
10
|
-
export { HTMLGenerator, HTMLGeneratorConstructorOptions, HTMLGeneratorOptions, HTMLGeneratorProviderOptions, HTMLGeneratorValuesService, htmlGeneratorProvider } from './html/htmlGenerator.mjs';
|
|
11
|
-
export { ErrorResponse } from '@homer0/api-utils';
|
|
12
|
-
export { APIClient, APIClientConfig, APIClientConstructorOptions, APIClientProviderOptions, APIClientSettings, EndpointsType, apiClientProvider } from './http/apiClient.mjs';
|
|
13
|
-
export { GetCustomHeadersFromRequestOptions, HTTP, HTTPContructorOptions, HTTPFetchBody, HTTPFetchOptions, HTTPOptions, httpProvider } from './http/http.mjs';
|
|
14
|
-
export { HTMLPostMessageResponseOptions, JSONResponseOptions, ResponsesBuilder, ResponsesBuilderConstructorOptions, responsesBuilderProvider } from './http/responsesBuilder.mjs';
|
|
15
|
-
export { EnsureBearerConstructorOptions, EnsureBearerToken, EnsureBearerTokenErrorOptions, EnsureBearerTokenOptions, EnsureBearerTokenProviderOptions, ensureBearerTokenProvider } from './utils/ensureBearerToken.mjs';
|
|
16
|
-
import '@homer0/jimple';
|
|
17
|
-
import '../index-Bwf7JHu9.mjs';
|
|
18
|
-
import '../types/express.mjs';
|
|
19
|
-
import 'express';
|
|
20
|
-
import '../types/http.mjs';
|
|
21
|
-
import 'https';
|
|
22
|
-
import 'http';
|
|
23
|
-
import 'spdy';
|
|
24
|
-
import 'node-fetch';
|
|
25
|
-
import '../types/utils.mjs';
|
|
26
|
-
import '@homer0/path-utils';
|
|
27
|
-
import '@homer0/simple-logger';
|
|
28
|
-
import '@homer0/simple-config';
|
|
29
|
-
import '@homer0/events-hub';
|
|
30
|
-
import '../utils/fns/statuses.mjs';
|
|
31
|
-
import 'statuses';
|
|
32
|
-
import 'fs/promises';
|
|
33
|
-
import '@homer0/deferred';
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
-
import { J as Jimpex } from '../../index-Bwf7JHu9.mjs';
|
|
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 'node-fetch';
|
|
12
|
-
import 'express';
|
|
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 { type EnsureBearerConstructorOptions, EnsureBearerToken, type EnsureBearerTokenErrorOptions, type EnsureBearerTokenOptions, type EnsureBearerTokenProviderOptions, ensureBearerTokenProvider };
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
-
import { J as Jimpex } from '../../index-Bwf7JHu9.mjs';
|
|
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 };
|
package/dist/types/events.d.mts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
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-Bwf7JHu9.mjs';
|
|
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/express.d.mts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
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 type { AsyncExpressMiddleware, ExpressErrorHandler, ExpressMiddleware, ExpressMiddlewareLike, RouterMethod };
|