jimpex 9.0.0 → 10.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 +20 -0
- package/dist/app/index.d.mts +1 -1
- package/dist/app/index.d.ts +1 -1
- package/dist/app/jimpex.d.mts +1 -1
- package/dist/app/jimpex.d.ts +1 -1
- package/dist/app/jimpex.js +13 -2
- package/dist/app/jimpex.js.map +1 -1
- package/dist/controllers/common/config.d.mts +2 -2
- package/dist/controllers/common/config.d.ts +2 -2
- package/dist/controllers/common/health.d.mts +3 -3
- package/dist/controllers/common/health.d.ts +3 -3
- package/dist/controllers/common/index.d.mts +2 -1
- package/dist/controllers/common/index.d.ts +2 -1
- package/dist/controllers/common/statics.d.mts +10 -2
- package/dist/controllers/common/statics.d.ts +10 -2
- package/dist/controllers/common/statics.js +9 -3
- package/dist/controllers/common/statics.js.map +1 -1
- package/dist/controllers/index.d.mts +2 -1
- package/dist/controllers/index.d.ts +2 -1
- package/dist/controllers/utils/gateway.d.mts +2 -2
- package/dist/controllers/utils/gateway.d.ts +2 -2
- package/dist/controllers/utils/gateway.js +3 -0
- package/dist/controllers/utils/gateway.js.map +1 -1
- package/dist/controllers/utils/index.d.mts +1 -1
- package/dist/controllers/utils/index.d.ts +1 -1
- package/dist/esm/app/jimpex.js +14 -3
- package/dist/esm/app/jimpex.js.map +1 -1
- package/dist/esm/{chunk-2B2CG5KL.js → chunk-F3FYYIAV.js} +1 -1
- package/dist/esm/controllers/common/config.js +1 -1
- package/dist/esm/controllers/common/health.js +1 -1
- package/dist/esm/controllers/common/statics.js +10 -4
- package/dist/esm/controllers/common/statics.js.map +1 -1
- package/dist/esm/controllers/utils/gateway.js +4 -1
- package/dist/esm/controllers/utils/gateway.js.map +1 -1
- package/dist/esm/middlewares/common/errorHandler.js +1 -1
- package/dist/esm/middlewares/common/forceHTTPS.js +1 -1
- package/dist/esm/middlewares/common/hsts.js +1 -1
- package/dist/esm/middlewares/html/fastHTML.js +1 -1
- package/dist/esm/middlewares/html/showHTML.js +1 -1
- package/dist/esm/middlewares/utils/versionValidator.js +1 -1
- package/dist/esm/services/common/appError.js +1 -1
- package/dist/esm/services/common/httpError.js +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 +1 -1
- package/dist/esm/services/frontend/index.js +1 -1
- package/dist/esm/services/html/htmlGenerator.js +1 -1
- package/dist/esm/services/html/index.js +1 -1
- package/dist/esm/services/http/apiClient.js +1 -1
- package/dist/esm/services/http/http.js +11 -5
- 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 +1 -1
- package/dist/esm/services/utils/ensureBearerToken.js +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/statuses.js +1 -1
- package/dist/esm/utils/fns/text.js +1 -1
- package/dist/esm/utils/wrappers.js +1 -1
- package/dist/{index-efeb437e.d.ts → index-Bwf7JHu9.d.mts} +6 -1
- package/dist/{index-b2a04c78.d.ts → index-C6I3NCC-.d.ts} +6 -1
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/middlewares/common/errorHandler.d.mts +3 -3
- package/dist/middlewares/common/errorHandler.d.ts +3 -3
- package/dist/middlewares/common/forceHTTPS.d.mts +3 -3
- package/dist/middlewares/common/forceHTTPS.d.ts +3 -3
- package/dist/middlewares/common/hsts.d.mts +3 -3
- package/dist/middlewares/common/hsts.d.ts +3 -3
- package/dist/middlewares/common/index.d.mts +1 -1
- package/dist/middlewares/common/index.d.ts +1 -1
- package/dist/middlewares/html/fastHTML.d.mts +2 -2
- package/dist/middlewares/html/fastHTML.d.ts +2 -2
- package/dist/middlewares/html/index.d.mts +1 -1
- package/dist/middlewares/html/index.d.ts +1 -1
- package/dist/middlewares/html/showHTML.d.mts +2 -2
- package/dist/middlewares/html/showHTML.d.ts +2 -2
- package/dist/middlewares/index.d.mts +1 -1
- package/dist/middlewares/index.d.ts +1 -1
- package/dist/middlewares/utils/index.d.mts +1 -1
- package/dist/middlewares/utils/index.d.ts +1 -1
- package/dist/middlewares/utils/versionValidator.d.mts +2 -2
- package/dist/middlewares/utils/versionValidator.d.ts +2 -2
- package/dist/services/common/appError.d.mts +2 -2
- package/dist/services/common/appError.d.ts +2 -2
- package/dist/services/common/httpError.d.mts +2 -2
- package/dist/services/common/httpError.d.ts +2 -2
- package/dist/services/common/index.d.mts +1 -1
- package/dist/services/common/index.d.ts +1 -1
- package/dist/services/common/sendFile.d.mts +2 -2
- package/dist/services/common/sendFile.d.ts +2 -2
- package/dist/services/frontend/frontendFs.d.mts +2 -2
- package/dist/services/frontend/frontendFs.d.ts +2 -2
- package/dist/services/frontend/index.d.mts +1 -1
- package/dist/services/frontend/index.d.ts +1 -1
- package/dist/services/html/htmlGenerator.d.mts +2 -2
- package/dist/services/html/htmlGenerator.d.ts +2 -2
- package/dist/services/html/index.d.mts +1 -1
- package/dist/services/html/index.d.ts +1 -1
- package/dist/services/http/apiClient.d.mts +2 -2
- package/dist/services/http/apiClient.d.ts +2 -2
- package/dist/services/http/http.d.mts +14 -8
- package/dist/services/http/http.d.ts +14 -8
- package/dist/services/http/http.js +10 -4
- package/dist/services/http/http.js.map +1 -1
- package/dist/services/http/index.d.mts +1 -1
- package/dist/services/http/index.d.ts +1 -1
- package/dist/services/http/responsesBuilder.d.mts +2 -2
- package/dist/services/http/responsesBuilder.d.ts +2 -2
- package/dist/services/index.d.mts +1 -1
- package/dist/services/index.d.ts +1 -1
- package/dist/services/utils/ensureBearerToken.d.mts +3 -3
- package/dist/services/utils/ensureBearerToken.d.ts +3 -3
- package/dist/services/utils/index.d.mts +1 -1
- package/dist/services/utils/index.d.ts +1 -1
- package/dist/types/events.d.mts +1 -1
- package/dist/types/events.d.ts +1 -1
- package/dist/types/express.d.mts +1 -1
- package/dist/types/express.d.ts +1 -1
- package/dist/types/http.d.mts +5 -2
- package/dist/types/http.d.ts +5 -2
- package/dist/types/http.js.map +1 -1
- package/dist/types/index.d.mts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/dist/types/options.d.mts +1 -1
- package/dist/types/options.d.ts +1 -1
- package/dist/types/utils.d.mts +1 -1
- package/dist/types/utils.d.ts +1 -1
- package/dist/utils/fns/statuses.d.mts +1 -1
- package/dist/utils/fns/statuses.d.ts +1 -1
- package/dist/utils/index.d.mts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/wrappers.d.mts +1 -1
- package/dist/utils/wrappers.d.ts +1 -1
- package/package.json +45 -44
- package/src/app/jimpex.ts +15 -2
- package/src/controllers/common/statics.ts +13 -2
- package/src/controllers/utils/gateway.ts +4 -0
- package/src/services/http/http.ts +13 -4
- package/src/types/http.ts +3 -0
- /package/dist/esm/{chunk-2B2CG5KL.js.map → chunk-F3FYYIAV.js.map} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
-
import { J as Jimpex } from '../../index-
|
|
2
|
+
import { J as Jimpex } from '../../index-Bwf7JHu9.mjs';
|
|
3
3
|
import { Response, NextFunction } from 'express';
|
|
4
4
|
import { PathUtils } from '@homer0/path-utils';
|
|
5
5
|
import '../../types/express.mjs';
|
|
@@ -99,4 +99,4 @@ declare const sendFile: ({ inject: { pathUtils } }: SendFileGeneratorOptions) =>
|
|
|
99
99
|
*/
|
|
100
100
|
declare const sendFileProvider: _homer0_jimple.Resource<"provider", "register", _homer0_jimple.ProviderRegisterFn<Jimpex>>;
|
|
101
101
|
|
|
102
|
-
export { SendFile, SendFileGeneratorOptions, SendFileOptions, sendFile, sendFileProvider };
|
|
102
|
+
export { type SendFile, type SendFileGeneratorOptions, type SendFileOptions, sendFile, sendFileProvider };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
-
import { J as Jimpex } from '../../index-
|
|
2
|
+
import { J as Jimpex } from '../../index-C6I3NCC-.js';
|
|
3
3
|
import { Response, NextFunction } from 'express';
|
|
4
4
|
import { PathUtils } from '@homer0/path-utils';
|
|
5
5
|
import '../../types/express.js';
|
|
@@ -99,4 +99,4 @@ declare const sendFile: ({ inject: { pathUtils } }: SendFileGeneratorOptions) =>
|
|
|
99
99
|
*/
|
|
100
100
|
declare const sendFileProvider: _homer0_jimple.Resource<"provider", "register", _homer0_jimple.ProviderRegisterFn<Jimpex>>;
|
|
101
101
|
|
|
102
|
-
export { SendFile, SendFileGeneratorOptions, SendFileOptions, sendFile, sendFileProvider };
|
|
102
|
+
export { type SendFile, type SendFileGeneratorOptions, type SendFileOptions, sendFile, sendFileProvider };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
-
import { J as Jimpex } from '../../index-
|
|
2
|
+
import { J as Jimpex } from '../../index-Bwf7JHu9.mjs';
|
|
3
3
|
import { PathUtils } from '@homer0/path-utils';
|
|
4
4
|
import fs from 'fs/promises';
|
|
5
5
|
import '../../types/express.mjs';
|
|
@@ -93,4 +93,4 @@ declare class FrontendFs {
|
|
|
93
93
|
*/
|
|
94
94
|
declare const frontendFsProvider: _homer0_jimple.Resource<"provider", "register", _homer0_jimple.ProviderRegisterFn<Jimpex>>;
|
|
95
95
|
|
|
96
|
-
export { FrontendFs, FrontendFsOptions, frontendFsProvider };
|
|
96
|
+
export { FrontendFs, type FrontendFsOptions, frontendFsProvider };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
-
import { J as Jimpex } from '../../index-
|
|
2
|
+
import { J as Jimpex } from '../../index-C6I3NCC-.js';
|
|
3
3
|
import { PathUtils } from '@homer0/path-utils';
|
|
4
4
|
import fs from 'fs/promises';
|
|
5
5
|
import '../../types/express.js';
|
|
@@ -93,4 +93,4 @@ declare class FrontendFs {
|
|
|
93
93
|
*/
|
|
94
94
|
declare const frontendFsProvider: _homer0_jimple.Resource<"provider", "register", _homer0_jimple.ProviderRegisterFn<Jimpex>>;
|
|
95
95
|
|
|
96
|
-
export { FrontendFs, FrontendFsOptions, frontendFsProvider };
|
|
96
|
+
export { FrontendFs, type FrontendFsOptions, frontendFsProvider };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
-
import { J as Jimpex } from '../../index-
|
|
2
|
+
import { J as Jimpex } from '../../index-Bwf7JHu9.mjs';
|
|
3
3
|
export { FrontendFs, FrontendFsOptions, frontendFsProvider } from './frontendFs.mjs';
|
|
4
4
|
import '../../types/express.mjs';
|
|
5
5
|
import 'express';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
-
import { J as Jimpex } from '../../index-
|
|
2
|
+
import { J as Jimpex } from '../../index-C6I3NCC-.js';
|
|
3
3
|
export { FrontendFs, FrontendFsOptions, frontendFsProvider } from './frontendFs.js';
|
|
4
4
|
import '../../types/express.js';
|
|
5
5
|
import 'express';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
-
import { J as Jimpex } from '../../index-
|
|
2
|
+
import { J as Jimpex } from '../../index-Bwf7JHu9.mjs';
|
|
3
3
|
import { SimpleLogger } from '@homer0/simple-logger';
|
|
4
4
|
import { SimpleConfig } from '@homer0/simple-config';
|
|
5
5
|
import { FrontendFs } from '../frontend/frontendFs.mjs';
|
|
@@ -234,4 +234,4 @@ declare class HTMLGenerator {
|
|
|
234
234
|
*/
|
|
235
235
|
declare const htmlGeneratorProvider: _homer0_jimple.ResourceCreator<"provider", "register", (options?: HTMLGeneratorProviderOptions) => (app: Jimpex) => void, _homer0_jimple.ProviderRegisterFn<Jimpex>>;
|
|
236
236
|
|
|
237
|
-
export { HTMLGenerator, HTMLGeneratorConstructorOptions, HTMLGeneratorOptions, HTMLGeneratorProviderOptions, HTMLGeneratorValuesService, htmlGeneratorProvider };
|
|
237
|
+
export { HTMLGenerator, type HTMLGeneratorConstructorOptions, type HTMLGeneratorOptions, type HTMLGeneratorProviderOptions, type HTMLGeneratorValuesService, htmlGeneratorProvider };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
-
import { J as Jimpex } from '../../index-
|
|
2
|
+
import { J as Jimpex } from '../../index-C6I3NCC-.js';
|
|
3
3
|
import { SimpleLogger } from '@homer0/simple-logger';
|
|
4
4
|
import { SimpleConfig } from '@homer0/simple-config';
|
|
5
5
|
import { FrontendFs } from '../frontend/frontendFs.js';
|
|
@@ -234,4 +234,4 @@ declare class HTMLGenerator {
|
|
|
234
234
|
*/
|
|
235
235
|
declare const htmlGeneratorProvider: _homer0_jimple.ResourceCreator<"provider", "register", (options?: HTMLGeneratorProviderOptions) => (app: Jimpex) => void, _homer0_jimple.ProviderRegisterFn<Jimpex>>;
|
|
236
236
|
|
|
237
|
-
export { HTMLGenerator, HTMLGeneratorConstructorOptions, HTMLGeneratorOptions, HTMLGeneratorProviderOptions, HTMLGeneratorValuesService, htmlGeneratorProvider };
|
|
237
|
+
export { HTMLGenerator, type HTMLGeneratorConstructorOptions, type HTMLGeneratorOptions, type HTMLGeneratorProviderOptions, type HTMLGeneratorValuesService, htmlGeneratorProvider };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
-
import { J as Jimpex } from '../../index-
|
|
2
|
+
import { J as Jimpex } from '../../index-Bwf7JHu9.mjs';
|
|
3
3
|
import { HTMLGeneratorProviderOptions } from './htmlGenerator.mjs';
|
|
4
4
|
export { HTMLGenerator, HTMLGeneratorConstructorOptions, HTMLGeneratorOptions, HTMLGeneratorValuesService, htmlGeneratorProvider } from './htmlGenerator.mjs';
|
|
5
5
|
import '../../types/express.mjs';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
-
import { J as Jimpex } from '../../index-
|
|
2
|
+
import { J as Jimpex } from '../../index-C6I3NCC-.js';
|
|
3
3
|
import { HTMLGeneratorProviderOptions } from './htmlGenerator.js';
|
|
4
4
|
export { HTMLGenerator, HTMLGeneratorConstructorOptions, HTMLGeneratorOptions, HTMLGeneratorValuesService, htmlGeneratorProvider } from './htmlGenerator.js';
|
|
5
5
|
import '../../types/express.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
-
import { J as Jimpex } from '../../index-
|
|
2
|
+
import { J as Jimpex } from '../../index-Bwf7JHu9.mjs';
|
|
3
3
|
import { HTTPErrorClass } from '../common/httpError.mjs';
|
|
4
4
|
import { HTTP } from './http.mjs';
|
|
5
5
|
import { APIClientOptions, APIClient as APIClient$1, ErrorResponse } from '@homer0/api-utils';
|
|
@@ -167,4 +167,4 @@ type APIClientProviderOptions = {
|
|
|
167
167
|
*/
|
|
168
168
|
declare const apiClientProvider: _homer0_jimple.ResourceCreator<"provider", "register", (options?: APIClientProviderOptions) => (app: Jimpex) => void, _homer0_jimple.ProviderRegisterFn<Jimpex>>;
|
|
169
169
|
|
|
170
|
-
export { APIClient, APIClientConfig, APIClientConstructorOptions, APIClientProviderOptions, APIClientSettings, EndpointsType, apiClientProvider };
|
|
170
|
+
export { APIClient, type APIClientConfig, type APIClientConstructorOptions, type APIClientProviderOptions, type APIClientSettings, type EndpointsType, apiClientProvider };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
-
import { J as Jimpex } from '../../index-
|
|
2
|
+
import { J as Jimpex } from '../../index-C6I3NCC-.js';
|
|
3
3
|
import { HTTPErrorClass } from '../common/httpError.js';
|
|
4
4
|
import { HTTP } from './http.js';
|
|
5
5
|
import { APIClientOptions, APIClient as APIClient$1, ErrorResponse } from '@homer0/api-utils';
|
|
@@ -167,4 +167,4 @@ type APIClientProviderOptions = {
|
|
|
167
167
|
*/
|
|
168
168
|
declare const apiClientProvider: _homer0_jimple.ResourceCreator<"provider", "register", (options?: APIClientProviderOptions) => (app: Jimpex) => void, _homer0_jimple.ProviderRegisterFn<Jimpex>>;
|
|
169
169
|
|
|
170
|
-
export { APIClient, APIClientConfig, APIClientConstructorOptions, APIClientProviderOptions, APIClientSettings, EndpointsType, apiClientProvider };
|
|
170
|
+
export { APIClient, type APIClientConfig, type APIClientConstructorOptions, type APIClientProviderOptions, type APIClientSettings, type EndpointsType, apiClientProvider };
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
-
import { J as Jimpex } from '../../index-
|
|
2
|
+
import { J as Jimpex } from '../../index-Bwf7JHu9.mjs';
|
|
3
3
|
import { Request } from 'express';
|
|
4
|
-
import {
|
|
4
|
+
import { NodeFetch } from '../../types/http.mjs';
|
|
5
5
|
import { SimpleLogger } from '@homer0/simple-logger';
|
|
6
|
+
import { BodyInit, Response, RequestInit } from 'node-fetch';
|
|
6
7
|
import '../../types/express.mjs';
|
|
7
|
-
import '../../types/http.mjs';
|
|
8
|
-
import 'https';
|
|
9
|
-
import 'http';
|
|
10
|
-
import 'spdy';
|
|
11
8
|
import '../../types/utils.mjs';
|
|
12
9
|
import '@homer0/path-utils';
|
|
13
10
|
import '@homer0/simple-config';
|
|
14
11
|
import '@homer0/events-hub';
|
|
12
|
+
import 'https';
|
|
13
|
+
import 'http';
|
|
14
|
+
import 'spdy';
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* The options to customize the service.
|
|
@@ -35,6 +35,7 @@ type HTTPContructorOptions = Partial<HTTPOptions> & {
|
|
|
35
35
|
*/
|
|
36
36
|
inject: {
|
|
37
37
|
logger: SimpleLogger;
|
|
38
|
+
nodeFetch: NodeFetch;
|
|
38
39
|
};
|
|
39
40
|
};
|
|
40
41
|
/**
|
|
@@ -99,6 +100,11 @@ declare class HTTP {
|
|
|
99
100
|
* The service used to log information in the terminal.
|
|
100
101
|
*/
|
|
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;
|
|
102
108
|
/**
|
|
103
109
|
* The service customization options.
|
|
104
110
|
*/
|
|
@@ -106,7 +112,7 @@ declare class HTTP {
|
|
|
106
112
|
/**
|
|
107
113
|
* @param options The options to construct the class.
|
|
108
114
|
*/
|
|
109
|
-
constructor({ inject: { logger }, ...options }: HTTPContructorOptions);
|
|
115
|
+
constructor({ inject: { logger, nodeFetch }, ...options }: HTTPContructorOptions);
|
|
110
116
|
/**
|
|
111
117
|
* Makes a fetch request.
|
|
112
118
|
*
|
|
@@ -173,4 +179,4 @@ declare class HTTP {
|
|
|
173
179
|
*/
|
|
174
180
|
declare const httpProvider: _homer0_jimple.Resource<"provider", "register", _homer0_jimple.ProviderRegisterFn<Jimpex>>;
|
|
175
181
|
|
|
176
|
-
export { GetCustomHeadersFromRequestOptions, HTTP, HTTPContructorOptions, HTTPFetchBody, HTTPFetchOptions, HTTPOptions, httpProvider };
|
|
182
|
+
export { type GetCustomHeadersFromRequestOptions, HTTP, type HTTPContructorOptions, type HTTPFetchBody, type HTTPFetchOptions, type HTTPOptions, httpProvider };
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
-
import { J as Jimpex } from '../../index-
|
|
2
|
+
import { J as Jimpex } from '../../index-C6I3NCC-.js';
|
|
3
3
|
import { Request } from 'express';
|
|
4
|
-
import {
|
|
4
|
+
import { NodeFetch } from '../../types/http.js';
|
|
5
5
|
import { SimpleLogger } from '@homer0/simple-logger';
|
|
6
|
+
import { BodyInit, Response, RequestInit } from 'node-fetch';
|
|
6
7
|
import '../../types/express.js';
|
|
7
|
-
import '../../types/http.js';
|
|
8
|
-
import 'https';
|
|
9
|
-
import 'http';
|
|
10
|
-
import 'spdy';
|
|
11
8
|
import '../../types/utils.js';
|
|
12
9
|
import '@homer0/path-utils';
|
|
13
10
|
import '@homer0/simple-config';
|
|
14
11
|
import '@homer0/events-hub';
|
|
12
|
+
import 'https';
|
|
13
|
+
import 'http';
|
|
14
|
+
import 'spdy';
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* The options to customize the service.
|
|
@@ -35,6 +35,7 @@ type HTTPContructorOptions = Partial<HTTPOptions> & {
|
|
|
35
35
|
*/
|
|
36
36
|
inject: {
|
|
37
37
|
logger: SimpleLogger;
|
|
38
|
+
nodeFetch: NodeFetch;
|
|
38
39
|
};
|
|
39
40
|
};
|
|
40
41
|
/**
|
|
@@ -99,6 +100,11 @@ declare class HTTP {
|
|
|
99
100
|
* The service used to log information in the terminal.
|
|
100
101
|
*/
|
|
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;
|
|
102
108
|
/**
|
|
103
109
|
* The service customization options.
|
|
104
110
|
*/
|
|
@@ -106,7 +112,7 @@ declare class HTTP {
|
|
|
106
112
|
/**
|
|
107
113
|
* @param options The options to construct the class.
|
|
108
114
|
*/
|
|
109
|
-
constructor({ inject: { logger }, ...options }: HTTPContructorOptions);
|
|
115
|
+
constructor({ inject: { logger, nodeFetch }, ...options }: HTTPContructorOptions);
|
|
110
116
|
/**
|
|
111
117
|
* Makes a fetch request.
|
|
112
118
|
*
|
|
@@ -173,4 +179,4 @@ declare class HTTP {
|
|
|
173
179
|
*/
|
|
174
180
|
declare const httpProvider: _homer0_jimple.Resource<"provider", "register", _homer0_jimple.ProviderRegisterFn<Jimpex>>;
|
|
175
181
|
|
|
176
|
-
export { GetCustomHeadersFromRequestOptions, HTTP, HTTPContructorOptions, HTTPFetchBody, HTTPFetchOptions, HTTPOptions, httpProvider };
|
|
182
|
+
export { type GetCustomHeadersFromRequestOptions, HTTP, type HTTPContructorOptions, type HTTPFetchBody, type HTTPFetchOptions, type HTTPOptions, httpProvider };
|
|
@@ -37,7 +37,6 @@ __export(http_exports, {
|
|
|
37
37
|
httpProvider: () => httpProvider
|
|
38
38
|
});
|
|
39
39
|
module.exports = __toCommonJS(http_exports);
|
|
40
|
-
var import_node_fetch = __toESM(require("node-fetch"));
|
|
41
40
|
var import_urijs = __toESM(require("urijs"));
|
|
42
41
|
var import_deep_assign = require("@homer0/deep-assign");
|
|
43
42
|
var import_utils = require("../../utils");
|
|
@@ -45,16 +44,22 @@ class HTTP {
|
|
|
45
44
|
/**
|
|
46
45
|
* @param options The options to construct the class.
|
|
47
46
|
*/
|
|
48
|
-
constructor({ inject: { logger }, ...options }) {
|
|
47
|
+
constructor({ inject: { logger, nodeFetch }, ...options }) {
|
|
49
48
|
/**
|
|
50
49
|
* The service used to log information in the terminal.
|
|
51
50
|
*/
|
|
52
51
|
__publicField(this, "_logger");
|
|
52
|
+
/**
|
|
53
|
+
* The node-fetch library. Since it's an ESM only module, Jimpex loads it on boot and makes
|
|
54
|
+
* it available on the container.
|
|
55
|
+
*/
|
|
56
|
+
__publicField(this, "_nodeFetch");
|
|
53
57
|
/**
|
|
54
58
|
* The service customization options.
|
|
55
59
|
*/
|
|
56
60
|
__publicField(this, "_options");
|
|
57
61
|
this._logger = logger;
|
|
62
|
+
this._nodeFetch = nodeFetch;
|
|
58
63
|
this._options = (0, import_deep_assign.deepAssignWithOverwrite)(
|
|
59
64
|
{
|
|
60
65
|
logRequests: false
|
|
@@ -97,7 +102,7 @@ class HTTP {
|
|
|
97
102
|
if (logRequests) {
|
|
98
103
|
this._logRequest(useURL, fetchOptions);
|
|
99
104
|
}
|
|
100
|
-
const response = await
|
|
105
|
+
const response = await this._nodeFetch(useURL, fetchOptions);
|
|
101
106
|
if (logRequests) {
|
|
102
107
|
this._logResponse(response);
|
|
103
108
|
}
|
|
@@ -197,7 +202,8 @@ const httpProvider = (0, import_utils.provider)((app) => {
|
|
|
197
202
|
const logRequests = config.get("debug.logRequests") === true;
|
|
198
203
|
return new HTTP({
|
|
199
204
|
inject: {
|
|
200
|
-
logger: app.get("logger")
|
|
205
|
+
logger: app.get("logger"),
|
|
206
|
+
nodeFetch: app.get("node-fetch")
|
|
201
207
|
},
|
|
202
208
|
logRequests
|
|
203
209
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/services/http/http.ts"],"sourcesContent":["import fetch, { type RequestInit, type BodyInit } from 'node-fetch';\nimport urijs from 'urijs';\nimport { deepAssignWithOverwrite } from '@homer0/deep-assign';\nimport { provider } from '../../utils';\nimport { Logger, Request, HTTPResponse } from '../../types';\n/**\n * The options to customize the service.\n *\n * @group Services/HTTP\n */\nexport type HTTPOptions = {\n /**\n * Whether or not the service should log the requests and their responses.\n */\n logRequests?: boolean;\n};\n/**\n * The options to construct a {@link HTTP}.\n *\n * @group Services/HTTP\n */\nexport type HTTPContructorOptions = Partial<HTTPOptions> & {\n /**\n * A dictionary with the dependencies to inject.\n */\n inject: {\n logger: Logger;\n };\n};\n/**\n * The allowed formats for the body of a request.\n *\n * @group Services/HTTP\n */\nexport type HTTPFetchBody = string | Record<string | number, unknown> | BodyInit;\n/**\n * The options for a request.\n *\n * @group Services/HTTP\n */\nexport type HTTPFetchOptions = {\n /**\n * The HTTP method.\n *\n * @default 'GET'\n */\n method?: string;\n /**\n * The headers dictionary.\n */\n headers?: Record<string, string>;\n /**\n * The body of the request.\n */\n body?: HTTPFetchBody;\n /**\n * A dictionary of query string parameters.\n */\n qs?: Record<string, unknown>;\n /**\n * A request object generated by the application. This can be used to copy information\n * like custom headers or the IP (for the X-Forwarded-For header).\n */\n req?: Request;\n};\n/**\n * The options for the method that extracts custom headers from a request.\n *\n * @group Services/HTTP\n */\nexport type GetCustomHeadersFromRequestOptions = {\n /**\n * Since the method considers all headers that start with `x-` as custom headers,\n * setting this to `false` is the only way to exclude `x-forwarded-` headers from the\n * list.\n *\n * @default false\n */\n includeXForwardedHeaders?: boolean;\n};\n/**\n * A set of utilities to work with HTTP requests and responses.\n *\n * @group Services\n * @group Services/HTTP\n */\nexport class HTTP {\n /**\n * The service used to log information in the terminal.\n */\n protected readonly _logger: Logger;\n /**\n * The service customization options.\n */\n protected readonly _options: HTTPOptions;\n /**\n * @param options The options to construct the class.\n */\n constructor({ inject: { logger }, ...options }: HTTPContructorOptions) {\n this._logger = logger;\n this._options = deepAssignWithOverwrite(\n {\n logRequests: false,\n },\n options,\n );\n\n this.fetch = this.fetch.bind(this);\n }\n /**\n * Makes a fetch request.\n *\n * @param url The URL to fetch.\n * @param options The custom options for the request.\n */\n async fetch(url: string, options: HTTPFetchOptions = {}): Promise<HTTPResponse> {\n let useURL = url;\n if (options.qs) {\n useURL = urijs(url).query(options.qs).toString();\n }\n\n const fetchOptions: RequestInit = {\n method: (options.method || 'get').toUpperCase(),\n body: options.body as BodyInit,\n };\n\n let defaultHeaders: Record<string, string> | undefined;\n if (options.req) {\n defaultHeaders = this.getCustomHeadersFromRequest(options.req);\n const ip = this.getIPFromRequest(options.req);\n if (ip) {\n defaultHeaders['x-forwarded-for'] = ip;\n }\n }\n const headers = {\n ...defaultHeaders,\n ...options.headers,\n };\n\n if (Object.keys(headers).length) {\n fetchOptions.headers = this.normalizeHeaders(headers);\n }\n\n const { logRequests } = this._options;\n if (logRequests) {\n this._logRequest(useURL, fetchOptions);\n }\n\n const response = await fetch(useURL, fetchOptions);\n if (logRequests) {\n this._logResponse(response);\n }\n\n return response;\n }\n /**\n * Tries to get the IP address from a given request.\n *\n * @param req The request from which it will try to obtain the IP address.\n */\n getIPFromRequest(req: Request): string | undefined {\n const headerValue = req.headers['x-forwarded-for'];\n if (headerValue) {\n return String(headerValue);\n }\n\n return req?.connection?.remoteAddress || req?.socket?.remoteAddress;\n }\n /**\n * Creates a dictionary with all the custom headers a request has. By custom header it\n * means all the headers which name start with `x-`.\n *\n * @param req The request from which it will try to get the headers.\n * @param options The options to customize the behavior with certain headers.\n */\n getCustomHeadersFromRequest(\n req: Request,\n options: GetCustomHeadersFromRequestOptions = {},\n ): Record<string, string> {\n const { includeXForwardedHeaders = false } = options;\n return Object.keys(req.headers).reduce<Record<string, string>>((acc, headerName) => {\n if (\n headerName.startsWith('x-') &&\n (includeXForwardedHeaders || !headerName.startsWith('x-forwarded-'))\n ) {\n acc[headerName] = req.headers[headerName] as string;\n }\n return acc;\n }, {});\n }\n /**\n * It takes a dictionary of headers and normalize the names so each word will start with\n * an upper case character. This is helpful in case you added custom headers and didn't\n * care about the casing, or when copying headers from a server request, as they all\n * come tranformed into lower case.\n *\n * @param headers The dictionary of headers to normalize.\n */\n normalizeHeaders(headers: Record<string, string>): Record<string, string> {\n return Object.keys(headers).reduce<Record<string, string>>((acc, name) => {\n const newName = name\n .split('-')\n .map((part) => part.replace(/^(\\w)/, (_, letter) => letter.toUpperCase()))\n .join('-');\n\n acc[newName] = headers[name]!;\n return acc;\n }, {});\n }\n /**\n * The customization options.\n */\n get options(): Readonly<HTTPOptions> {\n return deepAssignWithOverwrite({}, this._options);\n }\n /**\n * Logs a request information into the terminal.\n *\n * @param url The request URL.\n * @param options The options for the request.\n */\n protected _logRequest(url: string, options: RequestInit): void {\n const { method, headers } = options;\n const prefix = 'REQUEST> ';\n const lines = ['--->>', `${prefix}${method} ${url}`];\n if (headers) {\n Object.keys(headers).forEach((header) => {\n const value = headers[header as keyof typeof headers];\n lines.push(`${prefix}${header}: ${value}`);\n });\n }\n\n if (options.body) {\n lines.push(`${prefix}body: \"${options.body}\"`);\n }\n\n this._logger.info(lines);\n }\n /**\n * Logs a response information into the terminal.\n *\n * @param response The response to log.\n */\n protected _logResponse(response: HTTPResponse) {\n const prefix = 'RESPONSE> ';\n const lines = [\n '<<---',\n `${prefix}${response.url}`,\n `${prefix}status: ${response.status}`,\n ];\n\n response.headers.forEach((value, header) => {\n lines.push(`${prefix}${header}: ${value}`);\n });\n\n this._logger.info(lines);\n }\n}\n/**\n * The service provider that once registered on the container will set an instance of\n * {@link HTTP} as the `http` service. The provider also checks the `debug.logRequests`\n * setting on the application configuration in order to enable or not the logging of\n * requests/responses.\n *\n * @example\n *\n * // Register it on the container\n * container.register(httpProvider);\n * // Getting access to the service instance\n * const http = container.get<HTTP>('http');\n *\n * @group Providers\n * @group Services/HTTP\n */\nexport const httpProvider = provider((app) => {\n app.set('http', () => {\n const config = app.getConfig();\n const logRequests = config.get<boolean | undefined>('debug.logRequests') === true;\n return new HTTP({\n inject: {\n logger: app.get('logger'),\n },\n logRequests,\n });\n });\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wBAAuD;AACvD,mBAAkB;AAClB,yBAAwC;AACxC,mBAAyB;AAmFlB,MAAM,KAAK;AAAA;AAAA;AAAA;AAAA,EAYhB,YAAY,EAAE,QAAQ,EAAE,OAAO,GAAG,GAAG,QAAQ,GAA0B;AARvE;AAAA;AAAA;AAAA,wBAAmB;AAInB;AAAA;AAAA;AAAA,wBAAmB;AAKjB,SAAK,UAAU;AACf,SAAK,eAAW;AAAA,MACd;AAAA,QACE,aAAa;AAAA,MACf;AAAA,MACA;AAAA,IACF;AAEA,SAAK,QAAQ,KAAK,MAAM,KAAK,IAAI;AAAA,EACnC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,MAAM,KAAa,UAA4B,CAAC,GAA0B;AAC9E,QAAI,SAAS;AACb,QAAI,QAAQ,IAAI;AACd,mBAAS,aAAAA,SAAM,GAAG,EAAE,MAAM,QAAQ,EAAE,EAAE,SAAS;AAAA,IACjD;AAEA,UAAM,eAA4B;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CAAC,OAAO,WAAW;AAC1C,YAAM,KAAK,GAAG,MAAM,GAAG,MAAM,KAAK,KAAK,EAAE;AAAA,IAC3C,CAAC;AAED,SAAK,QAAQ,KAAK,KAAK;AAAA,EACzB;AACF;AAiBO,MAAM,mBAAe,uBAAS,CAAC,QAAQ;AAC5C,MAAI,IAAI,QAAQ,MAAM;AACpB,UAAM,SAAS,IAAI,UAAU;AAC7B,UAAM,cAAc,OAAO,IAAyB,mBAAmB,MAAM;AAC7E,WAAO,IAAI,KAAK;AAAA,MACd,QAAQ;AAAA,QACN,QAAQ,IAAI,IAAI,QAAQ;AAAA,MAC1B;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AACH,CAAC;","names":["urijs","fetch"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/services/http/http.ts"],"sourcesContent":["import urijs from 'urijs';\nimport type { RequestInit, BodyInit } from 'node-fetch';\nimport { deepAssignWithOverwrite } from '@homer0/deep-assign';\nimport { provider } from '../../utils';\nimport { Logger, Request, HTTPResponse, NodeFetch } from '../../types';\n\n/**\n * The options to customize the service.\n *\n * @group Services/HTTP\n */\nexport type HTTPOptions = {\n /**\n * Whether or not the service should log the requests and their responses.\n */\n logRequests?: boolean;\n};\n/**\n * The options to construct a {@link HTTP}.\n *\n * @group Services/HTTP\n */\nexport type HTTPContructorOptions = Partial<HTTPOptions> & {\n /**\n * A dictionary with the dependencies to inject.\n */\n inject: {\n logger: Logger;\n nodeFetch: NodeFetch;\n };\n};\n/**\n * The allowed formats for the body of a request.\n *\n * @group Services/HTTP\n */\nexport type HTTPFetchBody = string | Record<string | number, unknown> | BodyInit;\n/**\n * The options for a request.\n *\n * @group Services/HTTP\n */\nexport type HTTPFetchOptions = {\n /**\n * The HTTP method.\n *\n * @default 'GET'\n */\n method?: string;\n /**\n * The headers dictionary.\n */\n headers?: Record<string, string>;\n /**\n * The body of the request.\n */\n body?: HTTPFetchBody;\n /**\n * A dictionary of query string parameters.\n */\n qs?: Record<string, unknown>;\n /**\n * A request object generated by the application. This can be used to copy information\n * like custom headers or the IP (for the X-Forwarded-For header).\n */\n req?: Request;\n};\n/**\n * The options for the method that extracts custom headers from a request.\n *\n * @group Services/HTTP\n */\nexport type GetCustomHeadersFromRequestOptions = {\n /**\n * Since the method considers all headers that start with `x-` as custom headers,\n * setting this to `false` is the only way to exclude `x-forwarded-` headers from the\n * list.\n *\n * @default false\n */\n includeXForwardedHeaders?: boolean;\n};\n/**\n * A set of utilities to work with HTTP requests and responses.\n *\n * @group Services\n * @group Services/HTTP\n */\nexport class HTTP {\n /**\n * The service used to log information in the terminal.\n */\n protected readonly _logger: Logger;\n /**\n * The node-fetch library. Since it's an ESM only module, Jimpex loads it on boot and makes\n * it available on the container.\n */\n protected readonly _nodeFetch: NodeFetch;\n /**\n * The service customization options.\n */\n protected readonly _options: HTTPOptions;\n /**\n * @param options The options to construct the class.\n */\n constructor({ inject: { logger, nodeFetch }, ...options }: HTTPContructorOptions) {\n this._logger = logger;\n this._nodeFetch = nodeFetch;\n this._options = deepAssignWithOverwrite(\n {\n logRequests: false,\n },\n options,\n );\n\n this.fetch = this.fetch.bind(this);\n }\n /**\n * Makes a fetch request.\n *\n * @param url The URL to fetch.\n * @param options The custom options for the request.\n */\n async fetch(url: string, options: HTTPFetchOptions = {}): Promise<HTTPResponse> {\n let useURL = url;\n if (options.qs) {\n useURL = urijs(url).query(options.qs).toString();\n }\n\n const fetchOptions: RequestInit = {\n method: (options.method || 'get').toUpperCase(),\n body: options.body as BodyInit,\n };\n\n let defaultHeaders: Record<string, string> | undefined;\n if (options.req) {\n defaultHeaders = this.getCustomHeadersFromRequest(options.req);\n const ip = this.getIPFromRequest(options.req);\n if (ip) {\n defaultHeaders['x-forwarded-for'] = ip;\n }\n }\n const headers = {\n ...defaultHeaders,\n ...options.headers,\n };\n\n if (Object.keys(headers).length) {\n fetchOptions.headers = this.normalizeHeaders(headers);\n }\n\n const { logRequests } = this._options;\n if (logRequests) {\n this._logRequest(useURL, fetchOptions);\n }\n\n const response = await this._nodeFetch(useURL, fetchOptions);\n if (logRequests) {\n this._logResponse(response);\n }\n\n return response;\n }\n /**\n * Tries to get the IP address from a given request.\n *\n * @param req The request from which it will try to obtain the IP address.\n */\n getIPFromRequest(req: Request): string | undefined {\n const headerValue = req.headers['x-forwarded-for'];\n if (headerValue) {\n return String(headerValue);\n }\n\n return req?.connection?.remoteAddress || req?.socket?.remoteAddress;\n }\n /**\n * Creates a dictionary with all the custom headers a request has. By custom header it\n * means all the headers which name start with `x-`.\n *\n * @param req The request from which it will try to get the headers.\n * @param options The options to customize the behavior with certain headers.\n */\n getCustomHeadersFromRequest(\n req: Request,\n options: GetCustomHeadersFromRequestOptions = {},\n ): Record<string, string> {\n const { includeXForwardedHeaders = false } = options;\n return Object.keys(req.headers).reduce<Record<string, string>>((acc, headerName) => {\n if (\n headerName.startsWith('x-') &&\n (includeXForwardedHeaders || !headerName.startsWith('x-forwarded-'))\n ) {\n acc[headerName] = req.headers[headerName] as string;\n }\n return acc;\n }, {});\n }\n /**\n * It takes a dictionary of headers and normalize the names so each word will start with\n * an upper case character. This is helpful in case you added custom headers and didn't\n * care about the casing, or when copying headers from a server request, as they all\n * come tranformed into lower case.\n *\n * @param headers The dictionary of headers to normalize.\n */\n normalizeHeaders(headers: Record<string, string>): Record<string, string> {\n return Object.keys(headers).reduce<Record<string, string>>((acc, name) => {\n const newName = name\n .split('-')\n .map((part) => part.replace(/^(\\w)/, (_, letter) => letter.toUpperCase()))\n .join('-');\n\n acc[newName] = headers[name]!;\n return acc;\n }, {});\n }\n /**\n * The customization options.\n */\n get options(): Readonly<HTTPOptions> {\n return deepAssignWithOverwrite({}, this._options);\n }\n /**\n * Logs a request information into the terminal.\n *\n * @param url The request URL.\n * @param options The options for the request.\n */\n protected _logRequest(url: string, options: RequestInit): void {\n const { method, headers } = options;\n const prefix = 'REQUEST> ';\n const lines = ['--->>', `${prefix}${method} ${url}`];\n if (headers) {\n Object.keys(headers).forEach((header) => {\n const value = headers[header as keyof typeof headers];\n lines.push(`${prefix}${header}: ${value}`);\n });\n }\n\n if (options.body) {\n lines.push(`${prefix}body: \"${options.body}\"`);\n }\n\n this._logger.info(lines);\n }\n /**\n * Logs a response information into the terminal.\n *\n * @param response The response to log.\n */\n protected _logResponse(response: HTTPResponse) {\n const prefix = 'RESPONSE> ';\n const lines = [\n '<<---',\n `${prefix}${response.url}`,\n `${prefix}status: ${response.status}`,\n ];\n\n response.headers.forEach((value, header) => {\n lines.push(`${prefix}${header}: ${value}`);\n });\n\n this._logger.info(lines);\n }\n}\n/**\n * The service provider that once registered on the container will set an instance of\n * {@link HTTP} as the `http` service. The provider also checks the `debug.logRequests`\n * setting on the application configuration in order to enable or not the logging of\n * requests/responses.\n *\n * @example\n *\n * // Register it on the container\n * container.register(httpProvider);\n * // Getting access to the service instance\n * const http = container.get<HTTP>('http');\n *\n * @group Providers\n * @group Services/HTTP\n */\nexport const httpProvider = provider((app) => {\n app.set('http', () => {\n const config = app.getConfig();\n const logRequests = config.get<boolean | undefined>('debug.logRequests') === true;\n return new HTTP({\n inject: {\n logger: app.get('logger'),\n nodeFetch: app.get('node-fetch'),\n },\n logRequests,\n });\n });\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAElB,yBAAwC;AACxC,mBAAyB;AAqFlB,MAAM,KAAK;AAAA;AAAA;AAAA;AAAA,EAiBhB,YAAY,EAAE,QAAQ,EAAE,QAAQ,UAAU,GAAG,GAAG,QAAQ,GAA0B;AAblF;AAAA;AAAA;AAAA,wBAAmB;AAKnB;AAAA;AAAA;AAAA;AAAA,wBAAmB;AAInB;AAAA;AAAA;AAAA,wBAAmB;AAKjB,SAAK,UAAU;AACf,SAAK,aAAa;AAClB,SAAK,eAAW;AAAA,MACd;AAAA,QACE,aAAa;AAAA,MACf;AAAA,MACA;AAAA,IACF;AAEA,SAAK,QAAQ,KAAK,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,QAAQ,KAAK,KAAK;AAAA,EACzB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMU,aAAa,UAAwB;AAC7C,UAAM,SAAS;AACf,UAAM,QAAQ;AAAA,MACZ;AAAA,MACA,GAAG,MAAM,GAAG,SAAS,GAAG;AAAA,MACxB,GAAG,MAAM,WAAW,SAAS,MAAM;AAAA,IACrC;AAEA,aAAS,QAAQ,QAAQ,CAAC,OAAO,WAAW;AAC1C,YAAM,KAAK,GAAG,MAAM,GAAG,MAAM,KAAK,KAAK,EAAE;AAAA,IAC3C,CAAC;AAED,SAAK,QAAQ,KAAK,KAAK;AAAA,EACzB;AACF;AAiBO,MAAM,mBAAe,uBAAS,CAAC,QAAQ;AAC5C,MAAI,IAAI,QAAQ,MAAM;AACpB,UAAM,SAAS,IAAI,UAAU;AAC7B,UAAM,cAAc,OAAO,IAAyB,mBAAmB,MAAM;AAC7E,WAAO,IAAI,KAAK;AAAA,MACd,QAAQ;AAAA,QACN,QAAQ,IAAI,IAAI,QAAQ;AAAA,QACxB,WAAW,IAAI,IAAI,YAAY;AAAA,MACjC;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AACH,CAAC;","names":["urijs"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
-
import { J as Jimpex } from '../../index-
|
|
2
|
+
import { J as Jimpex } from '../../index-Bwf7JHu9.mjs';
|
|
3
3
|
export { ErrorResponse } from '@homer0/api-utils';
|
|
4
4
|
import { APIClientProviderOptions } from './apiClient.mjs';
|
|
5
5
|
export { APIClient, APIClientConfig, APIClientConstructorOptions, APIClientSettings, EndpointsType, apiClientProvider } from './apiClient.mjs';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
-
import { J as Jimpex } from '../../index-
|
|
2
|
+
import { J as Jimpex } from '../../index-C6I3NCC-.js';
|
|
3
3
|
export { ErrorResponse } from '@homer0/api-utils';
|
|
4
4
|
import { APIClientProviderOptions } from './apiClient.js';
|
|
5
5
|
export { APIClient, APIClientConfig, APIClientConstructorOptions, APIClientSettings, EndpointsType, apiClientProvider } from './apiClient.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
-
import { J as Jimpex } from '../../index-
|
|
2
|
+
import { J as Jimpex } from '../../index-Bwf7JHu9.mjs';
|
|
3
3
|
import { Response } from 'express';
|
|
4
4
|
import { Statuses } from '../../utils/fns/statuses.mjs';
|
|
5
5
|
import { SimpleConfig } from '@homer0/simple-config';
|
|
@@ -176,4 +176,4 @@ declare class ResponsesBuilder {
|
|
|
176
176
|
*/
|
|
177
177
|
declare const responsesBuilderProvider: _homer0_jimple.Resource<"provider", "register", _homer0_jimple.ProviderRegisterFn<Jimpex>>;
|
|
178
178
|
|
|
179
|
-
export { HTMLPostMessageResponseOptions, JSONResponseOptions, ResponsesBuilder, ResponsesBuilderConstructorOptions, responsesBuilderProvider };
|
|
179
|
+
export { type HTMLPostMessageResponseOptions, type JSONResponseOptions, ResponsesBuilder, type ResponsesBuilderConstructorOptions, responsesBuilderProvider };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
-
import { J as Jimpex } from '../../index-
|
|
2
|
+
import { J as Jimpex } from '../../index-C6I3NCC-.js';
|
|
3
3
|
import { Response } from 'express';
|
|
4
4
|
import { Statuses } from '../../utils/fns/statuses.js';
|
|
5
5
|
import { SimpleConfig } from '@homer0/simple-config';
|
|
@@ -176,4 +176,4 @@ declare class ResponsesBuilder {
|
|
|
176
176
|
*/
|
|
177
177
|
declare const responsesBuilderProvider: _homer0_jimple.Resource<"provider", "register", _homer0_jimple.ProviderRegisterFn<Jimpex>>;
|
|
178
178
|
|
|
179
|
-
export { HTMLPostMessageResponseOptions, JSONResponseOptions, ResponsesBuilder, ResponsesBuilderConstructorOptions, responsesBuilderProvider };
|
|
179
|
+
export { type HTMLPostMessageResponseOptions, type JSONResponseOptions, ResponsesBuilder, type ResponsesBuilderConstructorOptions, responsesBuilderProvider };
|
|
@@ -14,7 +14,7 @@ export { GetCustomHeadersFromRequestOptions, HTTP, HTTPContructorOptions, HTTPFe
|
|
|
14
14
|
export { HTMLPostMessageResponseOptions, JSONResponseOptions, ResponsesBuilder, ResponsesBuilderConstructorOptions, responsesBuilderProvider } from './http/responsesBuilder.mjs';
|
|
15
15
|
export { EnsureBearerConstructorOptions, EnsureBearerToken, EnsureBearerTokenErrorOptions, EnsureBearerTokenOptions, EnsureBearerTokenProviderOptions, ensureBearerTokenProvider } from './utils/ensureBearerToken.mjs';
|
|
16
16
|
import '@homer0/jimple';
|
|
17
|
-
import '../index-
|
|
17
|
+
import '../index-Bwf7JHu9.mjs';
|
|
18
18
|
import '../types/express.mjs';
|
|
19
19
|
import 'express';
|
|
20
20
|
import '../types/http.mjs';
|
package/dist/services/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export { GetCustomHeadersFromRequestOptions, HTTP, HTTPContructorOptions, HTTPFe
|
|
|
14
14
|
export { HTMLPostMessageResponseOptions, JSONResponseOptions, ResponsesBuilder, ResponsesBuilderConstructorOptions, responsesBuilderProvider } from './http/responsesBuilder.js';
|
|
15
15
|
export { EnsureBearerConstructorOptions, EnsureBearerToken, EnsureBearerTokenErrorOptions, EnsureBearerTokenOptions, EnsureBearerTokenProviderOptions, ensureBearerTokenProvider } from './utils/ensureBearerToken.js';
|
|
16
16
|
import '@homer0/jimple';
|
|
17
|
-
import '../index-
|
|
17
|
+
import '../index-C6I3NCC-.js';
|
|
18
18
|
import '../types/express.js';
|
|
19
19
|
import 'express';
|
|
20
20
|
import '../types/http.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
-
import { J as Jimpex } from '../../index-
|
|
2
|
+
import { J as Jimpex } from '../../index-Bwf7JHu9.mjs';
|
|
3
3
|
import { ExpressMiddleware } from '../../types/express.mjs';
|
|
4
4
|
import { Statuses } from '../../utils/fns/statuses.mjs';
|
|
5
5
|
import { DeepPartial } from '../../types/utils.mjs';
|
|
@@ -8,8 +8,8 @@ import '../../types/http.mjs';
|
|
|
8
8
|
import 'https';
|
|
9
9
|
import 'http';
|
|
10
10
|
import 'spdy';
|
|
11
|
-
import 'express';
|
|
12
11
|
import 'node-fetch';
|
|
12
|
+
import 'express';
|
|
13
13
|
import '@homer0/path-utils';
|
|
14
14
|
import '@homer0/simple-logger';
|
|
15
15
|
import '@homer0/simple-config';
|
|
@@ -155,4 +155,4 @@ declare class EnsureBearerToken {
|
|
|
155
155
|
*/
|
|
156
156
|
declare const ensureBearerTokenProvider: _homer0_jimple.ResourceCreator<"provider", "register", (options?: EnsureBearerTokenProviderOptions) => (app: Jimpex) => void, _homer0_jimple.ProviderRegisterFn<Jimpex>>;
|
|
157
157
|
|
|
158
|
-
export { EnsureBearerConstructorOptions, EnsureBearerToken, EnsureBearerTokenErrorOptions, EnsureBearerTokenOptions, EnsureBearerTokenProviderOptions, ensureBearerTokenProvider };
|
|
158
|
+
export { type EnsureBearerConstructorOptions, EnsureBearerToken, type EnsureBearerTokenErrorOptions, type EnsureBearerTokenOptions, type EnsureBearerTokenProviderOptions, ensureBearerTokenProvider };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
-
import { J as Jimpex } from '../../index-
|
|
2
|
+
import { J as Jimpex } from '../../index-C6I3NCC-.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';
|
|
@@ -8,8 +8,8 @@ import '../../types/http.js';
|
|
|
8
8
|
import 'https';
|
|
9
9
|
import 'http';
|
|
10
10
|
import 'spdy';
|
|
11
|
-
import 'express';
|
|
12
11
|
import 'node-fetch';
|
|
12
|
+
import 'express';
|
|
13
13
|
import '@homer0/path-utils';
|
|
14
14
|
import '@homer0/simple-logger';
|
|
15
15
|
import '@homer0/simple-config';
|
|
@@ -155,4 +155,4 @@ declare class EnsureBearerToken {
|
|
|
155
155
|
*/
|
|
156
156
|
declare const ensureBearerTokenProvider: _homer0_jimple.ResourceCreator<"provider", "register", (options?: EnsureBearerTokenProviderOptions) => (app: Jimpex) => void, _homer0_jimple.ProviderRegisterFn<Jimpex>>;
|
|
157
157
|
|
|
158
|
-
export { EnsureBearerConstructorOptions, EnsureBearerToken, EnsureBearerTokenErrorOptions, EnsureBearerTokenOptions, EnsureBearerTokenProviderOptions, ensureBearerTokenProvider };
|
|
158
|
+
export { type EnsureBearerConstructorOptions, EnsureBearerToken, type EnsureBearerTokenErrorOptions, type EnsureBearerTokenOptions, type EnsureBearerTokenProviderOptions, ensureBearerTokenProvider };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
-
import { J as Jimpex } from '../../index-
|
|
2
|
+
import { J as Jimpex } from '../../index-Bwf7JHu9.mjs';
|
|
3
3
|
import { EnsureBearerTokenProviderOptions } from './ensureBearerToken.mjs';
|
|
4
4
|
export { EnsureBearerConstructorOptions, EnsureBearerToken, EnsureBearerTokenErrorOptions, EnsureBearerTokenOptions, ensureBearerTokenProvider } from './ensureBearerToken.mjs';
|
|
5
5
|
import '../../types/express.mjs';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _homer0_jimple from '@homer0/jimple';
|
|
2
|
-
import { J as Jimpex } from '../../index-
|
|
2
|
+
import { J as Jimpex } from '../../index-C6I3NCC-.js';
|
|
3
3
|
import { EnsureBearerTokenProviderOptions } from './ensureBearerToken.js';
|
|
4
4
|
export { EnsureBearerConstructorOptions, EnsureBearerToken, EnsureBearerTokenErrorOptions, EnsureBearerTokenOptions, ensureBearerTokenProvider } from './ensureBearerToken.js';
|
|
5
5
|
import '../../types/express.js';
|
package/dist/types/events.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
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-
|
|
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
3
|
import 'express';
|
|
4
4
|
import './http.mjs';
|
|
5
5
|
import 'https';
|
package/dist/types/events.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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 '../index-
|
|
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-C6I3NCC-.js';
|
|
3
3
|
import 'express';
|
|
4
4
|
import './http.js';
|
|
5
5
|
import 'https';
|
package/dist/types/express.d.mts
CHANGED
|
@@ -7,4 +7,4 @@ type AsyncExpressMiddleware = (...args: Parameters<ExpressMiddleware>) => Promis
|
|
|
7
7
|
type ExpressErrorHandler = ErrorRequestHandler;
|
|
8
8
|
type RouterMethod = 'all' | 'get' | 'head' | 'post' | 'patch' | 'put' | 'delete' | 'connect' | 'options' | 'trace';
|
|
9
9
|
|
|
10
|
-
export { AsyncExpressMiddleware, ExpressErrorHandler, ExpressMiddleware, ExpressMiddlewareLike, RouterMethod };
|
|
10
|
+
export type { AsyncExpressMiddleware, ExpressErrorHandler, ExpressMiddleware, ExpressMiddlewareLike, RouterMethod };
|
package/dist/types/express.d.ts
CHANGED
|
@@ -7,4 +7,4 @@ type AsyncExpressMiddleware = (...args: Parameters<ExpressMiddleware>) => Promis
|
|
|
7
7
|
type ExpressErrorHandler = ErrorRequestHandler;
|
|
8
8
|
type RouterMethod = 'all' | 'get' | 'head' | 'post' | 'patch' | 'put' | 'delete' | 'connect' | 'options' | 'trace';
|
|
9
9
|
|
|
10
|
-
export { AsyncExpressMiddleware, ExpressErrorHandler, ExpressMiddleware, ExpressMiddlewareLike, RouterMethod };
|
|
10
|
+
export type { AsyncExpressMiddleware, ExpressErrorHandler, ExpressMiddleware, ExpressMiddlewareLike, RouterMethod };
|
package/dist/types/http.d.mts
CHANGED
|
@@ -3,8 +3,11 @@ export { Server as HTTPSServer } from 'https';
|
|
|
3
3
|
import { Server as Server$1 } from 'http';
|
|
4
4
|
export { Server as HTTPServer } from 'http';
|
|
5
5
|
import { ServerOptions } from 'spdy';
|
|
6
|
-
import
|
|
6
|
+
import NodeFetchFn from 'node-fetch';
|
|
7
7
|
export { Response as HTTPResponse } from 'node-fetch';
|
|
8
|
+
import { Express } from 'express';
|
|
9
|
+
|
|
10
|
+
type NodeFetch = typeof NodeFetchFn;
|
|
8
11
|
|
|
9
12
|
/**
|
|
10
13
|
* @group Jimpex
|
|
@@ -76,4 +79,4 @@ type JimpexHTTPSOptions = {
|
|
|
76
79
|
};
|
|
77
80
|
};
|
|
78
81
|
|
|
79
|
-
export { JimpexHTTP2Options, JimpexHTTPSCredentials, JimpexHTTPSOptions, JimpexServer, JimpexServerInstance };
|
|
82
|
+
export type { JimpexHTTP2Options, JimpexHTTPSCredentials, JimpexHTTPSOptions, JimpexServer, JimpexServerInstance, NodeFetch };
|
package/dist/types/http.d.ts
CHANGED
|
@@ -3,8 +3,11 @@ export { Server as HTTPSServer } from 'https';
|
|
|
3
3
|
import { Server as Server$1 } from 'http';
|
|
4
4
|
export { Server as HTTPServer } from 'http';
|
|
5
5
|
import { ServerOptions } from 'spdy';
|
|
6
|
-
import
|
|
6
|
+
import NodeFetchFn from 'node-fetch';
|
|
7
7
|
export { Response as HTTPResponse } from 'node-fetch';
|
|
8
|
+
import { Express } from 'express';
|
|
9
|
+
|
|
10
|
+
type NodeFetch = typeof NodeFetchFn;
|
|
8
11
|
|
|
9
12
|
/**
|
|
10
13
|
* @group Jimpex
|
|
@@ -76,4 +79,4 @@ type JimpexHTTPSOptions = {
|
|
|
76
79
|
};
|
|
77
80
|
};
|
|
78
81
|
|
|
79
|
-
export { JimpexHTTP2Options, JimpexHTTPSCredentials, JimpexHTTPSOptions, JimpexServer, JimpexServerInstance };
|
|
82
|
+
export type { JimpexHTTP2Options, JimpexHTTPSCredentials, JimpexHTTPSOptions, JimpexServer, JimpexServerInstance, NodeFetch };
|
package/dist/types/http.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types/http.ts"],"sourcesContent":["import type { Server as HTTPSServer } from 'https';\nimport type { Server as HTTPServer } from 'http';\nimport type { ServerOptions as SpdyServerOptions } from 'spdy';\nimport type { Express } from './express';\n\nexport type { Response as HTTPResponse } from 'node-fetch';\n\nexport type { HTTPSServer, HTTPServer };\n/**\n * @group Jimpex\n */\nexport type JimpexServer = Express | HTTPSServer;\n/**\n * @group Jimpex\n */\nexport type JimpexServerInstance = HTTPServer | HTTPSServer;\n/**\n * The paths to the SSL credentials. Depending on the application options, they can be\n * relative to the project root, or the application executable, but they can't be\n * absolute.\n *\n * @group Jimpex\n */\nexport type JimpexHTTPSCredentials = {\n /**\n * The path to the certificate authority file.\n */\n ca?: string;\n /**\n * The path to the certificate file.\n */\n cert?: string;\n /**\n * The path to the key file.\n */\n key?: string;\n};\n/**\n * The options to enable HTTP2.\n *\n * @group Jimpex\n */\nexport type JimpexHTTP2Options = {\n /**\n * Whether or not to enable HTTP2.\n */\n enabled?: boolean;\n /**\n * Custom options for the Spdy server.\n *\n * @see {@link https://github.com/spdy-http2/node-spdy#options}\n */\n spdy?: SpdyServerOptions['spdy'];\n};\n/**\n * The options to enable HTTPS.\n *\n * @group Jimpex\n */\nexport type JimpexHTTPSOptions = {\n /**\n * Whether or not to enable HTTPS.\n */\n enabled?: boolean;\n /**\n * The SSL credentials, and their location.\n */\n credentials?: JimpexHTTPSCredentials & {\n /**\n * If `true`, the credentials will be located relative to the project root, otherwise,\n * they will be located relative to the application executable.\n *\n * @default false\n */\n onHome?: boolean;\n };\n};\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/types/http.ts"],"sourcesContent":["import type { Server as HTTPSServer } from 'https';\nimport type { Server as HTTPServer } from 'http';\nimport type { ServerOptions as SpdyServerOptions } from 'spdy';\nimport type NodeFetchFn from 'node-fetch';\nimport type { Express } from './express';\n\nexport type { Response as HTTPResponse } from 'node-fetch';\n\nexport type NodeFetch = typeof NodeFetchFn;\n\nexport type { HTTPSServer, HTTPServer };\n/**\n * @group Jimpex\n */\nexport type JimpexServer = Express | HTTPSServer;\n/**\n * @group Jimpex\n */\nexport type JimpexServerInstance = HTTPServer | HTTPSServer;\n/**\n * The paths to the SSL credentials. Depending on the application options, they can be\n * relative to the project root, or the application executable, but they can't be\n * absolute.\n *\n * @group Jimpex\n */\nexport type JimpexHTTPSCredentials = {\n /**\n * The path to the certificate authority file.\n */\n ca?: string;\n /**\n * The path to the certificate file.\n */\n cert?: string;\n /**\n * The path to the key file.\n */\n key?: string;\n};\n/**\n * The options to enable HTTP2.\n *\n * @group Jimpex\n */\nexport type JimpexHTTP2Options = {\n /**\n * Whether or not to enable HTTP2.\n */\n enabled?: boolean;\n /**\n * Custom options for the Spdy server.\n *\n * @see {@link https://github.com/spdy-http2/node-spdy#options}\n */\n spdy?: SpdyServerOptions['spdy'];\n};\n/**\n * The options to enable HTTPS.\n *\n * @group Jimpex\n */\nexport type JimpexHTTPSOptions = {\n /**\n * Whether or not to enable HTTPS.\n */\n enabled?: boolean;\n /**\n * The SSL credentials, and their location.\n */\n credentials?: JimpexHTTPSCredentials & {\n /**\n * If `true`, the credentials will be located relative to the project root, otherwise,\n * they will be located relative to the application executable.\n *\n * @default false\n */\n onHome?: boolean;\n };\n};\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
package/dist/types/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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-
|
|
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-Bwf7JHu9.mjs';
|
|
2
2
|
export { AsyncExpressMiddleware, ExpressErrorHandler, ExpressMiddleware, ExpressMiddlewareLike, RouterMethod } from './express.mjs';
|
|
3
|
-
export { JimpexHTTP2Options, JimpexHTTPSCredentials, JimpexHTTPSOptions, JimpexServer, JimpexServerInstance } from './http.mjs';
|
|
3
|
+
export { JimpexHTTP2Options, JimpexHTTPSCredentials, JimpexHTTPSOptions, JimpexServer, JimpexServerInstance, NodeFetch } from './http.mjs';
|
|
4
4
|
export { DeepPartial, DeepReadonly, Dict, NoStringIndex } from './utils.mjs';
|
|
5
5
|
export { PathUtils } from '@homer0/path-utils';
|
|
6
6
|
export { SimpleLogger as Logger } from '@homer0/simple-logger';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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-
|
|
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-C6I3NCC-.js';
|
|
2
2
|
export { AsyncExpressMiddleware, ExpressErrorHandler, ExpressMiddleware, ExpressMiddlewareLike, RouterMethod } from './express.js';
|
|
3
|
-
export { JimpexHTTP2Options, JimpexHTTPSCredentials, JimpexHTTPSOptions, JimpexServer, JimpexServerInstance } from './http.js';
|
|
3
|
+
export { JimpexHTTP2Options, JimpexHTTPSCredentials, JimpexHTTPSOptions, JimpexServer, JimpexServerInstance, NodeFetch } from './http.js';
|
|
4
4
|
export { DeepPartial, DeepReadonly, Dict, NoStringIndex } from './utils.js';
|
|
5
5
|
export { PathUtils } from '@homer0/path-utils';
|
|
6
6
|
export { SimpleLogger as Logger } from '@homer0/simple-logger';
|