@keq-request/nestjs 5.0.0-alpha.30 → 5.0.0-alpha.32
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/.turbo/turbo-build.log +7 -7
- package/CHANGELOG.md +14 -0
- package/dist/index.js +26 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -2
- package/dist/index.mjs.map +1 -1
- package/dist/keq.module-definition.d.ts +1 -1
- package/dist/keq.module-definition.d.ts.map +1 -1
- package/dist/keq.module.d.ts +44 -2
- package/dist/keq.module.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/keq.module-definition.ts +1 -1
- package/src/keq.module.ts +53 -4
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @keq-request/nestjs@5.0.0-alpha.
|
|
2
|
+
> @keq-request/nestjs@5.0.0-alpha.32 build /home/runner/work/keq/keq/packages/nestjs
|
|
3
3
|
> tsup
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
[34mCLI[39m Cleaning output folder
|
|
11
11
|
[34mCJS[39m Build start
|
|
12
12
|
[34mESM[39m Build start
|
|
13
|
-
[32mCJS[39m [1mdist/index.js [22m[
|
|
14
|
-
[32mCJS[39m [1mdist/index.js.map [22m[
|
|
15
|
-
[32mCJS[39m ⚡️ Build success in
|
|
16
|
-
[32mESM[39m [1mdist/index.mjs [22m[
|
|
17
|
-
[32mESM[39m [1mdist/index.mjs.map [22m[
|
|
18
|
-
[32mESM[39m ⚡️ Build success in
|
|
13
|
+
[32mCJS[39m [1mdist/index.js [22m[32m3.28 KB[39m
|
|
14
|
+
[32mCJS[39m [1mdist/index.js.map [22m[32m4.04 KB[39m
|
|
15
|
+
[32mCJS[39m ⚡️ Build success in 89ms
|
|
16
|
+
[32mESM[39m [1mdist/index.mjs [22m[32m2.27 KB[39m
|
|
17
|
+
[32mESM[39m [1mdist/index.mjs.map [22m[32m3.94 KB[39m
|
|
18
|
+
[32mESM[39m ⚡️ Build success in 96ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @keq-request/nestjs
|
|
2
2
|
|
|
3
|
+
## 5.0.0-alpha.32
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [f194c41]
|
|
8
|
+
- Updated dependencies [b8d02ca]
|
|
9
|
+
- keq@5.0.0-alpha.32
|
|
10
|
+
|
|
11
|
+
## 5.0.0-alpha.31
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- keq@5.0.0-alpha.31
|
|
16
|
+
|
|
3
17
|
## 5.0.0-alpha.30
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -27,12 +27,20 @@ module.exports = __toCommonJS(index_exports);
|
|
|
27
27
|
|
|
28
28
|
// src/keq.module.ts
|
|
29
29
|
var import_keq = require("keq");
|
|
30
|
+
var import_common2 = require("@nestjs/common");
|
|
30
31
|
|
|
31
32
|
// src/keq.module-definition.ts
|
|
32
33
|
var import_common = require("@nestjs/common");
|
|
33
|
-
var { ConfigurableModuleClass
|
|
34
|
+
var { ConfigurableModuleClass, MODULE_OPTIONS_TOKEN, OPTIONS_TYPE, ASYNC_OPTIONS_TYPE } = new import_common.ConfigurableModuleBuilder().build();
|
|
34
35
|
|
|
35
36
|
// src/keq.module.ts
|
|
37
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
38
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
39
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
40
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
41
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
42
|
+
}
|
|
43
|
+
__name(_ts_decorate, "_ts_decorate");
|
|
36
44
|
var requestProvider = {
|
|
37
45
|
provide: import_keq.KeqRequest,
|
|
38
46
|
useFactory: /* @__PURE__ */ __name((config) => {
|
|
@@ -48,21 +56,37 @@ var requestProvider = {
|
|
|
48
56
|
MODULE_OPTIONS_TOKEN
|
|
49
57
|
]
|
|
50
58
|
};
|
|
51
|
-
var KeqModule = class extends
|
|
59
|
+
var KeqModule = class extends ConfigurableModuleClass {
|
|
52
60
|
static {
|
|
53
61
|
__name(this, "KeqModule");
|
|
54
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Register the module with synchronous options
|
|
65
|
+
* @param options - Configuration options including middlewares
|
|
66
|
+
* @returns DynamicModule with KeqRequest provider
|
|
67
|
+
*/
|
|
55
68
|
static register(options) {
|
|
56
69
|
const mo = super.register(options);
|
|
57
70
|
mo.providers.push(requestProvider);
|
|
71
|
+
mo.global = true;
|
|
58
72
|
return mo;
|
|
59
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Register the module with asynchronous options
|
|
76
|
+
* Useful when you need to inject dependencies like ConfigService
|
|
77
|
+
* @param options - Async configuration options
|
|
78
|
+
* @returns DynamicModule with KeqRequest provider
|
|
79
|
+
*/
|
|
60
80
|
static registerAsync(options) {
|
|
61
81
|
const mo = super.registerAsync(options);
|
|
62
82
|
mo.providers.push(requestProvider);
|
|
83
|
+
mo.global = true;
|
|
63
84
|
return mo;
|
|
64
85
|
}
|
|
65
86
|
};
|
|
87
|
+
KeqModule = _ts_decorate([
|
|
88
|
+
(0, import_common2.Global)()
|
|
89
|
+
], KeqModule);
|
|
66
90
|
// Annotate the CommonJS export names for ESM import in node:
|
|
67
91
|
0 && (module.exports = {
|
|
68
92
|
KeqModule
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/keq.module.ts","../src/keq.module-definition.ts"],"sourcesContent":["export * from './keq.module.js'\nexport * from './types/index.js'\n","
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/keq.module.ts","../src/keq.module-definition.ts"],"sourcesContent":["export * from './keq.module.js'\nexport * from './types/index.js'\n","\nimport { KeqRequest } from 'keq'\nimport { DynamicModule, Global, Provider } from '@nestjs/common'\nimport { ASYNC_OPTIONS_TYPE, ConfigurableModuleClass, MODULE_OPTIONS_TOKEN, OPTIONS_TYPE } from './keq.module-definition.js'\nimport { KeqModuleOptions } from './types/index.js'\n\n\n/**\n * Provider that creates and configures a KeqRequest instance\n * Applies any middlewares defined in the module options\n */\nconst requestProvider: Provider = {\n provide: KeqRequest,\n useFactory: (config: KeqModuleOptions) => {\n const request = new KeqRequest()\n\n if (config.middlewares) {\n for (const middleware of config.middlewares) {\n request.use(middleware)\n }\n }\n\n return request\n },\n inject: [MODULE_OPTIONS_TOKEN],\n}\n\n/**\n * KeqModule - Dynamic module for integrating Keq HTTP client with NestJS\n *\n * This module is global, so KeqRequest can be injected anywhere in your application\n * without needing to import the module in every feature module.\n *\n * @example\n * ```typescript\n * // Synchronous registration\n * KeqModule.register({\n * middlewares: [...]\n * })\n *\n * // Asynchronous registration\n * KeqModule.registerAsync({\n * imports: [ConfigModule],\n * useFactory: (config: ConfigService) => ({\n * middlewares: [...]\n * }),\n * inject: [ConfigService]\n * })\n *\n * // Inject in service\n * class UserService {\n * constructor(private readonly keqRequest: KeqRequest) {}\n * async getUser(id: string) {\n * return await this.keqRequest.get(`/users/${id}`).resolveWith('json')\n * }\n * }\n * ```\n */\n@Global()\nexport class KeqModule extends ConfigurableModuleClass {\n /**\n * Register the module with synchronous options\n * @param options - Configuration options including middlewares\n * @returns DynamicModule with KeqRequest provider\n */\n static register(options: typeof OPTIONS_TYPE): DynamicModule {\n const mo = super.register(options)\n mo.providers!.push(requestProvider)\n mo.global = true\n\n return mo\n }\n\n /**\n * Register the module with asynchronous options\n * Useful when you need to inject dependencies like ConfigService\n * @param options - Async configuration options\n * @returns DynamicModule with KeqRequest provider\n */\n static registerAsync(options: typeof ASYNC_OPTIONS_TYPE): DynamicModule {\n const mo = super.registerAsync(options)\n mo.providers!.push(requestProvider)\n mo.global = true\n\n return mo\n }\n}\n","\nimport { ConfigurableModuleBuilder } from '@nestjs/common'\nimport { KeqModuleOptions } from './types/keq-module-options'\n\n\nexport const {\n ConfigurableModuleClass,\n MODULE_OPTIONS_TOKEN,\n OPTIONS_TYPE,\n ASYNC_OPTIONS_TYPE,\n} = new ConfigurableModuleBuilder<KeqModuleOptions>().build()\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;ACCA,iBAA2B;AAC3B,IAAAA,iBAAgD;;;ACDhD,oBAA0C;AAInC,IAAM,EACXC,yBACAC,sBACAC,cACAC,mBAAkB,IAChB,IAAIC,wCAAAA,EAA8CC,MAAK;;;;;;;;;;ADC3D,IAAMC,kBAA4B;EAChCC,SAASC;EACTC,YAAY,wBAACC,WAAAA;AACX,UAAMC,UAAU,IAAIH,sBAAAA;AAEpB,QAAIE,OAAOE,aAAa;AACtB,iBAAWC,cAAcH,OAAOE,aAAa;AAC3CD,gBAAQG,IAAID,UAAAA;MACd;IACF;AAEA,WAAOF;EACT,GAVY;EAWZI,QAAQ;IAACC;;AACX;AAkCO,IAAMC,YAAN,cAAwBC,wBAAAA;SAAAA;;;;;;;;EAM7B,OAAOC,SAASC,SAA6C;AAC3D,UAAMC,KAAK,MAAMF,SAASC,OAAAA;AAC1BC,OAAGC,UAAWC,KAAKjB,eAAAA;AACnBe,OAAGG,SAAS;AAEZ,WAAOH;EACT;;;;;;;EAQA,OAAOI,cAAcL,SAAmD;AACtE,UAAMC,KAAK,MAAMI,cAAcL,OAAAA;AAC/BC,OAAGC,UAAWC,KAAKjB,eAAAA;AACnBe,OAAGG,SAAS;AAEZ,WAAOH;EACT;AACF;AA3BaJ,YAAAA,aAAAA;MADZS,uBAAAA;GACYT,SAAAA;","names":["import_common","ConfigurableModuleClass","MODULE_OPTIONS_TOKEN","OPTIONS_TYPE","ASYNC_OPTIONS_TYPE","ConfigurableModuleBuilder","build","requestProvider","provide","KeqRequest","useFactory","config","request","middlewares","middleware","use","inject","MODULE_OPTIONS_TOKEN","KeqModule","ConfigurableModuleClass","register","options","mo","providers","push","global","registerAsync","Global"]}
|
package/dist/index.mjs
CHANGED
|
@@ -3,12 +3,20 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
|
|
|
3
3
|
|
|
4
4
|
// src/keq.module.ts
|
|
5
5
|
import { KeqRequest } from "keq";
|
|
6
|
+
import { Global } from "@nestjs/common";
|
|
6
7
|
|
|
7
8
|
// src/keq.module-definition.ts
|
|
8
9
|
import { ConfigurableModuleBuilder } from "@nestjs/common";
|
|
9
|
-
var { ConfigurableModuleClass
|
|
10
|
+
var { ConfigurableModuleClass, MODULE_OPTIONS_TOKEN, OPTIONS_TYPE, ASYNC_OPTIONS_TYPE } = new ConfigurableModuleBuilder().build();
|
|
10
11
|
|
|
11
12
|
// src/keq.module.ts
|
|
13
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
14
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
15
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
16
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
17
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
18
|
+
}
|
|
19
|
+
__name(_ts_decorate, "_ts_decorate");
|
|
12
20
|
var requestProvider = {
|
|
13
21
|
provide: KeqRequest,
|
|
14
22
|
useFactory: /* @__PURE__ */ __name((config) => {
|
|
@@ -24,21 +32,37 @@ var requestProvider = {
|
|
|
24
32
|
MODULE_OPTIONS_TOKEN
|
|
25
33
|
]
|
|
26
34
|
};
|
|
27
|
-
var KeqModule = class extends
|
|
35
|
+
var KeqModule = class extends ConfigurableModuleClass {
|
|
28
36
|
static {
|
|
29
37
|
__name(this, "KeqModule");
|
|
30
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Register the module with synchronous options
|
|
41
|
+
* @param options - Configuration options including middlewares
|
|
42
|
+
* @returns DynamicModule with KeqRequest provider
|
|
43
|
+
*/
|
|
31
44
|
static register(options) {
|
|
32
45
|
const mo = super.register(options);
|
|
33
46
|
mo.providers.push(requestProvider);
|
|
47
|
+
mo.global = true;
|
|
34
48
|
return mo;
|
|
35
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Register the module with asynchronous options
|
|
52
|
+
* Useful when you need to inject dependencies like ConfigService
|
|
53
|
+
* @param options - Async configuration options
|
|
54
|
+
* @returns DynamicModule with KeqRequest provider
|
|
55
|
+
*/
|
|
36
56
|
static registerAsync(options) {
|
|
37
57
|
const mo = super.registerAsync(options);
|
|
38
58
|
mo.providers.push(requestProvider);
|
|
59
|
+
mo.global = true;
|
|
39
60
|
return mo;
|
|
40
61
|
}
|
|
41
62
|
};
|
|
63
|
+
KeqModule = _ts_decorate([
|
|
64
|
+
Global()
|
|
65
|
+
], KeqModule);
|
|
42
66
|
export {
|
|
43
67
|
KeqModule
|
|
44
68
|
};
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/keq.module.ts","../src/keq.module-definition.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../src/keq.module.ts","../src/keq.module-definition.ts"],"sourcesContent":["\nimport { KeqRequest } from 'keq'\nimport { DynamicModule, Global, Provider } from '@nestjs/common'\nimport { ASYNC_OPTIONS_TYPE, ConfigurableModuleClass, MODULE_OPTIONS_TOKEN, OPTIONS_TYPE } from './keq.module-definition.js'\nimport { KeqModuleOptions } from './types/index.js'\n\n\n/**\n * Provider that creates and configures a KeqRequest instance\n * Applies any middlewares defined in the module options\n */\nconst requestProvider: Provider = {\n provide: KeqRequest,\n useFactory: (config: KeqModuleOptions) => {\n const request = new KeqRequest()\n\n if (config.middlewares) {\n for (const middleware of config.middlewares) {\n request.use(middleware)\n }\n }\n\n return request\n },\n inject: [MODULE_OPTIONS_TOKEN],\n}\n\n/**\n * KeqModule - Dynamic module for integrating Keq HTTP client with NestJS\n *\n * This module is global, so KeqRequest can be injected anywhere in your application\n * without needing to import the module in every feature module.\n *\n * @example\n * ```typescript\n * // Synchronous registration\n * KeqModule.register({\n * middlewares: [...]\n * })\n *\n * // Asynchronous registration\n * KeqModule.registerAsync({\n * imports: [ConfigModule],\n * useFactory: (config: ConfigService) => ({\n * middlewares: [...]\n * }),\n * inject: [ConfigService]\n * })\n *\n * // Inject in service\n * class UserService {\n * constructor(private readonly keqRequest: KeqRequest) {}\n * async getUser(id: string) {\n * return await this.keqRequest.get(`/users/${id}`).resolveWith('json')\n * }\n * }\n * ```\n */\n@Global()\nexport class KeqModule extends ConfigurableModuleClass {\n /**\n * Register the module with synchronous options\n * @param options - Configuration options including middlewares\n * @returns DynamicModule with KeqRequest provider\n */\n static register(options: typeof OPTIONS_TYPE): DynamicModule {\n const mo = super.register(options)\n mo.providers!.push(requestProvider)\n mo.global = true\n\n return mo\n }\n\n /**\n * Register the module with asynchronous options\n * Useful when you need to inject dependencies like ConfigService\n * @param options - Async configuration options\n * @returns DynamicModule with KeqRequest provider\n */\n static registerAsync(options: typeof ASYNC_OPTIONS_TYPE): DynamicModule {\n const mo = super.registerAsync(options)\n mo.providers!.push(requestProvider)\n mo.global = true\n\n return mo\n }\n}\n","\nimport { ConfigurableModuleBuilder } from '@nestjs/common'\nimport { KeqModuleOptions } from './types/keq-module-options'\n\n\nexport const {\n ConfigurableModuleClass,\n MODULE_OPTIONS_TOKEN,\n OPTIONS_TYPE,\n ASYNC_OPTIONS_TYPE,\n} = new ConfigurableModuleBuilder<KeqModuleOptions>().build()\n"],"mappings":";;;;AACA,SAASA,kBAAkB;AAC3B,SAAwBC,cAAwB;;;ACDhD,SAASC,iCAAiC;AAInC,IAAM,EACXC,yBACAC,sBACAC,cACAC,mBAAkB,IAChB,IAAIJ,0BAAAA,EAA8CK,MAAK;;;;;;;;;;ADC3D,IAAMC,kBAA4B;EAChCC,SAASC;EACTC,YAAY,wBAACC,WAAAA;AACX,UAAMC,UAAU,IAAIH,WAAAA;AAEpB,QAAIE,OAAOE,aAAa;AACtB,iBAAWC,cAAcH,OAAOE,aAAa;AAC3CD,gBAAQG,IAAID,UAAAA;MACd;IACF;AAEA,WAAOF;EACT,GAVY;EAWZI,QAAQ;IAACC;;AACX;AAkCO,IAAMC,YAAN,cAAwBC,wBAAAA;SAAAA;;;;;;;;EAM7B,OAAOC,SAASC,SAA6C;AAC3D,UAAMC,KAAK,MAAMF,SAASC,OAAAA;AAC1BC,OAAGC,UAAWC,KAAKjB,eAAAA;AACnBe,OAAGG,SAAS;AAEZ,WAAOH;EACT;;;;;;;EAQA,OAAOI,cAAcL,SAAmD;AACtE,UAAMC,KAAK,MAAMI,cAAcL,OAAAA;AAC/BC,OAAGC,UAAWC,KAAKjB,eAAAA;AACnBe,OAAGG,SAAS;AAEZ,WAAOH;EACT;AACF;AA3BaJ,YAAAA,aAAAA;EADZS,OAAAA;GACYT,SAAAA;","names":["KeqRequest","Global","ConfigurableModuleBuilder","ConfigurableModuleClass","MODULE_OPTIONS_TOKEN","OPTIONS_TYPE","ASYNC_OPTIONS_TYPE","build","requestProvider","provide","KeqRequest","useFactory","config","request","middlewares","middleware","use","inject","MODULE_OPTIONS_TOKEN","KeqModule","ConfigurableModuleClass","register","options","mo","providers","push","global","registerAsync","Global"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { KeqModuleOptions } from './types/keq-module-options';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const ConfigurableModuleClass: import("@nestjs/common").ConfigurableModuleCls<KeqModuleOptions, "register", "create", {}>, MODULE_OPTIONS_TOKEN: string | symbol, OPTIONS_TYPE: KeqModuleOptions & Partial<{}>, ASYNC_OPTIONS_TYPE: import("@nestjs/common").ConfigurableModuleAsyncOptions<KeqModuleOptions, "create"> & Partial<{}>;
|
|
3
3
|
//# sourceMappingURL=keq.module-definition.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keq.module-definition.d.ts","sourceRoot":"","sources":["../src/keq.module-definition.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAG7D,eAAO,
|
|
1
|
+
{"version":3,"file":"keq.module-definition.d.ts","sourceRoot":"","sources":["../src/keq.module-definition.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAG7D,eAAO,MACL,uBAAuB,8FACvB,oBAAoB,mBACpB,YAAY,kCACZ,kBAAkB,mGACyC,CAAA"}
|
package/dist/keq.module.d.ts
CHANGED
|
@@ -1,7 +1,49 @@
|
|
|
1
1
|
import { DynamicModule } from '@nestjs/common';
|
|
2
|
-
import { ASYNC_OPTIONS_TYPE,
|
|
3
|
-
|
|
2
|
+
import { ASYNC_OPTIONS_TYPE, ConfigurableModuleClass, OPTIONS_TYPE } from './keq.module-definition.js';
|
|
3
|
+
/**
|
|
4
|
+
* KeqModule - Dynamic module for integrating Keq HTTP client with NestJS
|
|
5
|
+
*
|
|
6
|
+
* This module is global, so KeqRequest can be injected anywhere in your application
|
|
7
|
+
* without needing to import the module in every feature module.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* // Synchronous registration
|
|
12
|
+
* KeqModule.register({
|
|
13
|
+
* middlewares: [...]
|
|
14
|
+
* })
|
|
15
|
+
*
|
|
16
|
+
* // Asynchronous registration
|
|
17
|
+
* KeqModule.registerAsync({
|
|
18
|
+
* imports: [ConfigModule],
|
|
19
|
+
* useFactory: (config: ConfigService) => ({
|
|
20
|
+
* middlewares: [...]
|
|
21
|
+
* }),
|
|
22
|
+
* inject: [ConfigService]
|
|
23
|
+
* })
|
|
24
|
+
*
|
|
25
|
+
* // Inject in service
|
|
26
|
+
* class UserService {
|
|
27
|
+
* constructor(private readonly keqRequest: KeqRequest) {}
|
|
28
|
+
* async getUser(id: string) {
|
|
29
|
+
* return await this.keqRequest.get(`/users/${id}`).resolveWith('json')
|
|
30
|
+
* }
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare class KeqModule extends ConfigurableModuleClass {
|
|
35
|
+
/**
|
|
36
|
+
* Register the module with synchronous options
|
|
37
|
+
* @param options - Configuration options including middlewares
|
|
38
|
+
* @returns DynamicModule with KeqRequest provider
|
|
39
|
+
*/
|
|
4
40
|
static register(options: typeof OPTIONS_TYPE): DynamicModule;
|
|
41
|
+
/**
|
|
42
|
+
* Register the module with asynchronous options
|
|
43
|
+
* Useful when you need to inject dependencies like ConfigService
|
|
44
|
+
* @param options - Async configuration options
|
|
45
|
+
* @returns DynamicModule with KeqRequest provider
|
|
46
|
+
*/
|
|
5
47
|
static registerAsync(options: typeof ASYNC_OPTIONS_TYPE): DynamicModule;
|
|
6
48
|
}
|
|
7
49
|
//# sourceMappingURL=keq.module.d.ts.map
|
package/dist/keq.module.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keq.module.d.ts","sourceRoot":"","sources":["../src/keq.module.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"keq.module.d.ts","sourceRoot":"","sources":["../src/keq.module.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAoB,MAAM,gBAAgB,CAAA;AAChE,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAwB,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAwB5H;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBACa,SAAU,SAAQ,uBAAuB;IACpD;;;;OAIG;IACH,MAAM,CAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,YAAY,GAAG,aAAa;IAQ5D;;;;;OAKG;IACH,MAAM,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,kBAAkB,GAAG,aAAa;CAOxE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keq-request/nestjs",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.32",
|
|
4
4
|
"description": "Request API write by Typescript for flexibility, readability, and a low learning curve.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"request",
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/node": "^20.19.25",
|
|
39
39
|
"@nestjs/common": "^11.0.0",
|
|
40
|
-
"keq": "5.0.0-alpha.
|
|
40
|
+
"keq": "5.0.0-alpha.32"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"keq": "^5.0.0-alpha.
|
|
43
|
+
"keq": "^5.0.0-alpha.32",
|
|
44
44
|
"@nestjs/common": "^11.0.0"
|
|
45
45
|
},
|
|
46
46
|
"engines": {
|
package/src/keq.module.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
import { KeqRequest } from 'keq'
|
|
3
|
-
import { DynamicModule, Provider } from '@nestjs/common'
|
|
4
|
-
import { ASYNC_OPTIONS_TYPE,
|
|
3
|
+
import { DynamicModule, Global, Provider } from '@nestjs/common'
|
|
4
|
+
import { ASYNC_OPTIONS_TYPE, ConfigurableModuleClass, MODULE_OPTIONS_TOKEN, OPTIONS_TYPE } from './keq.module-definition.js'
|
|
5
5
|
import { KeqModuleOptions } from './types/index.js'
|
|
6
6
|
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Provider that creates and configures a KeqRequest instance
|
|
10
|
+
* Applies any middlewares defined in the module options
|
|
11
|
+
*/
|
|
8
12
|
const requestProvider: Provider = {
|
|
9
13
|
provide: KeqRequest,
|
|
10
14
|
useFactory: (config: KeqModuleOptions) => {
|
|
@@ -21,17 +25,62 @@ const requestProvider: Provider = {
|
|
|
21
25
|
inject: [MODULE_OPTIONS_TOKEN],
|
|
22
26
|
}
|
|
23
27
|
|
|
24
|
-
|
|
28
|
+
/**
|
|
29
|
+
* KeqModule - Dynamic module for integrating Keq HTTP client with NestJS
|
|
30
|
+
*
|
|
31
|
+
* This module is global, so KeqRequest can be injected anywhere in your application
|
|
32
|
+
* without needing to import the module in every feature module.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* // Synchronous registration
|
|
37
|
+
* KeqModule.register({
|
|
38
|
+
* middlewares: [...]
|
|
39
|
+
* })
|
|
40
|
+
*
|
|
41
|
+
* // Asynchronous registration
|
|
42
|
+
* KeqModule.registerAsync({
|
|
43
|
+
* imports: [ConfigModule],
|
|
44
|
+
* useFactory: (config: ConfigService) => ({
|
|
45
|
+
* middlewares: [...]
|
|
46
|
+
* }),
|
|
47
|
+
* inject: [ConfigService]
|
|
48
|
+
* })
|
|
49
|
+
*
|
|
50
|
+
* // Inject in service
|
|
51
|
+
* class UserService {
|
|
52
|
+
* constructor(private readonly keqRequest: KeqRequest) {}
|
|
53
|
+
* async getUser(id: string) {
|
|
54
|
+
* return await this.keqRequest.get(`/users/${id}`).resolveWith('json')
|
|
55
|
+
* }
|
|
56
|
+
* }
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
@Global()
|
|
60
|
+
export class KeqModule extends ConfigurableModuleClass {
|
|
61
|
+
/**
|
|
62
|
+
* Register the module with synchronous options
|
|
63
|
+
* @param options - Configuration options including middlewares
|
|
64
|
+
* @returns DynamicModule with KeqRequest provider
|
|
65
|
+
*/
|
|
25
66
|
static register(options: typeof OPTIONS_TYPE): DynamicModule {
|
|
26
67
|
const mo = super.register(options)
|
|
27
68
|
mo.providers!.push(requestProvider)
|
|
69
|
+
mo.global = true
|
|
28
70
|
|
|
29
71
|
return mo
|
|
30
72
|
}
|
|
31
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Register the module with asynchronous options
|
|
76
|
+
* Useful when you need to inject dependencies like ConfigService
|
|
77
|
+
* @param options - Async configuration options
|
|
78
|
+
* @returns DynamicModule with KeqRequest provider
|
|
79
|
+
*/
|
|
32
80
|
static registerAsync(options: typeof ASYNC_OPTIONS_TYPE): DynamicModule {
|
|
33
81
|
const mo = super.registerAsync(options)
|
|
34
82
|
mo.providers!.push(requestProvider)
|
|
83
|
+
mo.global = true
|
|
35
84
|
|
|
36
85
|
return mo
|
|
37
86
|
}
|