@adaptivestone/framework 5.0.0-beta.45 → 5.0.0-beta.47
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 +22 -0
- package/dist/codegen/appTypes.d.ts +19 -0
- package/dist/codegen/appTypes.js +49 -0
- package/dist/codegen/appTypes.js.map +1 -0
- package/dist/codegen/collectMetadata.d.ts +37 -0
- package/dist/codegen/collectMetadata.js +51 -0
- package/dist/codegen/collectMetadata.js.map +1 -0
- package/dist/codegen/emit.d.ts +29 -0
- package/dist/codegen/emit.js +214 -0
- package/dist/codegen/emit.js.map +1 -0
- package/dist/codegen/index.d.ts +16 -0
- package/dist/codegen/index.js +18 -0
- package/dist/codegen/index.js.map +1 -0
- package/dist/codegen/routeTypes.d.ts +13 -0
- package/dist/codegen/routeTypes.js +126 -0
- package/dist/codegen/routeTypes.js.map +1 -0
- package/dist/commands/GenerateTypes.d.ts +0 -4
- package/dist/commands/GenerateTypes.js +4 -42
- package/dist/commands/GenerateTypes.js.map +1 -1
- package/dist/controllers/Auth.d.ts +15 -124
- package/dist/controllers/Auth.js.map +1 -1
- package/dist/controllers/Auth.routes.gen.d.ts +57 -0
- package/dist/controllers/Auth.routes.gen.js +10 -0
- package/dist/controllers/Auth.routes.gen.js.map +1 -0
- package/dist/controllers/Home.routes.gen.d.ts +14 -0
- package/dist/controllers/Home.routes.gen.js +10 -0
- package/dist/controllers/Home.routes.gen.js.map +1 -0
- package/dist/controllers/index.d.ts +23 -3
- package/dist/controllers/index.js +355 -8
- package/dist/controllers/index.js.map +1 -1
- package/dist/helpers/files.js +2 -0
- package/dist/helpers/files.js.map +1 -1
- package/dist/models/Sequence.js +1 -1
- package/dist/models/Sequence.js.map +1 -1
- package/dist/models/User.d.ts +28 -28
- package/dist/models/UserOld.d.ts +16 -6
- package/dist/modules/AbstractController.d.ts +7 -29
- package/dist/modules/AbstractController.js +1 -253
- package/dist/modules/AbstractController.js.map +1 -1
- package/dist/server.d.ts +0 -1
- package/dist/server.js +11 -1
- package/dist/server.js.map +1 -1
- package/dist/services/http/HttpServer.d.ts +9 -0
- package/dist/services/http/HttpServer.js +20 -9
- package/dist/services/http/HttpServer.js.map +1 -1
- package/dist/services/http/middleware/AbstractMiddleware.d.ts +19 -4
- package/dist/services/http/middleware/AbstractMiddleware.js +16 -5
- package/dist/services/http/middleware/AbstractMiddleware.js.map +1 -1
- package/dist/services/http/middleware/GetUserByToken.d.ts +9 -0
- package/dist/services/http/middleware/GetUserByToken.js +9 -0
- package/dist/services/http/middleware/GetUserByToken.js.map +1 -1
- package/dist/services/http/routing/ExpressAdapter.d.ts +12 -0
- package/dist/services/http/routing/ExpressAdapter.js +93 -0
- package/dist/services/http/routing/ExpressAdapter.js.map +1 -0
- package/dist/services/http/routing/RouteNode.d.ts +99 -0
- package/dist/services/http/routing/RouteNode.js +21 -0
- package/dist/services/http/routing/RouteNode.js.map +1 -0
- package/dist/services/http/routing/RouteRegistry.d.ts +37 -0
- package/dist/services/http/routing/RouteRegistry.js +207 -0
- package/dist/services/http/routing/RouteRegistry.js.map +1 -0
- package/dist/services/http/routing/formatTree.d.ts +23 -0
- package/dist/services/http/routing/formatTree.js +158 -0
- package/dist/services/http/routing/formatTree.js.map +1 -0
- package/dist/services/http/routing/match.d.ts +30 -0
- package/dist/services/http/routing/match.js +128 -0
- package/dist/services/http/routing/match.js.map +1 -0
- package/dist/services/http/routing/middlewareNormalization.d.ts +16 -0
- package/dist/services/http/routing/middlewareNormalization.js +28 -0
- package/dist/services/http/routing/middlewareNormalization.js.map +1 -0
- package/dist/services/http/types.d.ts +74 -0
- package/dist/services/http/types.js +8 -0
- package/dist/services/http/types.js.map +1 -0
- package/dist/services/validate/ValidateService.d.ts +46 -23
- package/dist/services/validate/ValidateService.js +101 -74
- package/dist/services/validate/ValidateService.js.map +1 -1
- package/dist/services/validate/ValidationError.d.ts +35 -0
- package/dist/services/validate/ValidationError.js +77 -0
- package/dist/services/validate/ValidationError.js.map +1 -0
- package/dist/services/validate/drivers/StandardSchemaDriver.d.ts +15 -0
- package/dist/services/validate/drivers/StandardSchemaDriver.js +34 -0
- package/dist/services/validate/drivers/StandardSchemaDriver.js.map +1 -0
- package/dist/services/validate/drivers/YupDriver.d.ts +21 -0
- package/dist/services/validate/drivers/YupDriver.js +66 -0
- package/dist/services/validate/drivers/YupDriver.js.map +1 -0
- package/dist/services/validate/types.d.ts +104 -0
- package/dist/services/validate/types.js +11 -0
- package/dist/services/validate/types.js.map +1 -0
- package/dist/tests/setupVitest.js +4 -1
- package/dist/tests/setupVitest.js.map +1 -1
- package/dist/tests/testHelpers.d.ts +18 -16
- package/package.json +17 -8
- package/dist/commands/Documentation.d.ts +0 -5
- package/dist/commands/Documentation.js +0 -15
- package/dist/commands/Documentation.js.map +0 -1
- package/dist/commands/GetOpenApiJson.d.ts +0 -17
- package/dist/commands/GetOpenApiJson.js +0 -272
- package/dist/commands/GetOpenApiJson.js.map +0 -1
- package/dist/services/documentation/DocumentationGenerator.d.ts +0 -11
- package/dist/services/documentation/DocumentationGenerator.js +0 -130
- package/dist/services/documentation/DocumentationGenerator.js.map +0 -1
- package/dist/services/validate/drivers/AbstractValidator.d.ts +0 -14
- package/dist/services/validate/drivers/AbstractValidator.js +0 -29
- package/dist/services/validate/drivers/AbstractValidator.js.map +0 -1
- package/dist/services/validate/drivers/CustomValidator.d.ts +0 -14
- package/dist/services/validate/drivers/CustomValidator.js +0 -48
- package/dist/services/validate/drivers/CustomValidator.js.map +0 -1
- package/dist/services/validate/drivers/YupValidator.d.ts +0 -13
- package/dist/services/validate/drivers/YupValidator.js +0 -86
- package/dist/services/validate/drivers/YupValidator.js.map +0 -1
package/dist/models/User.d.ts
CHANGED
|
@@ -87,13 +87,13 @@ declare class User extends BaseModel {
|
|
|
87
87
|
readonly getUserByToken: (this: UserModelLite, token: string) => Promise<false | (import("mongoose").Document<unknown, {}, {
|
|
88
88
|
isVerified: boolean;
|
|
89
89
|
locale: string;
|
|
90
|
+
createdAt?: NativeDate | null | undefined;
|
|
91
|
+
updatedAt?: NativeDate | null | undefined;
|
|
90
92
|
name?: {
|
|
91
93
|
first?: string | null | undefined;
|
|
92
94
|
last?: string | null | undefined;
|
|
93
95
|
nick?: string | null | undefined;
|
|
94
96
|
} | null | undefined;
|
|
95
|
-
createdAt?: NativeDate | null | undefined;
|
|
96
|
-
updatedAt?: NativeDate | null | undefined;
|
|
97
97
|
avatar?: string | null | undefined;
|
|
98
98
|
password?: string | null | undefined;
|
|
99
99
|
email?: string | null | undefined;
|
|
@@ -123,13 +123,13 @@ declare class User extends BaseModel {
|
|
|
123
123
|
}, {}, import("mongoose").DefaultSchemaOptions> & {
|
|
124
124
|
isVerified: boolean;
|
|
125
125
|
locale: string;
|
|
126
|
+
createdAt?: NativeDate | null | undefined;
|
|
127
|
+
updatedAt?: NativeDate | null | undefined;
|
|
126
128
|
name?: {
|
|
127
129
|
first?: string | null | undefined;
|
|
128
130
|
last?: string | null | undefined;
|
|
129
131
|
nick?: string | null | undefined;
|
|
130
132
|
} | null | undefined;
|
|
131
|
-
createdAt?: NativeDate | null | undefined;
|
|
132
|
-
updatedAt?: NativeDate | null | undefined;
|
|
133
133
|
avatar?: string | null | undefined;
|
|
134
134
|
password?: string | null | undefined;
|
|
135
135
|
email?: string | null | undefined;
|
|
@@ -171,13 +171,13 @@ declare class User extends BaseModel {
|
|
|
171
171
|
readonly getUserByEmail: (this: UserModelLite, email: string) => Promise<false | (import("mongoose").Document<unknown, {}, {
|
|
172
172
|
isVerified: boolean;
|
|
173
173
|
locale: string;
|
|
174
|
+
createdAt?: NativeDate | null | undefined;
|
|
175
|
+
updatedAt?: NativeDate | null | undefined;
|
|
174
176
|
name?: {
|
|
175
177
|
first?: string | null | undefined;
|
|
176
178
|
last?: string | null | undefined;
|
|
177
179
|
nick?: string | null | undefined;
|
|
178
180
|
} | null | undefined;
|
|
179
|
-
createdAt?: NativeDate | null | undefined;
|
|
180
|
-
updatedAt?: NativeDate | null | undefined;
|
|
181
181
|
avatar?: string | null | undefined;
|
|
182
182
|
password?: string | null | undefined;
|
|
183
183
|
email?: string | null | undefined;
|
|
@@ -207,13 +207,13 @@ declare class User extends BaseModel {
|
|
|
207
207
|
}, {}, import("mongoose").DefaultSchemaOptions> & {
|
|
208
208
|
isVerified: boolean;
|
|
209
209
|
locale: string;
|
|
210
|
+
createdAt?: NativeDate | null | undefined;
|
|
211
|
+
updatedAt?: NativeDate | null | undefined;
|
|
210
212
|
name?: {
|
|
211
213
|
first?: string | null | undefined;
|
|
212
214
|
last?: string | null | undefined;
|
|
213
215
|
nick?: string | null | undefined;
|
|
214
216
|
} | null | undefined;
|
|
215
|
-
createdAt?: NativeDate | null | undefined;
|
|
216
|
-
updatedAt?: NativeDate | null | undefined;
|
|
217
217
|
avatar?: string | null | undefined;
|
|
218
218
|
password?: string | null | undefined;
|
|
219
219
|
email?: string | null | undefined;
|
|
@@ -255,13 +255,13 @@ declare class User extends BaseModel {
|
|
|
255
255
|
readonly getUserByPasswordRecoveryToken: (this: UserModelLite, passwordRecoveryToken: string) => Promise<import("mongoose").Document<unknown, {}, {
|
|
256
256
|
isVerified: boolean;
|
|
257
257
|
locale: string;
|
|
258
|
+
createdAt?: NativeDate | null | undefined;
|
|
259
|
+
updatedAt?: NativeDate | null | undefined;
|
|
258
260
|
name?: {
|
|
259
261
|
first?: string | null | undefined;
|
|
260
262
|
last?: string | null | undefined;
|
|
261
263
|
nick?: string | null | undefined;
|
|
262
264
|
} | null | undefined;
|
|
263
|
-
createdAt?: NativeDate | null | undefined;
|
|
264
|
-
updatedAt?: NativeDate | null | undefined;
|
|
265
265
|
avatar?: string | null | undefined;
|
|
266
266
|
password?: string | null | undefined;
|
|
267
267
|
email?: string | null | undefined;
|
|
@@ -291,13 +291,13 @@ declare class User extends BaseModel {
|
|
|
291
291
|
}, {}, import("mongoose").DefaultSchemaOptions> & {
|
|
292
292
|
isVerified: boolean;
|
|
293
293
|
locale: string;
|
|
294
|
+
createdAt?: NativeDate | null | undefined;
|
|
295
|
+
updatedAt?: NativeDate | null | undefined;
|
|
294
296
|
name?: {
|
|
295
297
|
first?: string | null | undefined;
|
|
296
298
|
last?: string | null | undefined;
|
|
297
299
|
nick?: string | null | undefined;
|
|
298
300
|
} | null | undefined;
|
|
299
|
-
createdAt?: NativeDate | null | undefined;
|
|
300
|
-
updatedAt?: NativeDate | null | undefined;
|
|
301
301
|
avatar?: string | null | undefined;
|
|
302
302
|
password?: string | null | undefined;
|
|
303
303
|
email?: string | null | undefined;
|
|
@@ -339,13 +339,13 @@ declare class User extends BaseModel {
|
|
|
339
339
|
readonly getUserByVerificationToken: (this: UserModelLite, verificationToken: string) => Promise<import("mongoose").Document<unknown, {}, {
|
|
340
340
|
isVerified: boolean;
|
|
341
341
|
locale: string;
|
|
342
|
+
createdAt?: NativeDate | null | undefined;
|
|
343
|
+
updatedAt?: NativeDate | null | undefined;
|
|
342
344
|
name?: {
|
|
343
345
|
first?: string | null | undefined;
|
|
344
346
|
last?: string | null | undefined;
|
|
345
347
|
nick?: string | null | undefined;
|
|
346
348
|
} | null | undefined;
|
|
347
|
-
createdAt?: NativeDate | null | undefined;
|
|
348
|
-
updatedAt?: NativeDate | null | undefined;
|
|
349
349
|
avatar?: string | null | undefined;
|
|
350
350
|
password?: string | null | undefined;
|
|
351
351
|
email?: string | null | undefined;
|
|
@@ -375,13 +375,13 @@ declare class User extends BaseModel {
|
|
|
375
375
|
}, {}, import("mongoose").DefaultSchemaOptions> & {
|
|
376
376
|
isVerified: boolean;
|
|
377
377
|
locale: string;
|
|
378
|
+
createdAt?: NativeDate | null | undefined;
|
|
379
|
+
updatedAt?: NativeDate | null | undefined;
|
|
378
380
|
name?: {
|
|
379
381
|
first?: string | null | undefined;
|
|
380
382
|
last?: string | null | undefined;
|
|
381
383
|
nick?: string | null | undefined;
|
|
382
384
|
} | null | undefined;
|
|
383
|
-
createdAt?: NativeDate | null | undefined;
|
|
384
|
-
updatedAt?: NativeDate | null | undefined;
|
|
385
385
|
avatar?: string | null | undefined;
|
|
386
386
|
password?: string | null | undefined;
|
|
387
387
|
email?: string | null | undefined;
|
|
@@ -442,13 +442,13 @@ declare class User extends BaseModel {
|
|
|
442
442
|
readonly sendPasswordRecoveryEmail: (this: import("mongoose").Document<unknown, {}, {
|
|
443
443
|
isVerified: boolean;
|
|
444
444
|
locale: string;
|
|
445
|
+
createdAt?: NativeDate | null | undefined;
|
|
446
|
+
updatedAt?: NativeDate | null | undefined;
|
|
445
447
|
name?: {
|
|
446
448
|
first?: string | null | undefined;
|
|
447
449
|
last?: string | null | undefined;
|
|
448
450
|
nick?: string | null | undefined;
|
|
449
451
|
} | null | undefined;
|
|
450
|
-
createdAt?: NativeDate | null | undefined;
|
|
451
|
-
updatedAt?: NativeDate | null | undefined;
|
|
452
452
|
avatar?: string | null | undefined;
|
|
453
453
|
password?: string | null | undefined;
|
|
454
454
|
email?: string | null | undefined;
|
|
@@ -478,13 +478,13 @@ declare class User extends BaseModel {
|
|
|
478
478
|
}, {}, import("mongoose").DefaultSchemaOptions> & {
|
|
479
479
|
isVerified: boolean;
|
|
480
480
|
locale: string;
|
|
481
|
+
createdAt?: NativeDate | null | undefined;
|
|
482
|
+
updatedAt?: NativeDate | null | undefined;
|
|
481
483
|
name?: {
|
|
482
484
|
first?: string | null | undefined;
|
|
483
485
|
last?: string | null | undefined;
|
|
484
486
|
nick?: string | null | undefined;
|
|
485
487
|
} | null | undefined;
|
|
486
|
-
createdAt?: NativeDate | null | undefined;
|
|
487
|
-
updatedAt?: NativeDate | null | undefined;
|
|
488
488
|
avatar?: string | null | undefined;
|
|
489
489
|
password?: string | null | undefined;
|
|
490
490
|
email?: string | null | undefined;
|
|
@@ -531,13 +531,13 @@ declare class User extends BaseModel {
|
|
|
531
531
|
readonly sendVerificationEmail: (this: import("mongoose").Document<unknown, {}, {
|
|
532
532
|
isVerified: boolean;
|
|
533
533
|
locale: string;
|
|
534
|
+
createdAt?: NativeDate | null | undefined;
|
|
535
|
+
updatedAt?: NativeDate | null | undefined;
|
|
534
536
|
name?: {
|
|
535
537
|
first?: string | null | undefined;
|
|
536
538
|
last?: string | null | undefined;
|
|
537
539
|
nick?: string | null | undefined;
|
|
538
540
|
} | null | undefined;
|
|
539
|
-
createdAt?: NativeDate | null | undefined;
|
|
540
|
-
updatedAt?: NativeDate | null | undefined;
|
|
541
541
|
avatar?: string | null | undefined;
|
|
542
542
|
password?: string | null | undefined;
|
|
543
543
|
email?: string | null | undefined;
|
|
@@ -567,13 +567,13 @@ declare class User extends BaseModel {
|
|
|
567
567
|
}, {}, import("mongoose").DefaultSchemaOptions> & {
|
|
568
568
|
isVerified: boolean;
|
|
569
569
|
locale: string;
|
|
570
|
+
createdAt?: NativeDate | null | undefined;
|
|
571
|
+
updatedAt?: NativeDate | null | undefined;
|
|
570
572
|
name?: {
|
|
571
573
|
first?: string | null | undefined;
|
|
572
574
|
last?: string | null | undefined;
|
|
573
575
|
nick?: string | null | undefined;
|
|
574
576
|
} | null | undefined;
|
|
575
|
-
createdAt?: NativeDate | null | undefined;
|
|
576
|
-
updatedAt?: NativeDate | null | undefined;
|
|
577
577
|
avatar?: string | null | undefined;
|
|
578
578
|
password?: string | null | undefined;
|
|
579
579
|
email?: string | null | undefined;
|
|
@@ -616,13 +616,13 @@ declare class User extends BaseModel {
|
|
|
616
616
|
readonly getPublic: (this: import("mongoose").Document<unknown, {}, {
|
|
617
617
|
isVerified: boolean;
|
|
618
618
|
locale: string;
|
|
619
|
+
createdAt?: NativeDate | null | undefined;
|
|
620
|
+
updatedAt?: NativeDate | null | undefined;
|
|
619
621
|
name?: {
|
|
620
622
|
first?: string | null | undefined;
|
|
621
623
|
last?: string | null | undefined;
|
|
622
624
|
nick?: string | null | undefined;
|
|
623
625
|
} | null | undefined;
|
|
624
|
-
createdAt?: NativeDate | null | undefined;
|
|
625
|
-
updatedAt?: NativeDate | null | undefined;
|
|
626
626
|
avatar?: string | null | undefined;
|
|
627
627
|
password?: string | null | undefined;
|
|
628
628
|
email?: string | null | undefined;
|
|
@@ -652,13 +652,13 @@ declare class User extends BaseModel {
|
|
|
652
652
|
}, {}, import("mongoose").DefaultSchemaOptions> & {
|
|
653
653
|
isVerified: boolean;
|
|
654
654
|
locale: string;
|
|
655
|
+
createdAt?: NativeDate | null | undefined;
|
|
656
|
+
updatedAt?: NativeDate | null | undefined;
|
|
655
657
|
name?: {
|
|
656
658
|
first?: string | null | undefined;
|
|
657
659
|
last?: string | null | undefined;
|
|
658
660
|
nick?: string | null | undefined;
|
|
659
661
|
} | null | undefined;
|
|
660
|
-
createdAt?: NativeDate | null | undefined;
|
|
661
|
-
updatedAt?: NativeDate | null | undefined;
|
|
662
662
|
avatar?: string | null | undefined;
|
|
663
663
|
password?: string | null | undefined;
|
|
664
664
|
email?: string | null | undefined;
|
package/dist/models/UserOld.d.ts
CHANGED
|
@@ -121,7 +121,9 @@ declare class UserOld extends AbstractModel<IUser, IAbstractModelMethods<IUser>,
|
|
|
121
121
|
_id: import("mongoose").Types.ObjectId;
|
|
122
122
|
} & {
|
|
123
123
|
__v: number;
|
|
124
|
-
}, "getSuper"> & IAbstractModelMethods<IUser>
|
|
124
|
+
}, "id" | "getSuper"> & IAbstractModelMethods<IUser> & {
|
|
125
|
+
id: string;
|
|
126
|
+
})>;
|
|
125
127
|
generateToken(this: InstanceType<UserOld['mongooseModel']>): Promise<{
|
|
126
128
|
token: string;
|
|
127
129
|
valid: Date;
|
|
@@ -134,7 +136,7 @@ declare class UserOld extends AbstractModel<IUser, IAbstractModelMethods<IUser>,
|
|
|
134
136
|
nick: string;
|
|
135
137
|
};
|
|
136
138
|
email: string;
|
|
137
|
-
id: string
|
|
139
|
+
id: string;
|
|
138
140
|
isVerified: boolean;
|
|
139
141
|
permissions: string[];
|
|
140
142
|
locale: string;
|
|
@@ -144,12 +146,16 @@ declare class UserOld extends AbstractModel<IUser, IAbstractModelMethods<IUser>,
|
|
|
144
146
|
_id: import("mongoose").Types.ObjectId;
|
|
145
147
|
} & {
|
|
146
148
|
__v: number;
|
|
147
|
-
}, "getSuper"> & IAbstractModelMethods<IUser>
|
|
149
|
+
}, "id" | "getSuper"> & IAbstractModelMethods<IUser> & {
|
|
150
|
+
id: string;
|
|
151
|
+
})>;
|
|
148
152
|
static getUserByEmail(this: UserOld['mongooseModel'], email: string): Promise<false | (import("mongoose").Document<unknown, object, IUser, {}, import("mongoose").DefaultSchemaOptions> & Omit<IUser & {
|
|
149
153
|
_id: import("mongoose").Types.ObjectId;
|
|
150
154
|
} & {
|
|
151
155
|
__v: number;
|
|
152
|
-
}, "getSuper"> & IAbstractModelMethods<IUser>
|
|
156
|
+
}, "id" | "getSuper"> & IAbstractModelMethods<IUser> & {
|
|
157
|
+
id: string;
|
|
158
|
+
})>;
|
|
153
159
|
static generateUserPasswordRecoveryToken(userMongoose: InstanceType<UserOld['mongooseModel']>): Promise<{
|
|
154
160
|
token: string;
|
|
155
161
|
until: number;
|
|
@@ -158,7 +164,9 @@ declare class UserOld extends AbstractModel<IUser, IAbstractModelMethods<IUser>,
|
|
|
158
164
|
_id: import("mongoose").Types.ObjectId;
|
|
159
165
|
} & {
|
|
160
166
|
__v: number;
|
|
161
|
-
}, "getSuper"> & IAbstractModelMethods<IUser
|
|
167
|
+
}, "id" | "getSuper"> & IAbstractModelMethods<IUser> & {
|
|
168
|
+
id: string;
|
|
169
|
+
}>;
|
|
162
170
|
sendPasswordRecoveryEmail(this: InstanceType<UserOld['mongooseModel']>, i18n: {
|
|
163
171
|
t: TFunction;
|
|
164
172
|
language: string;
|
|
@@ -171,7 +179,9 @@ declare class UserOld extends AbstractModel<IUser, IAbstractModelMethods<IUser>,
|
|
|
171
179
|
_id: import("mongoose").Types.ObjectId;
|
|
172
180
|
} & {
|
|
173
181
|
__v: number;
|
|
174
|
-
}, "getSuper"> & IAbstractModelMethods<IUser
|
|
182
|
+
}, "id" | "getSuper"> & IAbstractModelMethods<IUser> & {
|
|
183
|
+
id: string;
|
|
184
|
+
}>;
|
|
175
185
|
sendVerificationEmail(this: InstanceType<UserOld['mongooseModel']>, i18n: {
|
|
176
186
|
t: TFunction;
|
|
177
187
|
language: string;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { IRouter } from 'express';
|
|
2
1
|
import type { IApp } from '../server.ts';
|
|
3
2
|
import type AbstractMiddleware from '../services/http/middleware/AbstractMiddleware.ts';
|
|
3
|
+
import type { BodyParsingMode } from '../services/http/routing/RouteNode.ts';
|
|
4
|
+
import type { StandardSchemaV1 } from '../services/validate/types.ts';
|
|
4
5
|
import Base from './Base.ts';
|
|
5
|
-
type MiddlewareWithParamsTuple = [
|
|
6
|
+
type MiddlewareWithParamsTuple = readonly [
|
|
6
7
|
typeof AbstractMiddleware,
|
|
7
8
|
Record<string, unknown>
|
|
8
9
|
];
|
|
@@ -12,12 +13,9 @@ type RouteObject = {
|
|
|
12
13
|
handler: RouteHandler;
|
|
13
14
|
description?: string;
|
|
14
15
|
middleware?: TMiddleware | null;
|
|
15
|
-
request?:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
query?: (unknown & {
|
|
19
|
-
fields: unknown;
|
|
20
|
-
}) | null;
|
|
16
|
+
request?: StandardSchemaV1 | null;
|
|
17
|
+
query?: StandardSchemaV1 | null;
|
|
18
|
+
bodyParsing?: BodyParsingMode;
|
|
21
19
|
};
|
|
22
20
|
export type RouteParams = {
|
|
23
21
|
[method: string]: {
|
|
@@ -33,27 +31,7 @@ export type RouteParams = {
|
|
|
33
31
|
*/
|
|
34
32
|
declare class AbstractController extends Base {
|
|
35
33
|
prefix: string;
|
|
36
|
-
|
|
37
|
-
constructor(app: IApp, prefix: string, isExpressMergeParams?: boolean);
|
|
38
|
-
/**
|
|
39
|
-
* Parse middlewares to be an object.
|
|
40
|
-
*/
|
|
41
|
-
parseMiddlewares(middlewareMap: Map<string, TMiddleware>, httpPath: string): {
|
|
42
|
-
name: string;
|
|
43
|
-
method: string;
|
|
44
|
-
path: string;
|
|
45
|
-
fullPath: string;
|
|
46
|
-
params: {};
|
|
47
|
-
relatedQueryParameters: import("yup").ObjectSchema<{}, import("yup").AnyObject, {}, "">;
|
|
48
|
-
authParams: {
|
|
49
|
-
name: string;
|
|
50
|
-
type: string;
|
|
51
|
-
in?: string;
|
|
52
|
-
scheme?: string;
|
|
53
|
-
description: string;
|
|
54
|
-
}[];
|
|
55
|
-
MiddlewareFunction: typeof AbstractMiddleware;
|
|
56
|
-
}[];
|
|
34
|
+
constructor(app: IApp, prefix: string);
|
|
57
35
|
/**
|
|
58
36
|
* Object with routes. Routes relative to controller
|
|
59
37
|
* @example
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import express from 'express';
|
|
2
|
-
import DocumentationGenerator from '../services/documentation/DocumentationGenerator.js';
|
|
3
1
|
import Auth from "../services/http/middleware/Auth.js";
|
|
4
2
|
import GetUserByToken from "../services/http/middleware/GetUserByToken.js";
|
|
5
|
-
import ValidateService from '../services/validate/ValidateService.js';
|
|
6
3
|
import Base from "./Base.js";
|
|
7
4
|
/**
|
|
8
5
|
* Abstract controller. You should extend any controller from them.
|
|
@@ -13,258 +10,9 @@ import Base from "./Base.js";
|
|
|
13
10
|
*/
|
|
14
11
|
class AbstractController extends Base {
|
|
15
12
|
prefix = '';
|
|
16
|
-
|
|
17
|
-
constructor(app, prefix, isExpressMergeParams = false) {
|
|
18
|
-
const time = Date.now();
|
|
13
|
+
constructor(app, prefix) {
|
|
19
14
|
super(app);
|
|
20
15
|
this.prefix = prefix;
|
|
21
|
-
this.router = express.Router({
|
|
22
|
-
mergeParams: isExpressMergeParams,
|
|
23
|
-
});
|
|
24
|
-
const { routes } = this;
|
|
25
|
-
const httpPath = this.getHttpPath();
|
|
26
|
-
/**
|
|
27
|
-
* Grab route middleware into one Map
|
|
28
|
-
*/
|
|
29
|
-
const routeMiddlewares = new Map();
|
|
30
|
-
Object.entries(routes).forEach(([method, methodRoutes]) => {
|
|
31
|
-
Object.entries(methodRoutes).forEach(([route, routeParam]) => {
|
|
32
|
-
if (typeof routeParam === 'object' &&
|
|
33
|
-
routeParam !== null &&
|
|
34
|
-
'middleware' in routeParam &&
|
|
35
|
-
routeParam.middleware) {
|
|
36
|
-
const fullRoute = method.toUpperCase() + route;
|
|
37
|
-
if (!routeMiddlewares.has(fullRoute)) {
|
|
38
|
-
routeMiddlewares.set(fullRoute, []);
|
|
39
|
-
}
|
|
40
|
-
routeMiddlewares.set(fullRoute, [
|
|
41
|
-
...routeMiddlewares.get(fullRoute),
|
|
42
|
-
...routeParam.middleware,
|
|
43
|
-
]);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
const routeMiddlewaresReg = this.parseMiddlewares(routeMiddlewares, httpPath);
|
|
48
|
-
const middlewaresInfo = this.parseMiddlewares(this.constructor.middleware, httpPath);
|
|
49
|
-
const routesInfo = [];
|
|
50
|
-
/**
|
|
51
|
-
* Register controller middleware
|
|
52
|
-
*/
|
|
53
|
-
for (const middleware of middlewaresInfo) {
|
|
54
|
-
this.router[middleware.method](middleware.path, new middleware.MiddlewareFunction(this.app, middleware.params).getMiddleware());
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Register routes itself
|
|
58
|
-
*/
|
|
59
|
-
for (const verb in routes) {
|
|
60
|
-
if (typeof this.router[verb] !== 'function') {
|
|
61
|
-
this.logger?.error(`Method ${verb} not exist for router. Please check your codebase`);
|
|
62
|
-
continue;
|
|
63
|
-
}
|
|
64
|
-
for (const path in routes[verb]) {
|
|
65
|
-
const routeAdditionalMiddlewares = routeMiddlewaresReg.filter((middleware) => middleware.path === path && middleware.method === verb);
|
|
66
|
-
let routeObject = routes[verb][path];
|
|
67
|
-
if (Object.prototype.toString.call(routeObject) !== '[object Object]') {
|
|
68
|
-
// for support firect pass function instead of object
|
|
69
|
-
routeObject = {
|
|
70
|
-
handler: routeObject,
|
|
71
|
-
request: null,
|
|
72
|
-
query: null,
|
|
73
|
-
middleware: null,
|
|
74
|
-
};
|
|
75
|
-
if (typeof routeObject.handler !== 'function') {
|
|
76
|
-
this.logger?.error(`Can't resolve function '${routeObject.handler}' for controller '${this.getConstructorName()}'`);
|
|
77
|
-
continue;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
const { handler } = routeObject;
|
|
81
|
-
let fnName;
|
|
82
|
-
if (typeof handler === 'function') {
|
|
83
|
-
fnName = handler.name;
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
fnName = undefined;
|
|
87
|
-
}
|
|
88
|
-
const fullPath = `/${httpPath}/${path}`
|
|
89
|
-
.split('//')
|
|
90
|
-
.join('/')
|
|
91
|
-
.split('//')
|
|
92
|
-
.join('/');
|
|
93
|
-
routesInfo.push({
|
|
94
|
-
name: fnName,
|
|
95
|
-
description: routeObject?.description,
|
|
96
|
-
method: verb.toUpperCase(),
|
|
97
|
-
fields: routeObject?.request?.fields,
|
|
98
|
-
queryFields: routeObject?.query?.fields,
|
|
99
|
-
path,
|
|
100
|
-
fullPath,
|
|
101
|
-
});
|
|
102
|
-
// this.logger.verbose(
|
|
103
|
-
// `Controller '${this.getConstructorName()}' register function '${fnName}' for method '${verb}' and path '${path}' Full path '${fullPath}'`,
|
|
104
|
-
// );
|
|
105
|
-
let additionalMiddlewares;
|
|
106
|
-
if (routeAdditionalMiddlewares.length > 0) {
|
|
107
|
-
additionalMiddlewares = Array.from(routeAdditionalMiddlewares, ({ MiddlewareFunction, params }) => new MiddlewareFunction(this.app, params).getMiddleware());
|
|
108
|
-
}
|
|
109
|
-
this.router[verb](path, additionalMiddlewares || [], async (req, res, next) => {
|
|
110
|
-
const requestObj = {
|
|
111
|
-
query: req.query,
|
|
112
|
-
body: req.body,
|
|
113
|
-
appInfo: req.appInfo,
|
|
114
|
-
};
|
|
115
|
-
try {
|
|
116
|
-
req.appInfo.request = await new ValidateService(this.app, routeObject?.request).validateReqData(requestObj, {
|
|
117
|
-
selectedReqData: req.body,
|
|
118
|
-
additionalMiddlewareFieldsData: {
|
|
119
|
-
middlewaresInfo,
|
|
120
|
-
routeMiddlewaresReg,
|
|
121
|
-
options: {
|
|
122
|
-
method: verb,
|
|
123
|
-
path: fullPath,
|
|
124
|
-
prefix: 'request',
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
});
|
|
128
|
-
req.appInfo.query = await new ValidateService(this.app, routeObject?.query).validateReqData(requestObj, {
|
|
129
|
-
selectedReqData: req.query,
|
|
130
|
-
additionalMiddlewareFieldsData: {
|
|
131
|
-
middlewaresInfo,
|
|
132
|
-
routeMiddlewaresReg,
|
|
133
|
-
options: {
|
|
134
|
-
method: verb,
|
|
135
|
-
path: fullPath,
|
|
136
|
-
prefix: 'query',
|
|
137
|
-
},
|
|
138
|
-
},
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
catch (err) {
|
|
142
|
-
return res.status(400).json({
|
|
143
|
-
errors: err instanceof Error ? err.message : String(err),
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
// req.body = new Proxy(req.body, {
|
|
147
|
-
// get: (target, prop) => {
|
|
148
|
-
// this.logger.warn(
|
|
149
|
-
// 'Please not use "req.body" directly. Implement "request" and use "req.appInfo.request" ',
|
|
150
|
-
// );
|
|
151
|
-
// return target[prop];
|
|
152
|
-
// },
|
|
153
|
-
// });
|
|
154
|
-
// req.query = new Proxy(req.query, {
|
|
155
|
-
// get: (target, prop) => {
|
|
156
|
-
// this.logger.warn(
|
|
157
|
-
// 'Please not use "req.query" directly. Implement "query" and use "req.appInfo.query" ',
|
|
158
|
-
// );
|
|
159
|
-
// return target[prop];
|
|
160
|
-
// },
|
|
161
|
-
// });
|
|
162
|
-
if (!routeObject.handler) {
|
|
163
|
-
this.logger?.error(`Route object have no handler defined`);
|
|
164
|
-
return res.status(500).json({
|
|
165
|
-
message: 'Platform error 2. Please check later or contact support',
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
if (routeObject.handler.constructor.name !== 'AsyncFunction') {
|
|
169
|
-
const error = "Handler should be AsyncFunction. Perhabs you miss 'async' of function declaration?";
|
|
170
|
-
this.logger?.error(error);
|
|
171
|
-
return res.status(500).json({
|
|
172
|
-
message: 'Platform error. Please check later or contact support',
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
return routeObject.handler
|
|
176
|
-
.call(this, req, res, next)
|
|
177
|
-
.catch((e) => {
|
|
178
|
-
this.logger?.error(e);
|
|
179
|
-
return res.status(500).json({
|
|
180
|
-
message: 'Platform error. Please check later or contact support',
|
|
181
|
-
});
|
|
182
|
-
});
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* Generate text info
|
|
188
|
-
*/
|
|
189
|
-
const text = ['', `Controller '${this.getConstructorName()}' registered.`];
|
|
190
|
-
const reports = {
|
|
191
|
-
'Middlewares:': middlewaresInfo,
|
|
192
|
-
'Route middlewares:': routeMiddlewaresReg,
|
|
193
|
-
'Callbacks:': routesInfo,
|
|
194
|
-
};
|
|
195
|
-
for (const key in reports) {
|
|
196
|
-
text.push(`${key}`);
|
|
197
|
-
for (const item of reports[key]) {
|
|
198
|
-
text.push(`Path:'${item.path}'. Full path: '${item.fullPath}'. Method: '${item.method.toUpperCase()}'. Function: '${item.name}'`);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
text.push(`Time: ${Date.now() - time} ms`);
|
|
202
|
-
this.logger?.verbose(text.join('\n'));
|
|
203
|
-
/**
|
|
204
|
-
* Generate documentation
|
|
205
|
-
*/
|
|
206
|
-
if (!this.app.httpServer) {
|
|
207
|
-
this.app.documentation?.push(new DocumentationGenerator(this.app).convertDataToDocumentationElement(this.getConstructorName(), routesInfo, middlewaresInfo, routeMiddlewaresReg));
|
|
208
|
-
}
|
|
209
|
-
else {
|
|
210
|
-
this.app.httpServer.express.use(httpPath, this.router);
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Parse middlewares to be an object.
|
|
215
|
-
*/
|
|
216
|
-
parseMiddlewares(middlewareMap, httpPath) {
|
|
217
|
-
const middlewaresInfo = [];
|
|
218
|
-
for (let [path, middleware] of middlewareMap) {
|
|
219
|
-
if (!Array.isArray(middleware)) {
|
|
220
|
-
middleware = [middleware];
|
|
221
|
-
}
|
|
222
|
-
for (const M of middleware) {
|
|
223
|
-
let method = 'all';
|
|
224
|
-
let realPath = path;
|
|
225
|
-
if (typeof realPath !== 'string') {
|
|
226
|
-
this.logger?.error(`Path not a string ${realPath}. Please check it`);
|
|
227
|
-
continue;
|
|
228
|
-
}
|
|
229
|
-
if (!realPath.startsWith('/')) {
|
|
230
|
-
method = realPath.split('/')[0]?.toLowerCase();
|
|
231
|
-
if (!method) {
|
|
232
|
-
this.logger?.error(`Method not found for ${realPath}`);
|
|
233
|
-
continue;
|
|
234
|
-
}
|
|
235
|
-
realPath = realPath.substring(method.length);
|
|
236
|
-
}
|
|
237
|
-
if (typeof this.router[method] !== 'function') {
|
|
238
|
-
this.logger?.error(`Method ${method} not exist for middleware. Please check your codebase`);
|
|
239
|
-
continue;
|
|
240
|
-
}
|
|
241
|
-
const fullPath = `/${httpPath}/${realPath.toUpperCase()}`
|
|
242
|
-
.split('//')
|
|
243
|
-
.join('/')
|
|
244
|
-
.split('//')
|
|
245
|
-
.join('/');
|
|
246
|
-
let MiddlewareFunction;
|
|
247
|
-
let middlewareParams = {};
|
|
248
|
-
if (Array.isArray(M)) {
|
|
249
|
-
[MiddlewareFunction, middlewareParams] = M;
|
|
250
|
-
}
|
|
251
|
-
else {
|
|
252
|
-
MiddlewareFunction = M;
|
|
253
|
-
}
|
|
254
|
-
middlewaresInfo.push({
|
|
255
|
-
name: MiddlewareFunction.name,
|
|
256
|
-
method,
|
|
257
|
-
path: realPath,
|
|
258
|
-
fullPath,
|
|
259
|
-
params: middlewareParams,
|
|
260
|
-
relatedQueryParameters: new MiddlewareFunction(this.app, middlewareParams)?.relatedQueryParameters,
|
|
261
|
-
authParams: new MiddlewareFunction(this.app, middlewareParams)
|
|
262
|
-
?.usedAuthParameters,
|
|
263
|
-
MiddlewareFunction,
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
return middlewaresInfo;
|
|
268
16
|
}
|
|
269
17
|
/**
|
|
270
18
|
* Object with routes. Routes relative to controller
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractController.js","sourceRoot":"","sources":["../../src/modules/AbstractController.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AbstractController.js","sourceRoot":"","sources":["../../src/modules/AbstractController.ts"],"names":[],"mappings":"AAEA,OAAO,IAAI,MAAM,qCAAqC,CAAC;AACvD,OAAO,cAAc,MAAM,+CAA+C,CAAC;AAG3E,OAAO,IAAI,MAAM,WAAW,CAAC;AA0B7B;;;;;;GAMG;AACH,MAAM,kBAAmB,SAAQ,IAAI;IACnC,MAAM,GAAG,EAAE,CAAC;IAEZ,YAAY,GAAS,EAAE,MAAc;QACnC,KAAK,CAAC,GAAG,CAAC,CAAC;QACX,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,IAAI,MAAM;QACR,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,iDAAiD,CAAC,CAAC;QACrE,OAAO,EAAE,CAAC;IACZ,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,MAAM,KAAK,UAAU;QACnB,OAAO,IAAI,GAAG,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1D,CAAC;IAED;;OAEG;IACH,kBAAkB;QAChB,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,IAClE,IAAI,CAAC,WAAW,CAAC,IACnB,EAAE,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,WAAW;QACT,OAAO,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC1E,CAAC;IAED,MAAM,KAAK,WAAW;QACpB,OAAO,YAAY,CAAC;IACtB,CAAC;CACF;AAED,eAAe,kBAAkB,CAAC"}
|