@nattyjs/core 0.0.1-beta.10 → 0.0.1-beta.11
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/dist/index.cjs +19 -9
- package/dist/index.d.ts +65 -59
- package/dist/index.mjs +19 -10
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -60,10 +60,13 @@ const nattyContainer = new class {
|
|
|
60
60
|
this.container = /* @__PURE__ */ new Map();
|
|
61
61
|
this.containerState = /* @__PURE__ */ new Map();
|
|
62
62
|
}
|
|
63
|
-
|
|
63
|
+
get types() {
|
|
64
|
+
return common.commonContainer.types;
|
|
65
|
+
}
|
|
66
|
+
setup(config, routes, resolver) {
|
|
64
67
|
this.config = config;
|
|
65
68
|
this.routes = routes;
|
|
66
|
-
this.
|
|
69
|
+
this.resolver = resolver;
|
|
67
70
|
}
|
|
68
71
|
getTypes() {
|
|
69
72
|
return StaticContainer.types;
|
|
@@ -116,7 +119,7 @@ const nattyContainer = new class {
|
|
|
116
119
|
function init(config, appConfig) {
|
|
117
120
|
common.commonContainer.setupConfig(config);
|
|
118
121
|
common.commonContainer.setEnvTsDefinition(appConfig.envTsDefinition);
|
|
119
|
-
nattyContainer.setup(config, appConfig.routes, appConfig.
|
|
122
|
+
nattyContainer.setup(config, appConfig.routes, appConfig.resolver);
|
|
120
123
|
return initializeModule(config);
|
|
121
124
|
}
|
|
122
125
|
function initializeModule(config) {
|
|
@@ -557,7 +560,7 @@ class ParameterTypeConverter extends BaseResponse {
|
|
|
557
560
|
}
|
|
558
561
|
convertToInstance(entityName, data) {
|
|
559
562
|
const typesInfo = this.types[entityName];
|
|
560
|
-
const target = this.getClassTarget(typesInfo.path) || entityContainer.getTarget(entityName);
|
|
563
|
+
const target = this.getClassTarget(typesInfo.path, entityName) || entityContainer.getTarget(entityName);
|
|
561
564
|
let instance = null;
|
|
562
565
|
if (target) {
|
|
563
566
|
instance = new target();
|
|
@@ -566,11 +569,10 @@ class ParameterTypeConverter extends BaseResponse {
|
|
|
566
569
|
instance = data;
|
|
567
570
|
return instance;
|
|
568
571
|
}
|
|
569
|
-
getClassTarget(
|
|
570
|
-
if (
|
|
571
|
-
const classInfo = resolver();
|
|
572
|
-
|
|
573
|
-
return classInfo[name];
|
|
572
|
+
getClassTarget(path, entityName) {
|
|
573
|
+
if (path) {
|
|
574
|
+
const classInfo = nattyContainer.resolver(path);
|
|
575
|
+
return classInfo[entityName];
|
|
574
576
|
}
|
|
575
577
|
return void 0;
|
|
576
578
|
}
|
|
@@ -1231,6 +1233,13 @@ function authenticationOnly() {
|
|
|
1231
1233
|
};
|
|
1232
1234
|
}
|
|
1233
1235
|
|
|
1236
|
+
function setEnvInfo(envTsDefinition, envValueInfo) {
|
|
1237
|
+
if (envTsDefinition && envValueInfo) {
|
|
1238
|
+
common.commonContainer.setEnvTsDefinition(envTsDefinition);
|
|
1239
|
+
Object.keys(envValueInfo).forEach((key) => process.env[key] = envValueInfo[key]);
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1234
1243
|
exports.$request = $request;
|
|
1235
1244
|
exports.AbstractModelState = AbstractModelState;
|
|
1236
1245
|
exports.BadRequestResult = BadRequestResult;
|
|
@@ -1269,4 +1278,5 @@ exports.post = post;
|
|
|
1269
1278
|
exports.put = put;
|
|
1270
1279
|
exports.registerDecorator = registerDecorator;
|
|
1271
1280
|
exports.route = route;
|
|
1281
|
+
exports.setEnvInfo = setEnvInfo;
|
|
1272
1282
|
exports.useFilter = useFilter;
|
package/dist/index.d.ts
CHANGED
|
@@ -59,6 +59,64 @@ declare function put(path: string): (target: any, propertyKey?: string, descript
|
|
|
59
59
|
|
|
60
60
|
declare function Delete(): (target: any, propertyKey?: string, descriptor?: any) => void;
|
|
61
61
|
|
|
62
|
+
interface RouteConfig {
|
|
63
|
+
controller: Function;
|
|
64
|
+
parameters: Array<{
|
|
65
|
+
name: string;
|
|
66
|
+
type: string;
|
|
67
|
+
}>;
|
|
68
|
+
get: {
|
|
69
|
+
[key: string]: {
|
|
70
|
+
name: string;
|
|
71
|
+
parameters: Array<{
|
|
72
|
+
name: string;
|
|
73
|
+
type: string;
|
|
74
|
+
}>;
|
|
75
|
+
returnType: string;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
post: {
|
|
79
|
+
[key: string]: {
|
|
80
|
+
name: string;
|
|
81
|
+
parameters: Array<{
|
|
82
|
+
name: string;
|
|
83
|
+
type: string;
|
|
84
|
+
}>;
|
|
85
|
+
returnType: string;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
put: {
|
|
89
|
+
[key: string]: {
|
|
90
|
+
name: string;
|
|
91
|
+
parameters: Array<{
|
|
92
|
+
name: string;
|
|
93
|
+
type: string;
|
|
94
|
+
}>;
|
|
95
|
+
returnType: string;
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
delete: {
|
|
99
|
+
[key: string]: {
|
|
100
|
+
name: string;
|
|
101
|
+
parameters: Array<{
|
|
102
|
+
name: string;
|
|
103
|
+
type: string;
|
|
104
|
+
}>;
|
|
105
|
+
returnType: string;
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
declare function init(config: NattyConfig, appConfig: {
|
|
111
|
+
routes: {
|
|
112
|
+
[key: string]: RouteConfig;
|
|
113
|
+
};
|
|
114
|
+
envTsDefinition: {
|
|
115
|
+
[key: string]: string;
|
|
116
|
+
};
|
|
117
|
+
resolver: (path: string) => {};
|
|
118
|
+
}): any;
|
|
119
|
+
|
|
62
120
|
interface DecoratorInfo {
|
|
63
121
|
httpMethod: string;
|
|
64
122
|
route: string;
|
|
@@ -190,64 +248,6 @@ interface IHttpResult {
|
|
|
190
248
|
getResponse(): HttpResponseInit;
|
|
191
249
|
}
|
|
192
250
|
|
|
193
|
-
interface RouteConfig {
|
|
194
|
-
controller: Function;
|
|
195
|
-
parameters: Array<{
|
|
196
|
-
name: string;
|
|
197
|
-
type: string;
|
|
198
|
-
}>;
|
|
199
|
-
get: {
|
|
200
|
-
[key: string]: {
|
|
201
|
-
name: string;
|
|
202
|
-
parameters: Array<{
|
|
203
|
-
name: string;
|
|
204
|
-
type: string;
|
|
205
|
-
}>;
|
|
206
|
-
returnType: string;
|
|
207
|
-
};
|
|
208
|
-
};
|
|
209
|
-
post: {
|
|
210
|
-
[key: string]: {
|
|
211
|
-
name: string;
|
|
212
|
-
parameters: Array<{
|
|
213
|
-
name: string;
|
|
214
|
-
type: string;
|
|
215
|
-
}>;
|
|
216
|
-
returnType: string;
|
|
217
|
-
};
|
|
218
|
-
};
|
|
219
|
-
put: {
|
|
220
|
-
[key: string]: {
|
|
221
|
-
name: string;
|
|
222
|
-
parameters: Array<{
|
|
223
|
-
name: string;
|
|
224
|
-
type: string;
|
|
225
|
-
}>;
|
|
226
|
-
returnType: string;
|
|
227
|
-
};
|
|
228
|
-
};
|
|
229
|
-
delete: {
|
|
230
|
-
[key: string]: {
|
|
231
|
-
name: string;
|
|
232
|
-
parameters: Array<{
|
|
233
|
-
name: string;
|
|
234
|
-
type: string;
|
|
235
|
-
}>;
|
|
236
|
-
returnType: string;
|
|
237
|
-
};
|
|
238
|
-
};
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
declare function init(config: NattyConfig, appConfig: {
|
|
242
|
-
routes: {
|
|
243
|
-
[key: string]: RouteConfig;
|
|
244
|
-
};
|
|
245
|
-
envTsDefinition: {
|
|
246
|
-
[key: string]: string;
|
|
247
|
-
};
|
|
248
|
-
types?: TypesInfo;
|
|
249
|
-
}): any;
|
|
250
|
-
|
|
251
251
|
declare class HttpRequest {
|
|
252
252
|
private httpRequest;
|
|
253
253
|
constructor(http: HttpRequestInit);
|
|
@@ -463,4 +463,10 @@ declare function anonymous(): (target: any, propertyKey?: string, descriptor?: a
|
|
|
463
463
|
|
|
464
464
|
declare function authenticationOnly(): (target: any, propertyKey?: string, descriptor?: any) => void;
|
|
465
465
|
|
|
466
|
-
|
|
466
|
+
declare function setEnvInfo(envTsDefinition: {
|
|
467
|
+
[key: string]: string;
|
|
468
|
+
}, envValueInfo: {
|
|
469
|
+
[key: string]: any;
|
|
470
|
+
}): void;
|
|
471
|
+
|
|
472
|
+
export { $request, AbstractModelState, BadRequestResult, BaseController, BuildOptions, ClassTypeInfo, CreatedResult, Delete, ForbiddenAccessException, ForbiddenAccessInfoResult, HttpBadRequestException, HttpContext, HttpException, HttpHandler, HttpModule, HttpNotFoundException, HttpResponse, MethodInfo$1 as MethodInfo, ModelBindingContext, NoContentResult, NotFoundResult, OkResult, ParameterInfo, RunOn, TypeInfo$1 as TypeInfo, UnauthorizedAccessException, anonymous, authenticationOnly, badRequest, created, defineNattyConfig, entityContainer, filter, forbiddenAccessInfo, get, init, injectable, noContent, notFound, ok, post, put, registerDecorator, route, setEnvInfo, useFilter };
|
package/dist/index.mjs
CHANGED
|
@@ -58,10 +58,13 @@ const nattyContainer = new class {
|
|
|
58
58
|
this.container = /* @__PURE__ */ new Map();
|
|
59
59
|
this.containerState = /* @__PURE__ */ new Map();
|
|
60
60
|
}
|
|
61
|
-
|
|
61
|
+
get types() {
|
|
62
|
+
return commonContainer.types;
|
|
63
|
+
}
|
|
64
|
+
setup(config, routes, resolver) {
|
|
62
65
|
this.config = config;
|
|
63
66
|
this.routes = routes;
|
|
64
|
-
this.
|
|
67
|
+
this.resolver = resolver;
|
|
65
68
|
}
|
|
66
69
|
getTypes() {
|
|
67
70
|
return StaticContainer.types;
|
|
@@ -114,7 +117,7 @@ const nattyContainer = new class {
|
|
|
114
117
|
function init(config, appConfig) {
|
|
115
118
|
commonContainer.setupConfig(config);
|
|
116
119
|
commonContainer.setEnvTsDefinition(appConfig.envTsDefinition);
|
|
117
|
-
nattyContainer.setup(config, appConfig.routes, appConfig.
|
|
120
|
+
nattyContainer.setup(config, appConfig.routes, appConfig.resolver);
|
|
118
121
|
return initializeModule(config);
|
|
119
122
|
}
|
|
120
123
|
function initializeModule(config) {
|
|
@@ -555,7 +558,7 @@ class ParameterTypeConverter extends BaseResponse {
|
|
|
555
558
|
}
|
|
556
559
|
convertToInstance(entityName, data) {
|
|
557
560
|
const typesInfo = this.types[entityName];
|
|
558
|
-
const target = this.getClassTarget(typesInfo.path) || entityContainer.getTarget(entityName);
|
|
561
|
+
const target = this.getClassTarget(typesInfo.path, entityName) || entityContainer.getTarget(entityName);
|
|
559
562
|
let instance = null;
|
|
560
563
|
if (target) {
|
|
561
564
|
instance = new target();
|
|
@@ -564,11 +567,10 @@ class ParameterTypeConverter extends BaseResponse {
|
|
|
564
567
|
instance = data;
|
|
565
568
|
return instance;
|
|
566
569
|
}
|
|
567
|
-
getClassTarget(
|
|
568
|
-
if (
|
|
569
|
-
const classInfo = resolver();
|
|
570
|
-
|
|
571
|
-
return classInfo[name];
|
|
570
|
+
getClassTarget(path, entityName) {
|
|
571
|
+
if (path) {
|
|
572
|
+
const classInfo = nattyContainer.resolver(path);
|
|
573
|
+
return classInfo[entityName];
|
|
572
574
|
}
|
|
573
575
|
return void 0;
|
|
574
576
|
}
|
|
@@ -1229,4 +1231,11 @@ function authenticationOnly() {
|
|
|
1229
1231
|
};
|
|
1230
1232
|
}
|
|
1231
1233
|
|
|
1232
|
-
|
|
1234
|
+
function setEnvInfo(envTsDefinition, envValueInfo) {
|
|
1235
|
+
if (envTsDefinition && envValueInfo) {
|
|
1236
|
+
commonContainer.setEnvTsDefinition(envTsDefinition);
|
|
1237
|
+
Object.keys(envValueInfo).forEach((key) => process.env[key] = envValueInfo[key]);
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
export { $request, AbstractModelState, BadRequestResult, BaseController, CreatedResult, Delete, ForbiddenAccessException, ForbiddenAccessInfoResult, HttpBadRequestException, HttpContext, HttpException, HttpHandler, HttpNotFoundException, HttpResponse, ModelBindingContext, NoContentResult, NotFoundResult, OkResult, RunOn, UnauthorizedAccessException, anonymous, authenticationOnly, badRequest, created, defineNattyConfig, entityContainer, filter, forbiddenAccessInfo, get, init, injectable, noContent, notFound, ok, post, put, registerDecorator, route, setEnvInfo, useFilter };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nattyjs/core",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.11",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "ajayojha",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"tsyringe": "^4.7.0",
|
|
19
19
|
"path-to-regexp": "6.2.1",
|
|
20
|
-
"@nattyjs/common": "0.0.1-beta.
|
|
20
|
+
"@nattyjs/common": "0.0.1-beta.11"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"unbuild": "1.2.1"
|